Linux hints: Improve the code that looks for libc.so
authorBrian Fraser <fraserbn@gmail.com>
Wed, 22 Jan 2014 22:33:51 +0000 (19:33 -0300)
committerBrian Fraser <fraserbn@gmail.com>
Sun, 26 Jan 2014 17:44:18 +0000 (14:44 -0300)
hints/linux.sh

index 5f92bba..4c2c5f5 100644 (file)
@@ -60,17 +60,6 @@ libswanted="$*"
 # Debian 4.0 puts ndbm in the -lgdbm_compat library.
 libswanted="$libswanted gdbm_compat"
 
-# If you have glibc, then report the version for ./myconfig bug reporting.
-# (Configure doesn't need to know the specific version since it just uses
-# gcc to load the library for all tests.)
-# We don't use __GLIBC__ and  __GLIBC_MINOR__ because they
-# are insufficiently precise to distinguish things like
-# libc-2.0.6 and libc-2.0.7.
-if test -L /lib/libc.so.6; then
-    libc=`ls -l /lib/libc.so.6 | awk '{print $NF}'`
-    libc=/lib/$libc
-fi
-
 # Configure may fail to find lstat() since it's a static/inline
 # function in <sys/stat.h>.
 d_lstat=define
@@ -185,6 +174,32 @@ case "$plibpth" in
     ;;
 esac
 
+case "$libc" in
+'')
+# If you have glibc, then report the version for ./myconfig bug reporting.
+# (Configure doesn't need to know the specific version since it just uses
+# gcc to load the library for all tests.)
+# We don't use __GLIBC__ and  __GLIBC_MINOR__ because they
+# are insufficiently precise to distinguish things like
+# libc-2.0.6 and libc-2.0.7.
+    for p in $plibpth
+    do
+        for trylib in libc.so.6 libc.so
+        do
+            if $test -e $p/$trylib; then
+                libc=`ls -l $p/$trylib | awk '{print $NF}'`
+                if $test "X$libc" != X; then
+                    break
+                fi
+            fi
+        done
+        if $test "X$libc" != X; then
+            break
+        fi
+    done
+    ;;
+esac
+
 # Are we using ELF?  Thanks to Kenneth Albanowski <kjahds@kjahds.com>
 # for this test.
 cat >try.c <<'EOM'