[PATCH v2] configure.sh: support cross compilation with sysroot

Mikko Rapeli <[email protected]>
Newsgroups org.kernel.vger.trinity
Message-ID <[email protected]>
SYSROOT points to the path where libs and headers are to be searched
from.

Signed-off-by: Mikko Rapeli <[email protected]>
---
 configure.sh |   22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/configure.sh b/configure.sh
index 824abea..91916ba 100755
--- a/configure.sh
+++ b/configure.sh
@@ -15,6 +15,11 @@ MISSING_DEFS=0
 # expand tilde
 CC="$(eval echo ${CROSS_COMPILE}${CC})"
 
+CFLAGS=""
+if [ "${SYSROOT}xx" != "xx" ]; then
+	CFLAGS="$(eval echo --sysroot=${SYSROOT} )"
+fi
+
 echo "/* This file is auto-generated by configure.sh */" > config.h
 
 TMP=$(mktemp)
@@ -26,7 +31,7 @@ check_header()
 	rm -f "$TMP" || exit 1
 	echo "#include <$1>" >"$TMP.c"
 
-	${CC} "$TMP.c" -E &>"$TMP.log"
+	${CC} ${CFLAGS} "$TMP.c" -E &>"$TMP.log"
 	if [ $? -eq 0 ]; then
 		echo $GREEN "[YES]" $COL_RESET
 		echo "#define $2 1" >> config.h
@@ -64,8 +69,7 @@ void main()
 }
 EOF
 
-${CC} "$TMP.c" -o "$TMP" &>"$TMP.log"
-
+${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
 if [ ! -x "$TMP" ]; then
 	echo $RED "[NO]" $COL_RESET
 	MISSING_DEFS=1
@@ -93,8 +97,7 @@ void main()
 }
 EOF
 
-${CC} "$TMP.c" -o "$TMP" &>"$TMP.log"
-
+${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
 if [ ! -x "$TMP" ]; then
 	echo $RED "[NO]" $COL_RESET
 	MISSING_DEFS=1
@@ -122,8 +125,7 @@ void main()
 }
 EOF
 
-${CC} "$TMP.c" -o "$TMP" &>"$TMP.log"
-
+${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
 if [ ! -x "$TMP" ]; then
 	echo $RED "[NO]" $COL_RESET
 	MISSING_DEFS=1
@@ -149,8 +151,7 @@ void main()
 }
 EOF
 
-${CC} "$TMP.c" -o "$TMP" &>"$TMP.log"
-
+${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
 if [ ! -x "$TMP" ]; then
 	echo $RED "[NO]" $COL_RESET
 	MISSING_DEFS=1
@@ -176,8 +177,7 @@ int main()
 }
 EOF
 
-${CC} "$TMP.c" -o "$TMP" &>"$TMP.log"
-
+${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
 if [ ! -x "$TMP" ]; then
 	echo $RED "[NO]" $COL_RESET
 	MISSING_DEFS=1
-- 
1.7.9.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.