diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 67 |
1 files changed, 50 insertions, 17 deletions
@@ -1,32 +1,65 @@ +PYTHON := python .SUFFIXES: .asm .tx .o .gbc +.PHONY: all clean red blue +.SECONDEXPANSION: -TEXTFILES := $(shell find ./ -type f -name '*.asm') -all: pokered.gbc +TEXTQUEUE := -pokered.o: pokered.tx main.tx constants.tx wram.tx ${TEXTFILES:.asm=.tx} - rgbasm -o pokered.o pokered.tx - -pokeblue.o: pokeblue.tx main.tx constants.tx wram.tx ${TEXTFILES:.asm=.tx} - rgbasm -o pokeblue.o pokeblue.tx +RED_OBJS := pokered.o +BLUE_OBJS := pokeblue.o + +OBJS := $(RED_OBJS) $(BLUE_OBJS) + +ROMS := pokered.gbc pokeblue.gbc + +# generate dependencies for each object +$(shell $(foreach obj, $(OBJS), \ + $(eval $(obj:.o=)_DEPENDENCIES := $(shell $(PYTHON) extras/pokemontools/scan_includes.py $(obj:.o=.asm) | sed s/globals.asm//g)) \ +)) +$(shell $(foreach obj, $(OBJS), \ + $(eval ALL_DEPENDENCIES += $($(obj:.o=)_DEPENDENCIES)) \ +)) + +all: $(ROMS) +red: pokered.gbc +blue: pokeblue.gbc redrle: extras/redtools/redrle.c ${CC} -o $@ $> +clean: + rm -f $(ROMS) + rm -f $(OBJS) + rm -f globals.asm + @echo "removing *.tx" && rm -f $(shell find . -iname '*.tx' -printf '"%p" ') + rm -f redrle + + +baserom.gbc: ; + @echo "Wait! Need baserom.gbc first. Check README and INSTALL for details." && false + +%.asm: ; .asm.tx: - python textpre.py < $< > $@ + $(eval TEXTQUEUE := $(TEXTQUEUE) $<) + @rm -f $@ + +globals.asm: $(ALL_DEPENDENCIES:.asm=.tx) $(OBJS:.o=.tx) + @touch $@ + @$(PYTHON) prequeue.py $(TEXTQUEUE) +globals.tx: globals.asm + @cp $< $@ + +$(OBJS): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_DEPENDENCIES)) + rgbasm -o $@ $*.tx -pokered.gbc: pokered.o - rgblink -o $@ $*.o +pokered.gbc: globals.tx $(RED_OBJS) + rgblink -n $*.sym -m $*.map -o $@ $(RED_OBJS) rgbfix -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON RED" $@ cmp baserom.gbc $@ - -pokeblue.gbc: pokeblue.o - rgblink -o $@ $*.o + +pokeblue.gbc: globals.tx $(BLUE_OBJS) + rgblink -n $*.sym -m $*.map -o $@ $(BLUE_OBJS) rgbfix -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON BLUE" $@ cmp blue.gbc $@ -clean: - rm -f pokered.o pokered.gbc pokeblue.o pokeblue.gbc redrle $(TEXTFILES:.asm=.tx) - -more: pokered.gbc pokeblue.gbc |