This repository has been archived by the owner on Oct 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·78 lines (56 loc) · 1.65 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
roms := MONSGD.gbc
gold_obj := \
home.o \
main.o \
wram.o \
data/pokemon/evos_attacks.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:
.PHONY: all gold clean compare tools
.SECONDEXPANSION:
.PRECIOUS:
.SECONDARY:
all: $(roms)
gold: MONSGD.gbc
clean:
rm -f $(roms) $(gold_obj) $(silver_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) rgbdscheck.o
$(MAKE) clean -C tools/
compare: $(roms)
@$(SHA1) -c roms.sha1
tools:
$(MAKE) -C tools/
RGBASMFLAGS = -L -Weverything
# Create a sym/map for debug purposes if `make` run with `DEBUG=1`
ifeq ($(DEBUG),1)
RGBASMFLAGS += -E
endif
$(gold_obj): RGBASMFLAGS += -E
rgbdscheck.o: rgbdscheck.asm
$(RGBASM) -o $@ $<
# 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 $2) | rgbdscheck.o
$$(RGBASM) $$(RGBASMFLAGS) -o $$@ $$<
endef
# 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))
$(foreach obj, $(gold_obj), $(eval $(call DEP,$(obj),$(obj:.o=.asm))))
endif
MONSGD.gbc: $(gold_obj) layout.link
$(RGBLINK) -n MONSGD.sym -m MONSGD.map -l layout.link -o $@ $(gold_obj)
$(RGBFIX) -csv -i AAUJ -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t "POKEMON_GLD" $@