fix make O=dir build
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 8 Jul 2010 23:25:36 +0000 (01:25 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 8 Jul 2010 23:25:36 +0000 (01:25 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
scripts/Makefile.build
scripts/gen_build_files.sh
scripts/test_make_O [new file with mode: 0755]

index f343818b1144c64adfaaba673cdb2e88807818d5..5685b5bcc5cc3ae1f0f78900770b8b1904b55757 100644 (file)
@@ -13,8 +13,13 @@ __build:
 include scripts/Kbuild.include
 
 # The filename Kbuild has precedence over Makefile
+# bbox: we also try to include Kbuild file in obj tree first
 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
-include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
+include $(if $(wildcard $(src)/Kbuild), $(src)/Kbuild, \
+               $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, \
+                       $(kbuild-dir)/Makefile \
+               ) \
+       )
 
 include scripts/Makefile.lib
 
index a98f509ce334b459b02a4b64129c48662bac972a..9681587583d00b0bbe43d4ba92f32430c04d7156 100755 (executable)
@@ -4,6 +4,8 @@ test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
 
 # cd to objtree
 cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
+# In separate objtree build, include/ might not exist yet
+mkdir include 2>/dev/null
 
 srctree="$1"
 
@@ -46,10 +48,12 @@ if test x"$new" != x"$old"; then
 fi
 
 # (Re)generate */Kbuild and */Config.in
-find -type d | while read -r d; do
+{ cd -- "$srctree" && find -type d; } | while read -r d; do
        d="${d#./}"
+
        src="$srctree/$d/Kbuild.src"
        dst="$d/Kbuild"
+       mkdir -p -- "$d" 2>/dev/null
        if test -f "$src"; then
                #echo "  CHK     $dst"
 
@@ -69,6 +73,7 @@ find -type d | while read -r d; do
 
        src="$srctree/$d/Config.src"
        dst="$d/Config.in"
+       mkdir -p -- "$d" 2>/dev/null
        if test -f "$src"; then
                #echo "  CHK     $dst"
 
diff --git a/scripts/test_make_O b/scripts/test_make_O
new file mode 100755 (executable)
index 0000000..a0ee6a8
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+b=`basename $PWD`
+test "${b#busybox}" != "$b" || { echo "Must be run in busybox tree"; exit 1; }
+
+rm -rf ../testdir_make_O.$$
+mkdir ../testdir_make_O.$$
+odir=`cd ../testdir_make_O.$$ && pwd`
+test -d "$odir" || exit 1
+
+make O="$odir" $MAKEOPTS "$@" defconfig busybox 2>&1 | tee test_make_O.log