summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreeyorp <TheFreeYorp+git@gmail.com>2024-06-05 15:50:36 +0000
committerFreeyorp <TheFreeYorp+git@gmail.com>2024-06-05 19:09:16 +0000
commit00ffb562340f3f8f75efa48a138f2f1c8cf49202 (patch)
treeda0264e23f7c8a24e08070168301250abb602b0b
parent1c8a041d5c337306373453b4b2b8a0c3e9e30b46 (diff)
downloadtmwa-00ffb562340f3f8f75efa48a138f2f1c8cf49202.tar.gz
tmwa-00ffb562340f3f8f75efa48a138f2f1c8cf49202.tar.bz2
tmwa-00ffb562340f3f8f75efa48a138f2f1c8cf49202.tar.xz
tmwa-00ffb562340f3f8f75efa48a138f2f1c8cf49202.zip
Fix up .d generation for generated files
-rw-r--r--Makefile.in8
1 files changed, 8 insertions, 0 deletions
diff --git a/Makefile.in b/Makefile.in
index 587382e..e548065 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -438,6 +438,14 @@ obj/%.d: src/%.cpp | stamp/generated.stamp
${CXX} ${CPPFLAGS} -DGENERATING_DEPENDENCIES ${CXXFLAGS} -MG -MM \
-MT '$(patsubst obj/%.d,%,$@) := ' \
-MF $@ $<
+# -MG takes the include parameter as-is without prepending the path whenever
+# it's not found, and presumed to be a not-yet generated file.
+# This is troublesome, since real.make tends not to be in the same directory.
+# We work around this by checking to see if a file doesn't exist, and if it
+# doesn't, we prepend the path.
+ for f in $$(sed -e '1s@$(patsubst obj/%.d,%,$@) := \(.*\)@\1@' $@ | tr ' ' \\n | grep -vFx -e : -e \\); do \
+ test -f "$${f}" || sed -i "s|\($${f}\)|src/$(dir $*)\1|" $@; \
+ done
endif
# the above SRC_DIR replacement is not really safe, but it works okayish.
obj/%.ii: src/%.cpp