From 00ffb562340f3f8f75efa48a138f2f1c8cf49202 Mon Sep 17 00:00:00 2001 From: Freeyorp Date: Wed, 5 Jun 2024 15:50:36 +0000 Subject: Fix up .d generation for generated files --- Makefile.in | 8 ++++++++ 1 file changed, 8 insertions(+) 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 -- cgit v1.2.3-70-g09d2