-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
131 lines (96 loc) · 2.91 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
rom := poketcg2.gbc
rom_obj := \
src/main.o \
src/home.o \
src/gfx.o \
src/text.o \
src/audio.o \
src/wram.o \
src/hram.o
### Build tools
ifeq (,$(shell which sha1sum))
SHA1 := shasum
else
SHA1 := sha1sum
endif
RGBDS ?=
RGBASM ?= $(RGBDS)rgbasm
RGBFIX ?= $(RGBDS)rgbfix
RGBGFX ?= $(RGBDS)rgbgfx
RGBLINK ?= $(RGBDS)rgblink
### Build targets
.SUFFIXES:
.SECONDEXPANSION:
.PRECIOUS:
.SECONDARY:
.PHONY: all tcg2 clean tidy compare tools
all: $(rom) compare
tcg2: $(rom) compare
clean: tidy
find src/gfx \
\( -iname '*.1bpp' \
-o -iname '*.2bpp' \
-o -iname '*.pal' \) \
-delete
tidy:
$(RM) $(rom) \
$(rom:.gbc=.sym) \
$(rom:.gbc=.map) \
$(rom_obj) \
src/rgbdscheck.o
$(MAKE) clean -C tools/
compare: $(rom)
@$(SHA1) -c rom.sha1
tools:
$(MAKE) -C tools/
RGBASMFLAGS = -I src/ -Weverything
# Create a sym/map for debug purposes if `make` run with `DEBUG=1`
ifeq ($(DEBUG),1)
RGBASMFLAGS += -E
endif
src/rgbdscheck.o: src/rgbdscheck.asm
$(RGBASM) -o $@ $<
# 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 tidy tools,$(MAKECMDGOALS)))
$(info $(shell $(MAKE) -C tools))
# The dep rules have to be explicit or else missing files won't be reported.
# As a side effect, they're evaluated immediately instead of when the rule is invoked.
# It doesn't look like $(shell) can be deferred so there might not be a better way.
define DEP
$1: $2 $$(shell tools/scan_includes -s -I src/ $2) | src/rgbdscheck.o
$$(RGBASM) $$(RGBASMFLAGS) -o $$@ $$<
endef
# Dependencies for objects
$(foreach obj, $(rom_obj), $(eval $(call DEP,$(obj),$(obj:.o=.asm))))
endif
%.asm: ;
opts = -Cv -k 2P -l 0x33 -m 0x1b -p 0xff -r 03 -t POKEMON-CG2 -i BP7J
$(rom): $(rom_obj) src/layout.link
$(RGBLINK) -p 0xff -m $(rom:.gbc=.map) -n $(rom:.gbc=.sym) -l src/layout.link -O baserom.gbc -o $@ $(filter %.o,$^)
$(RGBFIX) $(opts) $@
### Misc file-specific graphics rules
src/gfx/coins/%.2bpp: rgbgfx += -x 1
src/gfx/booster_packs/beginning_pack.2bpp: rgbgfx += -x 2
src/gfx/booster_packs/legendary_pack.2bpp: rgbgfx += -x 1
src/gfx/booster_packs/fossil_pack.2bpp: rgbgfx += -x 2
src/gfx/booster_packs/psychic_pack.2bpp: rgbgfx += -x 1
src/gfx/booster_packs/ambition_pack.2bpp: rgbgfx += -x 2
src/gfx/booster_packs/present_pack.2bpp: rgbgfx += -x 2
src/gfx/booster_packs/pack_oam.2bpp: rgbgfx += -x 1
src/gfx/titlescreen/title_screen.2bpp: rgbgfx += -x 4
src/gfx/titlescreen/gb_error.2bpp: rgbgfx += -x 10
src/gfx/black_box/black_box_bg.2bpp: rgbgfx += -x 5
src/gfx/link/card_pop_scene.2bpp: rgbgfx += -x 9
src/gfx/link/link_scene.2bpp: rgbgfx += -x 7
### Catch-all graphics rules
%.png: ;
%.pal: ;
%.2bpp: %.png
$(RGBGFX) $(rgbgfx) -o $@ $<
$(if $(tools/gfx),\
tools/gfx $(tools/gfx) -o $@ $@)
%.1bpp: %.png
$(RGBGFX) $(rgbgfx) -d1 -o $@ $<
$(if $(tools/gfx),\
tools/gfx $(tools/gfx) -d1 -o $@ $@)