On 28/01/2025 11.41, Marc Hartmayer wrote:
If VPATH is used, object files are also looked up in the source directory [1],
and this has some disadvantages like a simultaneous in-source build and
out-of-source build is not possible:
$ cd "$KUT" && ./configure && make -j
# This command fails
$ mkdir ../build && cd ../build && "../$KUT/configure" && make -j
Use 'vpath' [2] only for *.c, *.s, and *.S files and not for *.lds files, as
this is not necessary as all *.lds prerequisites already use $(SRCDIR)/*.lds.
[1] https://www.gnu.org/software/make/manual/html_node/General-Search.html
[2] https://www.gnu.org/software/make/manual/html_node/Selective-Search.html
Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
--
Note: IMO, in the long run we should try to get rid of vpath completely and use
OBJDIR/BUILDDIR and SRCDIR instead.
---
Makefile | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 7471f7285b78..78352fced9d4 100644
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,10 @@ endif
include config.mak
-# Set search path for all sources
-VPATH = $(SRCDIR)
+# Set search path for %.c %.s and %.S files
+vpath %.c $(SRCDIR)
+vpath %.s $(SRCDIR)
+vpath %.S $(SRCDIR)
Makes sense,
Reviewed-by: Thomas Huth <thuth@xxxxxxxxxx>
and pushed, thanks!