forked from pret/pokered
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
executable file
·82 lines (59 loc) · 1.97 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
# python 2.7
PYTHON := python
# md5sum -c is used to compare rom hashes. The options may vary across platforms.
MD5 := md5sum -c --quiet
# Clear the default suffixes.
.SUFFIXES:
.SUFFIXES: .asm .o .gbc .png .2bpp .1bpp .pic
# Secondary expansion is required for dependency variables in object rules.
.SECONDEXPANSION:
# Suppress annoying intermediate file deletion messages.
.PRECIOUS: %.2bpp
.PHONY: all clean red green blue compare
poketools := extras/pokemontools
gfx := $(PYTHON) $(poketools)/gfx.py
2bpp := $(gfx) 2bpp
1bpp := $(gfx) 1bpp
pic := $(PYTHON) $(poketools)/pic.py compress
includes := $(PYTHON) $(poketools)/scan_includes.py
versions := red green blue
# Collect file dependencies for objects in red/ and blue/.
$(foreach ver, $(versions), \
$(eval $(ver)_asm := $(shell find $(ver) -iname '*.asm')) \
$(eval $(ver)_obj := $($(ver)_asm:.asm=.o)) \
$(eval all_obj += $($(ver)_obj)) \
)
$(foreach obj, $(all_obj), \
$(eval $(obj:.o=)_dep := $(shell $(includes) $(obj:.o=.asm))) \
)
roms := pokered.gbc pokegreen.gbc pokeblue.gbc
all: $(roms)
red: pokered.gbc
green: pokegreen.gbc
blue: pokeblue.gbc
# For contributors to make sure a change didn't affect the contents of the rom.
compare: red green blue
@$(MD5) roms.md5
clean:
rm -f $(roms) $(all_obj) $(roms:.gbc=.sym)
find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} +
# Don't fix halts.
asm_opt = -h
# Make a symfile for debugging.
link_opt = -n poke$*.sym
# Header options for rgbfix.
dmg_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03
red_opt = $(dmg_opt) -t "POKEMON RED"
green_opt = $(dmg_opt) -t "POKEMON GREEN"
blue_opt = $(dmg_opt) -t "POKEMON BLUE"
%.png: ;
%.2bpp: %.png ; @$(2bpp) $<
%.1bpp: %.png ; @$(1bpp) $<
%.pic: %.2bpp ; @$(pic) $<
# Assemble source files into objects.
$(all_obj): $$*.asm $$($$*_dep)
rgbasm $(asm_opt) -o $@ $*.asm
# Link objects to produce a rom.
poke%.gbc: $$(%_obj)
rgblink $(link_opt) -o $@ $^
rgbfix $($*_opt) $@