[PATCH 05/12] 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 3bececc..8d1927e 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
@@ -65,8 +70,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
 	cat "$TMP.log"
@@ -95,8 +99,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
 	cat "$TMP.log"
@@ -125,8 +128,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
 	cat "$TMP.log"
@@ -153,8 +155,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
 	cat "$TMP.log"
@@ -181,8 +182,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
 	cat "$TMP.log"
-- 
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.