From 4c58208755e09482d62037af3b3c2f5863225fba Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 25 Oct 2021 18:09:51 +0200 Subject: [PATCH] buildsys: restrict vpath to src directory The `vpath` directives are what makes out-of-tree builds possible. With them, if a source file is not present in `${builddir}`, then GNU make automatically looks for it in `${srcdir}`. For files in `src`, this is generally what we want. But for generated files in `build`, we do *not* want that. As a result, it could happen that instead of `${builddir}/build/gap_version.c` we would access `${srcdir}/build/gap_version.c`, and so on. This patch fixes this by restricting the `vpath` directives to files inside `src` subdirectory. --- GNUmakefile.in | 13 +++++++++---- dev/ci.sh | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/GNUmakefile.in b/GNUmakefile.in index 7afcbebb58..1f048241fe 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -188,10 +188,15 @@ sysconfdir = @sysconfdir@ # out-of-tree builds without accidentally picking up e.g. *.o files from the # wrong tree. Wee still have to be careful about build/config.h, though. # -vpath %.h $(srcdir) -vpath %.c $(srcdir) -vpath %.cc $(srcdir) -vpath %.s $(srcdir) +vpath src/%.h $(srcdir) +vpath src/%.c $(srcdir) +vpath src/%.cc $(srcdir) +vpath src/%.s $(srcdir) + +vpath src/hpc/%.h $(srcdir) +vpath src/hpc/%.c $(srcdir) +vpath src/hpc/%.cc $(srcdir) +vpath src/hpc/%.s $(srcdir) # diff --git a/dev/ci.sh b/dev/ci.sh index 08cd1322a1..58bb8c7f9f 100755 --- a/dev/ci.sh +++ b/dev/ci.sh @@ -115,6 +115,7 @@ GAPInput mkdir -p $SRCDIR/build/obj/src echo "garbage content 1" > $SRCDIR/${bool_d} echo "garbage content 2" > $SRCDIR/${bool_lo} + echo "garbage content 3" > $SRCDIR/build/gap_version.c # test: `make clean` works and afterwards we can still `make`; in particular # build/config.h must be regenerated before any actual compilation