summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreeyorp <TheFreeYorp+git@gmail.com>2024-06-05 21:19:19 +0000
committerFreeyorp <TheFreeYorp+git@gmail.com>2024-06-05 23:57:13 +0000
commitbf14f1b157333c53cc0578f20627529e5fd3e539 (patch)
treebfa979ebfc4b3aa92d262ea4912f1cb8410506cc
parentc33d3f8efc280a2c4e3e440d065360094151c331 (diff)
downloadtmwa-bf14f1b157333c53cc0578f20627529e5fd3e539.tar.gz
tmwa-bf14f1b157333c53cc0578f20627529e5fd3e539.tar.bz2
tmwa-bf14f1b157333c53cc0578f20627529e5fd3e539.tar.xz
tmwa-bf14f1b157333c53cc0578f20627529e5fd3e539.zip
real.make: Fix out-of-tree builds
I appreciate and respect how densely packed Makefile code can be. hahahaahahahaaa
-rw-r--r--Makefile.in10
1 files 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})) \
) \