[U-Boot] [PATCH 4/5] kbuild: Use relative path when possible
Masahiro Yamada
yamada.m at jp.panasonic.com
Mon Jun 16 11:56:39 CEST 2014
Import 3 useful commits by Michal Marek <mmarek at suse.cz>
from Linux 3.16-rc1.
commit 9da0763bdd82572be243fcf5161734f11568960f
kbuild: Use relative path when building in a subdir of the source tree
commit 890676c65d699db3ad82e7dddd0cf8fb449031af
kbuild: Use relative path when building in the source tree
commit 7e1c04779efd51154baf652e653ceb24ce68939b
kbuild: Use relative path for $(objtree)
mkconfig and tools/Makefile must be adjusted to use relative path
for srctree.
Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
---
Makefile | 14 ++++++++++++--
mkconfig | 4 ++--
tools/Makefile | 2 +-
3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 2116e9a..21c8bd9 100644
--- a/Makefile
+++ b/Makefile
@@ -153,8 +153,18 @@ else
_all: modules
endif
-srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
-objtree := $(CURDIR)
+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
+objtree := .
src := $(srctree)
obj := $(objtree)
diff --git a/mkconfig b/mkconfig
index 2bf5897..7592d15 100755
--- a/mkconfig
+++ b/mkconfig
@@ -105,7 +105,7 @@ fi
#
if [ -n "$KBUILD_SRC" ] ; then
mkdir -p ${objtree}/include
- LNPREFIX=${srctree}/arch/${arch}/include/asm/
+ LNPREFIX=$(cd $srctree; pwd)/arch/${arch}/include/asm/
cd ${objtree}/include
mkdir -p asm
else
@@ -121,7 +121,7 @@ else
fi
if [ -z "$KBUILD_SRC" ] ; then
- cd ${srctree}/include
+ cd ../../../include
fi
#
diff --git a/tools/Makefile b/tools/Makefile
index 0088c1a..c80f54f 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -153,7 +153,7 @@ HOSTCFLAGS_sha256.o := -pedantic
#HOSTCFLAGS_mpc86x_clk.o := -pedantic
quiet_cmd_wrap = WRAP $@
-cmd_wrap = echo "\#include <$(srctree)/$(patsubst $(obj)/%,%,$@)>" >$@
+cmd_wrap = echo "\#include <../$(patsubst $(obj)/%,%,$@)>" >$@
$(obj)/lib/%.c $(obj)/common/%.c:
$(call cmd,wrap)
--
1.9.1
More information about the U-Boot
mailing list