From bf14f1b157333c53cc0578f20627529e5fd3e539 Mon Sep 17 00:00:00 2001 From: Freeyorp Date: Wed, 5 Jun 2024 21:19:19 +0000 Subject: real.make: Fix out-of-tree builds I appreciate and respect how densely packed Makefile code can be. hahahaahahahaaa --- Makefile.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index 79fe4ce..d4334eb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -347,8 +347,10 @@ thisdir := $(abspath .) # - sorted # - relative and simplified: it's stripped of any absolute path relative to # the current directory after being converted to an absolute path. +# This also converts paths from being relative to the build directory to +# being relative to the source directory, if they differ. # This simplifies any construct such as: -# src/mmo/../strings/zstring.tcc +# ../src/mmo/../strings/zstring.tcc # to: # src/strings/zstring.tcc # - only files which either exist (the purpose of the wildcard function), @@ -370,9 +372,13 @@ $(foreach root,${PATTERN_ROOTS},$(eval \ # Secondly, make sure that the files actually exist, or are files we expect to # generate ourselves. Sort the result for readability. +# Note that we re-add and remove the ${SRC_DIR} prefix when testing for +# existence, as we need to test for existence relative to our build directory. $(foreach root,${PATTERN_ROOTS},$(eval \ ${root} := $(sort \ - $(wildcard $(value ${root})) \ + $(patsubst ${SRC_DIR}/%,%,$(wildcard $(addprefix ${SRC_DIR}/, \ + $(value ${root}) \ + ))) \ $(filter conf-raw/%.h,$(value ${root})) \ $(filter ${GENERATED_FILES},$(value ${root})) \ ) \ -- cgit v1.2.3-70-g09d2