[RFC kvm-unit-tests PATCH 1/8] configure: make it run-able from outside source tree

Alex Bennée alex.bennee at linaro.org
Thu Apr 6 15:07:20 EDT 2017


This is a first step to enabling out-of-tree builds for
kvm-unit-tests. When you invoke configure like this:

  ../tree.git/configure [args]

It will detect we the case and:

  - link ../tree.git/Makefile to the build-dir
  - ensure lib is created with a correct lib/asm
  - set SRCDIR in the config.mk

Signed-off-by: Alex Bennée <alex.bennee at linaro.org>
---
 configure | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 8821f37..223809c 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+srcdir=$(cd "$(dirname "$0")"; pwd)
 prefix=/usr/local
 cc=gcc
 ld=ld
@@ -102,12 +103,12 @@ elif [ "$arch" = "ppc64" ]; then
 else
     testdir=$arch
 fi
-if [ ! -d $testdir ]; then
+if [ ! -d $srcdir/$testdir ]; then
     echo "$testdir does not exist!"
     exit 1
 fi
-if [ -f $testdir/run ]; then
-    ln -fs $testdir/run $testdir-run
+if [ -f $srcdir/$testdir/run ]; then
+    ln -fs $srcdir/$testdir/run $testdir-run
 fi
 
 # check if uint32_t needs a long format modifier
@@ -135,18 +136,27 @@ fi
 rm -f lib_test.c
 fi
 
+# Are we in a separate build tree? If so, link the Makefile
+# so that 'make' works.
+if test ! -e Makefile; then
+    echo "linking Makefile..."
+    ln -s "${srcdir}/Makefile" .
+fi
+
 # link lib/asm for the architecture
 rm -f lib/asm
 asm=asm-generic
-if [ -d lib/$arch/asm ]; then
-	asm=$arch/asm
-elif [ -d lib/$testdir/asm ]; then
-	asm=$testdir/asm
+if [ -d $srcdir/lib/$arch/asm ]; then
+	asm=$srcdir/lib/$arch/asm
+elif [ -d $srcdir/lib/$testdir/asm ]; then
+	asm=$srcdir/lib/$testdir/asm
 fi
+mkdir -p lib
 ln -s $asm lib/asm
 
 # create the config
 cat <<EOF > config.mak
+SRCDIR=$srcdir
 PREFIX=$prefix
 HOST=$host
 ARCH=$arch
-- 
2.11.0




More information about the linux-arm-kernel mailing list