-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
114 lines (80 loc) · 2.69 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
roms := red-speedchoice.gbc
red-speedchoice_obj := audio_red.o main_red.o pics_red.o text_red.o wram_red.o
### Build tools
MD5 := md5sum -c
PYTHON3 := python3
RGBDS ?=
RGBASM ?= $(RGBDS)rgbasm
RGBFIX ?= $(RGBDS)rgbfix
RGBGFX ?= $(RGBDS)rgbgfx
RGBLINK ?= $(RGBDS)rgblink
### Build targets
.SUFFIXES:
.SECONDEXPANSION:
.PRECIOUS:
.SECONDARY:
.PHONY: all red clean tidy compare tools config
all: $(roms) config
red: red-speedchoice.gbc
config: red-speedchoice.ini
# For contributors to make sure a change didn't affect the contents of the rom.
compare: $(roms)
@$(MD5) roms.md5
clean:
rm -f $(roms) $(red-speedchoice_obj) $(roms:.gbc=.sym)
find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' -o -iname '*.lz' \) -exec rm {} +
$(MAKE) clean -C tools/
tidy:
rm -f $(roms) $(red-speedchoice_obj) $(roms:.gbc=.sym)
$(MAKE) clean -C tools/
tools:
$(MAKE) -C tools/
# Build tools when building the rom.
# This has to happen before the rules are processed, since that's when scan_includes is run.
ifeq (,$(filter clean tools,$(MAKECMDGOALS)))
$(info $(shell $(MAKE) -C tools))
endif
# Echo current git revision into an include for the permaoptions screen to pick up
$(shell echo "db \"-"$(shell git log -1 --format="%h")"\"" > git-revision.asm)
%.asm: ;
%_red.o: dep = $(shell tools/scan_includes $(@D)/$*.asm)
$(red-speedchoice_obj): %_red.o: %.asm $$(dep)
$(RGBASM) -D _RED -h -o $@ $*.asm
red-speedchoice_opt = -cjsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "RED_SPDC" -i KAPC
%.gbc: $$(%_obj)
$(RGBLINK) -n $*.sym -l red-speedchoice.link -m red-speedchoice.map -o $@ $^
$(RGBFIX) $($*_opt) $@
sort $*.sym -o $*.sym
### LZ compression rules
%.lz: %
tools/lzcomp $(LZFLAGS) -- $< $@
### Misc file-specific graphics rules
gfx/blue/intro_purin_1.2bpp: RGBGFX += -h
gfx/blue/intro_purin_2.2bpp: RGBGFX += -h
gfx/blue/intro_purin_3.2bpp: RGBGFX += -h
gfx/red/intro_nido_1.2bpp: RGBGFX += -h
gfx/red/intro_nido_2.2bpp: RGBGFX += -h
gfx/red/intro_nido_3.2bpp: RGBGFX += -h
gfx/game_boy.2bpp: tools/gfx += --remove-duplicates
gfx/theend.2bpp: tools/gfx += --interleave --png=$<
gfx/tilesets/%.2bpp: tools/gfx += --trim-whitespace
pic/bmon/%.2bpp: RGBGFX += -h
pic/monback/%.2bpp: RGBGFX += -h
pic/other/%.2bpp: RGBGFX += -h
pic/rgmon/%.2bpp: RGBGFX += -h
pic/trainer/%.2bpp: RGBGFX += -h
pic/ymon/%.2bpp: RGBGFX += -h
pic/ytrainer/%.2bpp: RGBGFX += -h
### Catch-all graphics rules
%.png: ;
%.2bpp: %.png
$(RGBGFX) $(rgbgfx) -o $@ $<
$(if $(tools/gfx),\
tools/gfx $(tools/gfx) -o $@ $@)
%.1bpp: %.png
$(RGBGFX) -d1 $(rgbgfx) -o $@ $<
$(if $(tools/gfx),\
tools/gfx $(tools/gfx) -d1 -o $@ $@)
%.ini: %.gbc %.sym
$(PYTHON3) genrandoini.py $^ $@
echo "MD5Hash="$(shell md5sum $< | cut -d' ' -f1) >> $@