summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rwxr-xr-xMakefile87
1 files changed, 50 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index dd8488e..5ab2704 100755
--- a/Makefile
+++ b/Makefile
@@ -1,37 +1,50 @@
-# Build Pokemon Pinball.
-outputrom := pokepinball.gbc
-
-# If your default python is 3, you may want to change this to python27.
-PYTHON := python
-
-# Link objects together to build a rom.
-all: main.o wram.o
- rgblink -n pokepinball.sym -m pokepinball.map -o $(outputrom) main.o wram.o
- rgbfix -jsvc -k 01 -l 0x33 -m 0x1e -p 0 -r 02 -t "POKEPINBALLVPHE" pokepinball.gbc
-
-# Assemble source files into objects.
-# Use rgbasm -h to use halts without nops.
-main.o: main.asm bin
- rgbasm -h -o main.o main.asm
-
-# Assemble working RAM into objects.
-# Use rgbasm -h to use halts without nops.
-wram.o: wram.asm
- rgbasm -h -o wram.o wram.asm
-
-# Create .bin dumps from baserom.gbc by scanning main.asm for INCBIN.
-bin:
- $(PYTHON) util/generate_bin_dumps.py main.asm
-
-# The compare target is a shortcut to check that the build matches the original roms exactly.
-# This is for contributors to make sure a change didn't affect the contents of the rom.
-# More thorough comparison can be made by diffing the output of hexdump -C against both roms.
-compare: $(outputrom) baserom.gbc
- md5sum $(outputrom)
- md5sum baserom.gbc
-
-# Remove files generated by the build process.
-clean:
- rm -f $(outputrom) *.o poke*.sym *.sav
- rm -rf bin
- find . \( -iname '*.1bpp' -o -iname '*.pic' \) -exec rm {} +
+.PHONY: all compare clean
+
+.SUFFIXES:
+.SUFFIXES: .asm .o .gbc .png
+.SECONDEXPANSION:
+
+# Build Pokemon Pinball.
+ROMS := pokepinball.gbc
+OBJS := main.o wram.o
+
+# If your default python is 3, you may want to change this to python27.
+PYTHON := python
+PRET := pokemon-reverse-engineering-tools/pokemontools
+
+$(foreach obj, $(OBJS), \
+ $(eval $(obj:.o=)_dep := $(shell $(PYTHON) $(PRET)/scan_includes.py $(obj:.o=.asm))) \
+)
+
+# Link objects together to build a rom.
+all: $(ROMS) compare
+
+# Assemble source files into objects.
+# Use rgbasm -h to use halts without nops.
+$(OBJS): $$*.asm $$($$*_dep)
+ @$(PYTHON) $(PRET)/gfx.py 2bpp $(2bppq)
+ @$(PYTHON) $(PRET)/gfx.py 1bpp $(1bppq)
+ rgbasm -h -o $@ $<
+
+$(ROMS): $(OBJS)
+ rgblink -n $(ROMS:.gbc=.sym) -o $@ $^
+ rgbfix -jsvc -k 01 -l 0x33 -m 0x1e -p 0 -r 02 -t "POKEPINBALL" -i VPHE $@
+
+# The compare target is a shortcut to check that the build matches the original roms exactly.
+# This is for contributors to make sure a change didn't affect the contents of the rom.
+# More thorough comparison can be made by diffing the output of hexdump -C against both roms.
+compare: $(ROMS) baserom.gbc
+ cmp $^
+
+# Remove files generated by the build process.
+clean:
+ rm -f $(ROMS) $(OBJS) $(ROMS:.gbc=.sym)
+ find . \( -iname '*.1bpp' -o -iname '*.2bpp' \) -exec rm {} +
+
+%.2bpp: %.png
+ $(eval 2bppq += $<)
+ @rm -f $@
+
+%.1bpp: %.png
+ $(eval 1bppq += $<)
+ @rm -f $@