-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
156 lines (131 loc) · 4.63 KB
/
Copy pathMakefile
File metadata and controls
156 lines (131 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# SPDX-License-Identifier: 0BSD
#
# p96cts -- P96 driver conformance test suite (AmigaOS m68k target).
#
# To build using the default containerized toolchain:
# make docker-build
DOCKER_RUN = docker run --rm --user $$(id -u):$$(id -g) -v .:/src -w /src berniecodewiz/m68k-amigaos-gcc:gcc-v16.2
# Or build with a specified compiler:
#
# make CC=m68k-amigaos-gcc
CC = m68k-amigaos-gcc
# With a toolchain that does not bundle the P96 headers (e.g. bebbo's),
# unpack P96Develop.lha and point P96_CFLAGS at the headers:
#
# make P96_CFLAGS=-I/path/to/Picasso96Develop/Include
#
P96_CFLAGS ?=
# Allow overriding code generation flags
CFLAGS ?= -O3 -fomit-frame-pointer -m68020-60 $(WARNINGS)
# Normally bundled with AmigaPorts/m68k-amigaos-gcc
PNG_CFLAGS ?=
PNG_LIBS ?= -lpng -lz -lm
TARGET = p96cts
BUILD ?= build
AMIGA_VERSION ?= $(shell git describe --tags --dirty | sed -r 's/^(release_|v)//')
AMIGA_DATE := $(shell date '+%-d.%-m.%Y')
# Strict enough to catch the usual C mistakes without fighting the Amiga headers.
# -Wvla and -Walloca are policy: AmigaOS tasks run on a small fixed stack.
WARNINGS = -Wall -Wextra -Wshadow -Wpointer-arith -Wundef -Wwrite-strings \
-Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition \
-Wfloat-conversion -Wdouble-promotion -Wduplicated-cond \
-Wduplicated-branches -Wlogical-op -Wformat=2 -Wcast-align \
-Wnull-dereference -Wvla -Walloca
ALL_CFLAGS = $(CFLAGS) -g -noixemul -Isrc $(P96_CFLAGS) $(PNG_CFLAGS) \
-DAMIGA_VERSION=\"$(AMIGA_VERSION)\" \
-DAMIGA_DATE=\"$(AMIGA_DATE)\"
SRCS = \
src/backdrop.c \
src/gfx.c \
src/glyph.c \
src/layer.c \
src/main.c \
src/modes.c \
src/palette.c \
src/pngio.c \
src/report.c \
src/rtg.c \
src/runtest.c \
src/timer.c \
src/wall.c \
tests/bitmapscale.c \
tests/bltbitmap.c \
tests/bltpattern.c \
tests/blttemplate.c \
tests/clipblit.c \
tests/drawline.c \
tests/pixelarray.c \
tests/rectfill.c \
tests/scrollraster.c
OBJS = $(SRCS:%.c=$(BUILD)/%.o)
all: $(TARGET)
# p96cts_unstripped is what to point m68k-amigaos-gdb at while bgdbserver runs
# the stripped p96cts on the Amiga: 17k of that is the symbol table, which is
# enough for breakpoints by name and named frames in a backtrace.
#
# Source-level debugging does not work yet. The compiler emits DWARF per
# object, but linking to hunk drops every .debug_* section, so gdb has no line
# table. -g is kept anyway -- it costs 16 bytes here, and the day the linker
# carries DWARF this starts working on its own.
UNSTRIPPED = $(TARGET)_unstripped
STRIP = $(CC:gcc=strip)
$(UNSTRIPPED): $(OBJS)
$(CC) $(ALL_CFLAGS) -o $@ $(OBJS) $(PNG_LIBS)
# chmod because strip -o writes a fresh file with default permissions, and a
# HOSTFS mount maps the unix x bit to the Amiga e bit: without it the guest
# answers "Unknown command" even given the full path.
$(TARGET): $(UNSTRIPPED)
$(STRIP) -o $@ $<
chmod +x $@
HEADERS = \
src/backdrop.h \
src/gfx.h \
src/glyph.h \
src/layer.h \
src/modes.h \
src/p96cts.h \
src/palette.h \
src/pngio.h \
src/report.h \
src/rtg.h \
src/runtest.h \
src/timer.h \
src/wall.h
$(BUILD)/%.o: %.c $(HEADERS)
@mkdir -p $(@D)
$(CC) $(ALL_CFLAGS) -c -o $@ $<
clean:
rm -rf $(BUILD) $(TARGET) $(UNSTRIPPED)
# Keep the sources compilable as C++ too: no implicit conversions from
# void * or into enums. Syntax-only, with the C-only warnings dropped, and
# without g++'s complaint about designated initializers that leave trailing
# fields to zero -- deliberate throughout the test tables.
CXX = $(CC:gcc=g++)
CXX_WARNINGS = $(filter-out -Wstrict-prototypes -Wmissing-prototypes \
-Wold-style-definition,$(WARNINGS)) -Wno-missing-field-initializers
check-cxx:
$(CXX) -x c++ -fsyntax-only $(filter-out $(WARNINGS),$(ALL_CFLAGS)) \
$(CXX_WARNINGS) $(SRCS)
# The git tag is "v0.1"; the archive is "p96cts-0.1.lha", matching both the
# Aminet convention and the program's own "p96cts 0.1" banner.
RELDIR = $(TARGET)-$(TAG:v%=%)
# Pack the binary, its documentation and the golden set built from the same
# commit, so the archive drops onto an Amiga as a matched pair. Needs LHa for
# UNIX: distributions now ship lhasa, which only extracts, so on most hosts
# this wants the docker-release target below.
release: $(TARGET)
@test -n "$(TAG)" || { echo "usage: make release TAG=v0.1" >&2; exit 2; }
rm -rf $(RELDIR) $(RELDIR).lha
mkdir -p $(RELDIR)
cp $(TARGET) README.md LICENSE $(RELDIR)/
cp -r golden $(RELDIR)/
lha a $(RELDIR).lha $(RELDIR)/
rm -rf $(RELDIR)
@echo "wrote $(RELDIR).lha"
docker-build:
$(DOCKER_RUN) make all
docker-clean:
$(DOCKER_RUN) make clean
docker-release:
$(DOCKER_RUN) make release TAG=$(TAG)
.PHONY: all clean check-cxx release docker-build docker-clean docker-release