diff --git a/Makefile b/Makefile index 39176c78d..215aa7687 100644 --- a/Makefile +++ b/Makefile @@ -103,20 +103,21 @@ $(pokeblue_vc_obj): RGBASMFLAGS += -D _BLUE -D _BLUE_VC rgbdscheck.o: rgbdscheck.asm $(RGBASM) -o $@ $< -# 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: $2 $$(shell tools/scan_includes $2) | includes.asm rgbdscheck.o - $$(RGBASM) $$(RGBASMFLAGS) -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 tidy tools,$(MAKECMDGOALS))) $(info $(shell $(MAKE) -C tools)) +# 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. +preinclude_deps := includes.asm $(shell tools/scan_includes includes.asm) +define DEP +$1: $2 $$(shell tools/scan_includes $2) $(preinclude_deps) | rgbdscheck.o + $$(RGBASM) $$(RGBASMFLAGS) -o $$@ $$< +endef + # Dependencies for objects (drop _red and _blue from asm file basenames) $(foreach obj, $(pokered_obj), $(eval $(call DEP,$(obj),$(obj:_red.o=.asm)))) $(foreach obj, $(pokeblue_obj), $(eval $(call DEP,$(obj),$(obj:_blue.o=.asm)))) @@ -125,7 +126,7 @@ $(foreach obj, $(pokered_vc_obj), $(eval $(call DEP,$(obj),$(obj:_red_vc.o=.asm) $(foreach obj, $(pokeblue_vc_obj), $(eval $(call DEP,$(obj),$(obj:_blue_vc.o=.asm)))) # Dependencies for VC files that need to run scan_includes -%.constants.sym: %.constants.asm $(shell tools/scan_includes %.constants.asm) | includes.asm rgbdscheck.o +%.constants.sym: %.constants.asm $(shell tools/scan_includes %.constants.asm) $(preinclude_deps) | rgbdscheck.o $(RGBASM) $(RGBASMFLAGS) $< > $@ endif