summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorU-Daniel-PC\Daniel <corrnondacqb@yahoo.com>2015-02-12 11:26:02 -0500
committerU-Daniel-PC\Daniel <corrnondacqb@yahoo.com>2015-02-12 11:26:02 -0500
commit6f71f21219694949bc0c4ce381d56ed32c62e330 (patch)
treef94bc78382d62afda522d063ac8b9de038710de3
parentb97ef936bbf571754e5e1d902754436a0692a5e7 (diff)
Optimize Makefile
-rwxr-xr-xMakefile39
1 files changed, 23 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index dd8488e..779a130 100755
--- a/Makefile
+++ b/Makefile
@@ -1,37 +1,44 @@
+.PHONY: all compare clean
+
+.SUFFIXES:
+.SUFFIXES: .asm .o .gbc
+.SECONDEXPANSION:
+
# Build Pokemon Pinball.
-outputrom := pokepinball.gbc
+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: 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
+all: $(ROMS) compare
# 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
+$(OBJS): $$*.asm bin $$($$*_dep)
+ rgbasm -h -o $@ $<
-# Assemble working RAM into objects.
-# Use rgbasm -h to use halts without nops.
-wram.o: wram.asm
- rgbasm -h -o wram.o wram.asm
+$(ROMS): $(OBJS)
+ rgblink -n $(ROMS:.gbc=.sym) -o $@ $^
+ rgbfix -jsvc -k 01 -l 0x33 -m 0x1e -p 0 -r 02 -t "POKEPINBALL" -i VPHE $@
# Create .bin dumps from baserom.gbc by scanning main.asm for INCBIN.
bin:
- $(PYTHON) util/generate_bin_dumps.py main.asm
+ @$(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
+compare: $(ROMS) baserom.gbc
+ cmp $^
# Remove files generated by the build process.
clean:
- rm -f $(outputrom) *.o poke*.sym *.sav
+ rm -f $(ROMS) $(OBJS) $(ROMS:.gbc=.sym)
rm -rf bin
- find . \( -iname '*.1bpp' -o -iname '*.pic' \) -exec rm {} +