As part of their switch to a multi-arch library layout,
authorAndy Dougherty <doughera@lafayette.edu>
Sun, 17 Apr 2011 08:19:57 +0000 (18:19 +1000)
committerJesse Vincent <jesse@bestpractical.com>
Sun, 17 Apr 2011 08:22:18 +0000 (18:22 +1000)
Ubuntu 11.04 (and later, presumably) doesn't keep most libraries
(such as -lm) in /lib or /usr/lib.  So we have to ask gcc to tell us
where to look.  We don't want gcc's own libraries, however, so we
filter those out.

This could be conditional on Ubuntu, but other distributions have
announced their intent follow suit, and this scheme seems to work even
on rather old gcc's.  This unconditionally uses gcc because even if the
user is using another compiler, we still need to find the math library
and friends, and I don't know how other compilers will cope with that
situation.  Still, as an escape hatch, allow Configure command line
overrides to plibpth to bypass this check.

hints/linux.sh

index ac27f23..e03ab1e 100644 (file)
@@ -151,6 +151,24 @@ case "$optimize" in
     ;;
 esac
 
+# Ubuntu 11.04 (and later, presumably) doesn't keep most libraries
+# (such as -lm) in /lib or /usr/lib.  So we have to ask gcc to tell us
+# where to look.  We don't want gcc's own libraries, however, so we
+# filter those out.
+# This could be conditional on Unbuntu, but other distributions may
+# follow suit, and this scheme seems to work even on rather old gcc's.
+# This unconditionally uses gcc because even if the user is using another
+# compiler, we still need to find the math library and friends, and I don't
+# know how other compilers will cope with that situation.
+# Still, as an escape hatch, allow Configure command line overrides to
+# plibpth to bypass this check.
+case "$plibpth" in
+'') plibpth=`gcc -print-search-dirs | grep libraries |
+       cut -f2- -d= | tr ':' $trnl | grep -v 'gcc'`
+    plibpth="$plibpth"  # Collapse all entries on one line
+    ;;
+esac
+
 # Are we using ELF?  Thanks to Kenneth Albanowski <kjahds@kjahds.com>
 # for this test.
 cat >try.c <<'EOM'