[PATCH] kbuild: Use symbolic link to the source tree for out-of-tree build

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since commit 9da0763bd, the variable 'srctree' is set as follows:

[1] Building in the source tree
      => srctree is set to '.'
[2] Building in a subdir right under the source tree
      => srctree is set to '..'
[3] Other cases
      => srctree is set to the absolute path to the source tree

Pros are more readable compiler messages, WARN_ON() etc.
for case [1] and [2]. (but not [3])

Cons are we have to do build-test for 3 cases when adding
some changes to the build infrastructure.

We want to treat case [2] and [3] in the same way like prior to
commit 9da0763bd, keeping the compact log messages.

The idea here is to create a symbolic link 'srctree' pointing
to $(KBUILD_SRC) at the very early stage of the build process.

We created the symbolic link 'source' in outputmakefile: target,
but it is redundant and should be removed.
(I think 'srctree' is a more suitable symbolic link name than 'source')

Signed-off-by: Masahiro Yamada <yamada.m@xxxxxxxxxxxxxxxx>
Cc: Michal Marek <mmarek@xxxxxxx>
Cc: Sam Ravnborg <sam@xxxxxxxxxxxx>
---
 Makefile | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index 4d75b4b..0089618 100644
--- a/Makefile
+++ b/Makefile
@@ -130,6 +130,7 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
 # able to understand relative filenames.
 sub-make: FORCE
 	@echo "make[1]: Entering directory \`$(KBUILD_OUTPUT)'"
+	$(if $(KBUILD_VERBOSE:1=),@)ln -fsn $(CURDIR) $(KBUILD_OUTPUT)/srctree
 	$(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
 	KBUILD_SRC=$(CURDIR) \
 	KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \
@@ -152,17 +153,7 @@ else
 _all: modules
 endif
 
-ifeq ($(KBUILD_SRC),)
-        # building in the source tree
-        srctree := .
-else
-        ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
-                # building in a subdirectory of the source tree
-                srctree := ..
-        else
-                srctree := $(KBUILD_SRC)
-        endif
-endif
+srctree		:= $(if $(KBUILD_SRC),srctree,.)
 objtree		:= .
 src		:= $(srctree)
 obj		:= $(objtree)
@@ -460,7 +451,6 @@ PHONY += outputmakefile
 # output directory.
 outputmakefile:
 ifneq ($(KBUILD_SRC),)
-	$(Q)ln -fsn $(srctree) source
 	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
 	    $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
 endif
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux