-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
271 lines (229 loc) · 7.03 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
ifdef USE_LOCAL_CC65
# use locally installed binary (requires cc65 to be in the $PATH)
CC65= cc65
CA65= ca65
CL65= cl65
else
# use the binary built from the submodule
CC65= cc65/bin/cc65
CA65= ca65
CL65= cc65/bin/cl65
endif
MEGA65LIBCDIR= ../mega65-libc/cc65
MEGA65LIBCLIB= $(MEGA65LIBCDIR)/libmega65.a
MEGA65LIBCINC= -I$(MEGA65LIBCDIR)/include
#COPTS= -t c64 -O -Or -Oi -Os --cpu 65c02 -Icc65/include
COPTS= -t c64 -Os --cpu 65c02 -Icc65/include
LOPTS= --asm-include-dir cc65/asminc --cfg-path cc65/cfg --lib-path cc65/lib
FILES= FREEZER.M65 \
AUDIOMIX.M65 \
MONITOR.M65 \
MAKEDISK.M65 \
SPRITED.M65 \
ROMLOAD.M65 \
MEGAINFO.M65 \
C65THUMB.M65 \
C64THUMB.M65 \
M65THUMB.M65 \
GUSTHUMB.M65
M65IDESOURCES= freezer.c \
freeze_audiomix.c \
frozen_memory.c \
freeze_monitor.c \
freeze_diskchooser.c \
fdisk_memory.c \
fdisk_screen.c \
fdisk_fat32.c \
fdisk_hal_mega65.c
ASSFILES= freezer.s \
frozen_memory.s \
freeze_diskchooser.s \
fdisk_memory.s \
fdisk_screen.s \
fdisk_fat32.s \
fdisk_hal_mega65.s \
charset.s \
helper.s \
freezer_common.s
MONASSFILES= monitor.s \
freeze_monitor.s \
frozen_memory.s \
fdisk_memory.s \
fdisk_screen.s \
fdisk_hal_mega65.s \
charset.s \
helper.s \
freezer_common.s
AMASSFILES= audiomix.s \
freeze_audiomix.s \
frozen_memory.s \
fdisk_memory.s \
fdisk_screen.s \
fdisk_hal_mega65.s \
charset.s \
helper.s \
freezer_common.s
MDASSFILES= makedisk.s \
freezer_common.s \
fdisk_fat32.s \
frozen_memory.s \
fdisk_memory.s \
fdisk_screen.s \
fdisk_hal_mega65.s \
charset.s \
helper.s
SEASSFILES= sprited.s \
freezer_common.s \
freeze_sprited.s \
frozen_memory.s \
fdisk_memory.s \
fdisk_screen.s \
fdisk_hal_mega65.s \
charset.s \
helper.s
RLASSFILES= romload.s \
freeze_romload.s \
frozen_memory.s \
fdisk_memory.s \
fdisk_screen.s \
fdisk_hal_mega65.s \
charset.s \
helper.s \
freezer_common.s
MIASSFILES= megainfo.s \
freeze_megainfo.s \
frozen_memory.s \
fdisk_memory.s \
fdisk_screen.s \
fdisk_hal_mega65.s \
charset.s \
helper.s \
infohelper.s \
freezer_common.s
HEADERS= Makefile \
freezer.h \
fdisk_memory.h \
fdisk_screen.h \
fdisk_fat32.h \
fdisk_hal.h \
ascii.h
DATAFILES= ascii8x8.bin
.PHONY: all
all: $(FILES)
# prerequisite: mega65-libc checked out on same level as this repo
$(MEGA65LIBCLIB):
make -C $(MEGA65LIBCDIR) all
make -C $(MEGA65LIBCDIR) clean
%.s: %.c $(HEADERS) $(DATAFILES) $(CC65)
$(info ======== Making: $@)
$(CC65) $(MEGA65LIBCINC) $(COPTS) --add-source -o $@ $<
MAKE_VERSION= \
@if [ -z "$(DO_MKVER)" ] || [ "$(DO_MKVER)" -eq "1" ] ; then \
echo "Retrieving Git version string... (set env-var DO_MKVER=0 to turn this behaviour off)" ; \
echo '.segment "CODE"' > version.s ; \
echo '_version:' >> version.s ; \
echo " .asciiz \"v:`./gitversion.sh`\"" >> version.s ; \
fi
# $9000 (screen) - $07ff
MAX_SIZE=34817
CHECKSIZE=\
@SIZE=$$(stat -L -c %s $@); \
if [ $${SIZE} -gt $(MAX_SIZE) ]; then \
echo "!!!!!!!! $@ is greater than $(MAX_SIZE)"; \
exit 1; \
else \
echo "======== $@ size is ok ($$(($(MAX_SIZE)-SIZE)) remaining)"; \
exit 0; \
fi
$(CC65):
$(info ======== Making: $@)
ifdef USE_LOCAL_CC65
@echo "Using local installed CC65."
else
git submodule init
git submodule update
( cd cc65 && make -j 8 )
endif
ascii8x8.bin: ascii00-7f.png tools/pngprepare
$(info ======== Making: $@)
./tools/pngprepare charrom ascii00-7f.png ascii8x8.bin
tools/asciih: tools/asciih.c
$(info ======== Making: $@)
$(CC) -o tools/asciih tools/asciih.c
ascii.h: tools/asciih
$(info ======== Making: $@)
./tools/asciih
tools/pngprepare: tools/pngprepare.c
$(info ======== Making: $@)
$(CC) -I/usr/local/include -L/usr/local/lib -o tools/pngprepare tools/pngprepare.c -lpng
tools/thumbnail-surround-formatter: tools/thumbnail-surround-formatter.c
$(info ======== Making: $@)
gcc -g -Wall -o tools/thumbnail-surround-formatter tools/thumbnail-surround-formatter.c -lpng
FREEZER.M65: $(ASSFILES) $(DATAFILES) $(CC65) *.h
$(info ======== Making: $@)
$(MAKE_VERSION)
$(CL65) $(COPTS) -g -Ln freezer.lbl $(LOPTS) -vm --add-source -l freezer.list -m freezer.map -o FREEZER.M65 version.s $(ASSFILES)
$(CHECKSIZE)
AUDIOMIX.M65: $(AMASSFILES) $(DATAFILES) $(CC65) *.h
$(info ======== Making: $@)
$(MAKE_VERSION)
$(CL65) $(COPTS) $(LOPTS) -vm --add-source -l audiomix.list -m audiomix.map -o AUDIOMIX.M65 version.s $(AMASSFILES)
$(CHECKSIZE)
MONITOR.M65: $(MONASSFILES) $(DATAFILES) $(CC65) *.h
$(info ======== Making: $@)
$(MAKE_VERSION)
$(CL65) $(COPTS) $(LOPTS) -vm --add-source -l monitor.list -m monitor.map -o MONITOR.M65 version.s $(MONASSFILES)
$(CHECKSIZE)
MAKEDISK.M65: $(MDASSFILES) $(DATAFILES) $(CC65) *.h
$(info ======== Making: $@)
$(MAKE_VERSION)
$(CL65) $(COPTS) $(LOPTS) -vm --add-source -l makedisk.list -m makedisk.map -o MAKEDISK.M65 version.s $(MDASSFILES)
$(CHECKSIZE)
SPRITED.M65: $(SEASSFILES) $(DATAFILES) $(CC65) *.h $(MEGA65LIBCLIB)
$(info ======== Making: $@)
$(MAKE_VERSION)
$(CL65) $(COPTS) $(LOPTS) -vm --add-source -l sprited.list -m sprited.map -o SPRITED.M65 version.s $(SEASSFILES) $(MEGA65LIBCLIB)
$(CHECKSIZE)
ROMLOAD.M65: $(RLASSFILES) $(DATAFILES) $(CC65) *.h
$(info ======== Making: $@)
$(MAKE_VERSION)
$(CL65) $(COPTS) $(LOPTS) -vm --add-source -l romload.list -m romload.map -o ROMLOAD.M65 version.s $(RLASSFILES)
$(CHECKSIZE)
MEGAINFO.M65: $(MIASSFILES) $(DATAFILES) $(CC65) *.h
$(info ======== Making: $@)
$(MAKE_VERSION)
$(CL65) $(COPTS) $(LOPTS) -vm --add-source -l megainfo.list -m megainfo.map -o MEGAINFO.M65 version.s $(MIASSFILES)
$(CHECKSIZE)
M65THUMB.M65: assets/thumbnail-surround-m65.png tools/thumbnail-surround-formatter
$(warning ======== Making: $@)
tools/thumbnail-surround-formatter assets/thumbnail-surround-m65.png 5 1 M65THUMB.M65 2>/dev/null
C65THUMB.M65: assets/thumbnail-surround-c65.png tools/thumbnail-surround-formatter
$(info ======== Making: $@)
tools/thumbnail-surround-formatter assets/thumbnail-surround-c65.png 5 1 C65THUMB.M65 2>/dev/null
C64THUMB.M65: assets/thumbnail-surround-c64.png tools/thumbnail-surround-formatter
$(info ======== Making: $@)
tools/thumbnail-surround-formatter assets/thumbnail-surround-c64.png 5 1 C64THUMB.M65 2>/dev/null
GUSTHUMB.M65: assets/thumbnail-surround-gus.png tools/thumbnail-surround-formatter
$(info ======== Making: $@)
tools/thumbnail-surround-formatter assets/thumbnail-surround-gus.png 8 3 GUSTHUMB.M65 2>/dev/null
format:
@submodules=""; for sm in `git submodule | awk '{ print "./" $$2 }'`; do \
submodules="$$submodules -o -path $$sm"; \
done; \
find . -type d \( $${submodules:3} \) -prune -false -o \( -iname '*.h' -o -iname '*.c' -o -iname '*.cpp' \) -print | xargs clang-format --style=file -i --verbose
.PHONY: clean cleangen version.s
clean: cleangen
rm -f $(FILES) \
*.o *.map *.list *.lbl \
freezer.s \
freeze_*.s \
frozen_*.s \
fdisk_*.s \
megainfo.s \
version.s \
audiomix.s makedisk.s monitor.s romload.s sprited.s \
tools/asciih \
tools/pngprepare \
tools/thumbnail-surround-formatter
cleangen:
rm -f ascii8x8.bin ascii.h