shithub: pokered

Download patch

ref: 6bb3d82e7a11d2fbdada3e5a57e51d9ec7fff142
parent: 9d7b581310eb500910a4cf89e9f2a317eee40ec8
author: mid-kid <esteve.varela@gmail.com>
date: Tue Oct 25 14:02:29 EDT 2022

Fix preinclude dependencies

From pokecrystal:
- 0425018d1ce5b3b726e3cd83f59f14ead9171c92
- 8b429e2a545e87407a3b8c7b92f7ceafc455e390

--- a/Makefile
+++ b/Makefile
@@ -103,20 +103,21 @@
 rgbdscheck.o: rgbdscheck.asm
 	$(RGBASM) -o $@ $<
 
+# 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) | includes.asm rgbdscheck.o
+$1: $2 $$(shell tools/scan_includes $2) $(preinclude_deps) | 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))
-
 # 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, $(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