-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
184 lines (153 loc) · 4.75 KB
/
makefile
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# The Virus, a ZX Spectrum game
# Copyright (C) 2022 Derek Fountain
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
CC=zcc
AS=zcc
APPMAKE=z88dk-appmake
TARGET=+zx
VERBOSITY=-vn
CRT=31
PRAGMA_FILE=zpragma.inc
# Tested at an arbitrary point in development. -SO2 ran test in 11.80 secs and left 4228 bytes free.
# -SO3 ran test in 11.00 secs and left 4582 bytes free. So -SO3 produces smaller, faster code.
#
C_OPT_FLAGS=-SO3 --max-allocs-per-node200000 -DNDEBUG --c-code-in-asm --std-sdcc2x --list
#C_OPT_FLAGS=--c-code-in-asm --std-sdcc2x --list
CFLAGS=$(TARGET) $(VERBOSITY) -c $(C_OPT_FLAGS) -preserve -compiler sdcc -clib=sdcc_iy -pragma-include:$(PRAGMA_FILE)
LDFLAGS=$(TARGET) $(VERBOSITY) -m -clib=sdcc_iy -pragma-include:$(PRAGMA_FILE)
ASFLAGS=$(TARGET) $(VERBOSITY) -c
CPP_FLAGS=$(TARGET) $(VERBOSITY) -c -compiler sdcc -clib=sdcc_iy -pragma-include:$(PRAGMA_FILE) -E
SYMBOLS_GENERATOR=./generate_symbols.pl
MAP=tv.map
TAGGABLE_SRC_GENERATOR=./generate_taggable_src.pl
TAGGABLE_SRC=tv.taggable_src
TAGS_GENERATOR=etags
TAGS=TAGS
MEM_FREE=./how_much_memory_left.sh
EXEC=tv.tap
EXEC_OUTPUT=tv
SYM_OUTPUT=tv.sym
OBJECTS = main.o \
player.o \
controls.o \
int.o \
level.o \
levels.o \
levels_01234567.o \
levels_89.o \
levels_1011.o \
levels_1213.o \
levels_1415.o \
levels_1617.o \
levels_1819.o \
levels_primitives.o \
swarm.o \
virion.o \
print_str.o \
timer.o \
sound.o \
snow_table.o \
snow_demo_plot.o \
tv.o \
font.o
# Objects built from C files (as opposed to ASMs)
C_OBJECTS = main.o \
player.o \
controls.o \
int.o \
level.o \
levels.o \
levels_01234567.o \
levels_89.o \
levels_1011.o \
levels_1213.o \
levels_1415.o \
levels_1617.o \
levels_1819.o \
levels_primitives.o \
swarm.o \
virion.o \
print_str.o \
timer.o \
sound.o
LEVEL01234567_INCS = $(wildcard level[01234567].inc)
LEVEL_INCS = $(wildcard level1*.inc)
# A .cpre is the output of the C preprocessor
PREPROCESSED = $(C_OBJECTS:.o=.cpre)
# For now, if any header changes, recompile the lot.
HEADERS = main.h \
player.h \
level.h \
levels.h \
levels_01234567.h \
levels_89.h \
levels_1011.h \
levels_1213.h \
levels_1415.h \
levels_1617.h \
levels_1819.h \
levels_primitives.h \
controls.h \
int.h \
swarm.h \
virion.h \
print_str.h \
timer.h \
snow.h \
sound.h
# Not used:
# rtunes.h
# Run the preprocessor on *.c files to get *.cpre files
%.cpre: %.c $(PRAGMA_FILE) $(HEADERS)
$(CC) $(CPP_FLAGS) -o $@ $<
%.o: %.c $(PRAGMA_FILE) $(HEADERS) sections.asm
$(CC) $(CFLAGS) sections.asm -o $@ $<
%.o: %.asm
$(AS) $(ASFLAGS) -o $@ $<
all : clean_tmp $(EXEC) $(SYM_OUTPUT) $(TAGGABLE_SRC) $(TAGS) report
# Special rules for the levels files to make sure it picks up changes to the include
# files generated by the level creator
#
levels_01234567.o : levels_01234567.c $(PRAGMA_FILE) $(HEADERS) $(LEVEL01234567_INCS)
$(CC) $(CFLAGS) -o $@ $<
# Might need to do better here. There are several level*.c files with dependences on
# level*.inc files.
levels.o : levels.c $(PRAGMA_FILE) $(HEADERS) $(LEVEL_INCS)
$(CC) $(CFLAGS) -o $@ $<
# Rule to build the executable.
$(EXEC) : $(OBJECTS)
$(CC) $(LDFLAGS) -startup=$(CRT) $(OBJECTS) -o $(EXEC_OUTPUT)
$(APPMAKE) +glue -b tv --filler 0xDF --clean
$(APPMAKE) +zx -b tv__.bin --org 32768 --blockname tv -o $(EXEC)
# Build the symbols table after the executable
$(SYM_OUTPUT): $(EXEC)
$(SYMBOLS_GENERATOR) < $(MAP) > $(SYM_OUTPUT)
# Tagged source needs symbol table
$(TAGGABLE_SRC): $(SYM_OUTPUT)
$(TAGGABLE_SRC_GENERATOR) $(SYM_OUTPUT) *.c.lis > $(TAGGABLE_SRC)
# TAGS file generated each time the binary is rebuilt for any reason
$(TAGS): $(EXEC)
$(TAGS_GENERATOR) *.h *.c
# After everything, report the exec size
.PHONY: report
report: $(SYM_OUTPUT) $(TAGGABLE_SRC) $(TAGS)
$(MEM_FREE)
.PHONY: clean_tmp
clean_tmp:
rm -f /tmp/tmpXX*
.PHONY: clean
clean :
rm -f *.tap *.cpre *.bin *.map *.sym *.o *.lis tv*.inc TAGS *~ $(TAGGABLE_SRC)