develooper Front page | perl.perl5.porters | Postings from November 2012

JROBINSON, grant update and a patch with sysroot support

From:
Jess Robinson
Date:
November 30, 2012 13:29
Subject:
JROBINSON, grant update and a patch with sysroot support
Message ID:
alpine.LNX.2.00.1211301253250.3709@insel
From e6b98173b10d5e51a51c086268053d2d0605f5de Mon Sep 17 00:00:00 2001
From: Jess Robinson <castaway@desert-island.me.uk>
Date: Fri, 19 Oct 2012 19:05:25 +0100
Subject: [PATCH 1/3] Introduce sysroot variable to Configure

This is borrowed from gcc and allows us to indicate the logical root
directory for headers and libraries, under which all -I and -L are
searched for. This patch adjusts Configure to search under $sysroot
(if supplied) for headers and libraries, instead of /.

$libsearchpth is also introduced to track the absolute paths of
found libraries. $libpath continues to list the relative paths to
pass to -L.
---
 Configure |   67 ++++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 51 insertions(+), 16 deletions(-)

diff --git a/Configure b/Configure
index a1bc835..9d223d0 100755
--- a/Configure
+++ b/Configure
@@ -209,6 +209,7 @@ from=''
 run=''
 targetarch=''
 to=''
+sysroot=''
 usecrosscompile=''
 extern_C=''
 mistrustnm=''
@@ -1955,6 +1956,13 @@ true)
 	;;
 esac
 
+: Set 'sysroot' to change the logical root directory to your headers and libraries see man gcc
+: This is primarily meant for cross-compile environments, and may fail to be useful in other cases
+
+if test "X$sysroot" != X; then
+  echo "Using $sysroot to find your headers and libraries"
+fi
+
 : Eunice requires " " instead of "", can you believe it
 echo " "
 : Here we go...
@@ -4515,9 +4523,10 @@ case "$gccversion" in
 esac
 
 : What should the include directory be ?
+: Use sysroot if set, so findhdr looks in the right place.
 echo " "
 $echo $n "Hmm...  $c"
-dflt='/usr/include'
+dflt="$sysroot/usr/include"
 incpath=''
 mips_type=''
 if $test -f /bin/mips && /bin/mips; then
@@ -4721,14 +4730,21 @@ case "$libpth" in
 esac
 
 : Now check and see which directories actually exist, avoiding duplicates
+: Use sysroot for checking so we find cross-compiler dirs
 libpth=''
+: create list of actual paths on disk, for lib hunting later
+libsearchpth=''
 for xxx in $dlist
 do
-    if $test -d $xxx; then
+    if $test -d $sysroot$xxx; then
 		case " $libpth " in
 		*" $xxx "*) ;;
 		*) libpth="$libpth $xxx";;
 		esac
+        case " $libsearchpth " in
+		*" $sysroot$xxx "*) ;;
+		*) libsearchpth="$libsearchpth $sysroot$xxx";;
+		esac            
     fi
 done
 $cat <<'EOM'
@@ -4739,6 +4755,14 @@ know not to be holding relevant libraries, and add any that are needed.
 Say "none" for none.
 
 EOM
+
+if test "X$sysroot" != X; then
+  $cat <<EOM
+You have set sysroot to $sysroot, please supply the directories excluding sysroot
+
+EOM
+fi
+
 case "$libpth" in
 '') dflt='none';;
 *)
@@ -4753,11 +4777,20 @@ case "$ans" in
 none) libpth=' ';;
 *) libpth="$ans";;
 esac
+: reset libsearchpth, listing each path with sysroot included, removing any duplicates
+libsearchpth=''
+for xxx in $libpth
+do
+    case " $libsearchpth " in
+    *" $sysroot$xxx "*) ;;
+    *) libsearchpth="$libsearchpth $sysroot$xxx";;
+    esac
+done
 
 : compute shared library extension
 case "$so" in
 '')
-	if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
+	if xxx=`./loc libc.sl X $libsearchpth`; $test -f "$xxx"; then
 		dflt='sl'
 	else
 		dflt='so'
@@ -4904,7 +4937,7 @@ libsfound=''
 libsfiles=''
 libsdirs=''
 libspath=''
-for thisdir in $libpth $xlibpth; do
+for thisdir in $libsearchpth $xlibpth; do
   test -d $thisdir && libspath="$libspath $thisdir"
 done
 for thislib in $libswanted; do
@@ -7452,7 +7485,7 @@ echo " "
 case "$libc" in
 '') libc=unknown
 	case "$libs" in
-	*-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
+	*-lc_s*) libc=`./loc libc_s$_a $libc $libsearchpth`
 	esac
 	;;
 esac
@@ -7465,17 +7498,17 @@ case "$libs" in
 		;;
 	-l*)
 		thislib=`echo $thislib | $sed -e 's/^-l//'`
-		if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
+		if try=`./loc lib$thislib.$so.'*' X $libsearchpth`; $test -f "$try"; then
 			:
-		elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
+		elif try=`./loc lib$thislib.$so X $libsearchpth`; $test -f "$try"; then
 			:
-		elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
+		elif try=`./loc lib$thislib$_a X $libsearchpth`; $test -f "$try"; then
 			:
-		elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
+		elif try=`./loc $thislib$_a X $libsearchpth`; $test -f "$try"; then
 			:
-		elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
+		elif try=`./loc lib$thislib X $libsearchpth`; $test -f "$try"; then
 			:
-		elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
+		elif try=`./loc $thislib X $libsearchpth`; $test -f "$try"; then
 			:
 		elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
 			:
@@ -7493,7 +7526,7 @@ xxx=normal
 case "$libc" in
 unknown)
 	set /lib/libc.$so
-	for xxx in $libpth; do
+	for xxx in $libsearchpth; do
 		$test -r $1 || set $xxx/libc.$so
 		: The messy sed command sorts on library version numbers.
 		$test -r $1 || \
@@ -7534,10 +7567,10 @@ elif $test -r /lib/libc$_a; then
 	libc=/lib/libc$_a;
 	echo "Your C library seems to be in $libc.  You're normal."
 else
-	if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
+	if tans=`./loc libc$_a blurfl/dyick $libsearchpth`; $test -r "$tans"; then
 		:
-	elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
-		libnames="$libnames "`./loc clib blurfl/dyick $libpth`
+	elif tans=`./loc libc blurfl/dyick $libsearchpth`; $test -r "$tans"; then
+		libnames="$libnames "`./loc clib blurfl/dyick $libsearchpth`
 	elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
 		:
 	elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
@@ -7564,7 +7597,7 @@ compiler, or your machine supports multiple models), you can override it here.
 EOM
 else
 	dflt=''
-	echo $libpth | $tr ' ' $trnl | $sort | $uniq > libpath
+	echo $libsearchpth | $tr ' ' $trnl | $sort | $uniq > libpath
 	cat >&4 <<EOM
 I can't seem to find your C library.  I've looked in the following places:
 
@@ -23588,6 +23621,7 @@ libperl='$libperl'
 libpth='$libpth'
 libs='$libs'
 libsdirs='$libsdirs'
+libsearchpth='$libsearchpth'
 libsfiles='$libsfiles'
 libsfound='$libsfound'
 libspath='$libspath'
@@ -23805,6 +23839,7 @@ strings='$strings'
 submit='$submit'
 subversion='$subversion'
 sysman='$sysman'
+sysroot='$sysroot'
 tail='$tail'
 tar='$tar'
 targetarch='$targetarch'
-- 
1.7.8.6




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About