-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (116 loc) · 4.16 KB
/
Copy pathMakefile
File metadata and controls
138 lines (116 loc) · 4.16 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
# SPDX-License-Identifier: 0BSD
#
# p96cts -- P96 driver conformance test suite (AmigaOS m68k target).
#
# Needs an m68k-amigaos-gcc and the Picasso96 developer includes. The default
# P96_CFLAGS points where the amiga-gcc toolchain ships them, so a
# containerised build needs no arguments at all:
#
# make docker-build
#
# With a toolchain that does not bundle them (e.g. bebbo's), point at an
# unpacked P96Develop.lha instead:
#
# make CC=m68k-amigaos-gcc P96_CFLAGS=-I/path/to/Picasso96Develop/Include
# Plain assignment, not ?=: make predefines CC as "cc". A command-line
# CC=... still overrides this.
CC = m68k-amigaos-gcc
DOCKER_RUN = docker run --rm --user $$(id -u):$$(id -g) -v .:/src -w /src stefanreinauer/amiga-gcc:gcc-v16.1
TARGET = p96cts
AMIGA_VERSION ?= $(shell git describe --tags --dirty | sed -r 's/^(release_|v)//')
AMIGA_DATE := $(shell date '+%-d.%-m.%Y')
OBJS = \
src/backdrop.o \
src/gfx.o \
src/glyph.o \
src/layer.o \
src/main.o \
src/modes.o \
src/palette.o \
src/pngio.o \
src/report.o \
src/rtg.o \
src/runtest.o \
src/timer.o \
src/wall.o \
tests/bitmapscale.o \
tests/bltbitmap.o \
tests/bltpattern.o \
tests/blttemplate.o \
tests/clipblit.o \
tests/drawline.o \
tests/pixelarray.o \
tests/rectfill.o \
tests/scrollraster.o
# zlib and libpng, built for this target and committed. See
# third_party/README.md for provenance and how to rebuild them.
PNG_CFLAGS = -Ithird_party/libpng/include -Ithird_party/zlib/include
PNG_LIBS = third_party/libpng/lib/libpng16.a third_party/zlib/lib/libz.a
# Strict enough to catch the usual C mistakes without fighting the Amiga
# headers. -Wstrict-prototypes and -Wold-style-definition matter here because
# these sources are otherwise easy to write in K&R style by accident.
WARNINGS = -Wall -Wextra -Wshadow -Wpointer-arith -Wundef -Wwrite-strings \
-Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition
# Allow overriding code generation flags
CFLAGS ?= -O3 -fomit-frame-pointer -m68020 $(WARNINGS)
ALL_CFLAGS = $(CFLAGS) -noixemul -Isrc $(P96_CFLAGS) $(PNG_CFLAGS) \
-DAMIGA_VERSION=\"$(AMIGA_VERSION)\" \
-DAMIGA_DATE=\"$(AMIGA_DATE)\"
all: $(TARGET)
# libpng needs libm for its gamma arithmetic; both are software floating
# point, so no FPU is required at runtime.
$(TARGET): $(OBJS) $(PNG_LIBS)
$(CC) $(ALL_CFLAGS) -o $@ $(OBJS) $(PNG_LIBS) -lm
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
%.o: %.c $(HEADERS)
$(CC) $(ALL_CFLAGS) -c -o $@ $<
clean:
rm -f $(OBJS) $(TARGET)
# 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) $(OBJS:.o=.c)
# 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-thirdparty:
$(DOCKER_RUN) bash third_party/build.sh
docker-release:
$(DOCKER_RUN) make release TAG=$(TAG)
.PHONY: all clean check-cxx release docker-build docker-clean docker-thirdparty docker-release