diff options
author | entrpntr <entrpntr@gmail.com> | 2020-03-22 18:37:40 -0400 |
---|---|---|
committer | entrpntr <entrpntr@gmail.com> | 2020-03-22 18:37:40 -0400 |
commit | db8db97aa341f52174a14d415ca680656f0bcf64 (patch) | |
tree | ce6b343e20e393e929ea0d8509e69b7c04ae83dd /Makefile | |
parent | 15890237493f06d266a3197357d42edf883355e2 (diff) |
Clean up makefile, submodules, root dir; Python 3 compatibility.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 92 |
1 files changed, 62 insertions, 30 deletions
@@ -1,28 +1,43 @@ -PYTHON := python -MD5 := md5sum -c - -.SUFFIXES: -.PHONY: all clean gold silver pngs compare -.SECONDEXPANSION: -.PRECIOUS: -.SECONDARY: - -gfx := $(PYTHON) gfx.py -includes := $(PYTHON) scan_includes.py - +roms := pokegold.gbc pokesilver.gbc rom_obj := \ audio.o \ +home.o \ +main.o \ +wram.o \ data/text/common.o \ data/pokemon/dex_entries.o \ -wram.o \ -main.o \ -home.o + gold_obj := $(rom_obj:.o=_gold.o) silver_obj := $(rom_obj:.o=_silver.o) -roms := pokegold.gbc pokesilver.gbc + +### 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 + +PYTHON := python +gfx := $(PYTHON) tools/gfx.py + + +### Build targets + +.SUFFIXES: +.PHONY: all gold silver clean pngs compare tools +.SECONDEXPANSION: +.PRECIOUS: +.SECONDARY: all: $(roms) gold: pokegold.gbc @@ -30,31 +45,48 @@ silver: pokesilver.gbc clean: rm -f $(roms) $(gold_obj) $(silver_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) + find gfx/pics gfx/trainers -name "*.png" -delete + $(MAKE) clean -C tools/ + +compare: $(roms) + @$(SHA1) -c roms.sha1 -compare: pokegold.gbc pokesilver.gbc - @$(MD5) roms.md5 +tools: + $(MAKE) -C tools/ -%.asm: ; +$(gold_obj): RGBASMFLAGS = -D _GOLD +$(silver_obj): RGBASMFLAGS = -D _SILVER + +# 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: $$(shell $$(includes) $2) +$1: $2 $$(shell tools/scan_includes $2) + $$(RGBASM) $$(RGBASMFLAGS) -L -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:_gold.o=.asm)))) $(foreach obj, $(silver_obj), $(eval $(call DEP,$(obj),$(obj:_silver.o=.asm)))) -$(gold_obj): %_gold.o: %.asm $$(dep) - rgbasm -D GOLD -L -o $@ $< +endif -$(silver_obj): %_silver.o: %.asm $$(dep) - rgbasm -D SILVER -L -o $@ $< -pokegold.gbc: $(gold_obj) - rgblink -n pokegold.sym -m pokegold.map -l pokegold.link -o $@ $^ - rgbfix -cjsv -i AAUE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t "POKEMON_GLD" $@ +pokegold.gbc: $(gold_obj) pokegold.link + $(RGBLINK) -n pokegold.sym -m pokegold.map -l pokegold.link -o $@ $(gold_obj) + $(RGBFIX) -cjsv -i AAUE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t "POKEMON_GLD" $@ + tools/sort_symfile.sh pokegold.sym -pokesilver.gbc: $(silver_obj) - rgblink -n pokesilver.sym -m pokesilver.map -l pokesilver.link -o $@ $^ - rgbfix -cjsv -i AAXE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t "POKEMON_SLV" $@ +pokesilver.gbc: $(silver_obj) pokesilver.link + $(RGBLINK) -n pokesilver.sym -m pokesilver.map -l pokesilver.link -o $@ $(silver_obj) + $(RGBFIX) -cjsv -i AAXE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t "POKEMON_SLV" $@ + tools/sort_symfile.sh pokesilver.sym pngs: find . -iname "*.lz" -exec $(gfx) unlz {} + |