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) libdirs-get = $(shell [ -d "lib/$(1)" ] && echo "lib/$(1) lib/$(1)/asm") ARCH_LIBDIRS := $(call libdirs-get,$(ARCH_LIBDIR)) $(call libdirs-get,$(TEST_DIR)) base-commit: 0ed2cdf3c80ee803b9150898e687e77e4d6f5db2 -- 2.48.1