]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
libtool: support LT_SYS_LIBRARY_PATH for adjusting bad guesses.
authorPavel Raiskup <praiskup@redhat.com>
Thu, 11 Dec 2014 21:49:19 +0000 (21:49 +0000)
committerGary V. Vaughan <gary@gnu.org>
Thu, 11 Dec 2014 23:06:09 +0000 (23:06 +0000)
Revert 8728e07 and 440fee6.
Some GNU/Linux distributions install libraries into /lib64 (or
/usr/lib64) on 64-bit machines, while /lib (/usr/lib
respectively) stays for multilib variant.  Other distributions
keep /usr/lib for 64-bit variant and reserve other directory for
multilib. Detection of what approach a given system uses is
difficult, however, especially because Glibc's ldconfig does not
report the full and correct list of search paths. Allow the user
to adjust Libtools heuristically determined search paths with
the new LT_SYS_LIBRARY_PATH environment variable at both
compile-time, when libtool is called, and at configure time.
* m4/libtool.m4 (_LT_PREPARE_MUNGE_PATH_LIST): Define a new
function to munge a libtool path list according to a user
supplied colon-delimited path.
(_LT_SYS_DYNAMIC_LINKER): Require _LT_PREPARE_MUNGE_PATH_LIST.
Mark LT_SYS_LIBRARY_PATH as precious to autoconf (to survive
automatic "autoreconf").
Call the new func_munge_path_list function on
sys_lib_dlsearch_path_spec - this propagates results to
generated libtool script.
(_LT_CONFIG): Expand _LT_PREPARE_MUNGE_PATH_LIST into generated
libtool script.
* build-aux/ltmain.in (func_mode_link): Call it to adjust
sys_lib_dlsearch_path according to LT_SYS_LIBRARY_PATH.
* doc/libtool.texi: Document new LT_SYS_LIBRARY_PATH.
* doc/notes.texi: Likewise.
* NEWS: Update.

References: http://thread.gmane.org/gmane.comp.gnu.libtool.general/8339/focus=8345
Signed-off-by: Gary V. Vaughan <gary@gnu.org>
NEWS
build-aux/ltmain.in
doc/libtool.texi
doc/notes.texi
m4/libtool.m4

diff --git a/NEWS b/NEWS
index 6d48d28dee714e33fd0d3d3430f0ffc109a3d644..87926bda89e9cbafdd817f8559ce54024af01496 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ NEWS - list of user-visible changes between releases of GNU Libtool
   - Libtoolize searches for the best available M4 on the user PATH at
     runtime, rather than settling for the first one found.
 
+  - Support munging sys_lib_dlsearch_path_spec with LT_SYS_LIBRARY_PATH
+    environment variable.
+
 ** Bug fixes:
 
   - Bail out at configure time if the installed M4 is not sufficient
@@ -24,9 +27,6 @@ NEWS - list of user-visible changes between releases of GNU Libtool
     ia64-hp-hpux*, because the default system runtime loader path does
     not contain them.
 
-  - For various GNU/Linux (and other GNU OSes) on 64bit glibc/ELF hosts,
-    explicit /lib64 and /usr/lib64 rpaths are no longer necessary.
-
 
 * Noteworthy changes in release 2.4.4 (2014-11-29) [stable]
 
index a72c007cbf589b6256e7db136551a0f2aec43f01..42048dfe346afa9a184002204347f729151e110c 100644 (file)
@@ -5525,6 +5525,9 @@ func_mode_link ()
     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
 
+    # Definition is injected by LT_CONFIG during libtool generation.
+    func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
+
     func_dirname "$output" "/" ""
     output_objdir=$func_dirname_result$objdir
     func_to_tool_file "$output_objdir/"
index 90aeb8ffef996dc3240970f5bf7c4e42c70037bd..06322259bb20a7c5298a1466039d6b45c1563c13 100644 (file)
@@ -2419,6 +2419,27 @@ Program to use rather than checking for @command{mt}, the Manifest Tool.
 Only used on Cygwin/MS-Windows at the moment.
 @end defvar
 
+@defvar LT_SYS_LIBRARY_PATH
+Libtool has heuristics for the system search path for runtime-loaded
+libraries.  If the guessed default does not match the setup of the host
+system, this variable can be used to modify that path list, as follows
+(@code{LT_SYS_LIBRARY_PATH} is a colon-delimited list like @code{PATH}):
+@itemize @bullet
+@item @code{path:}
+The heuristically determined paths will be appened after the trailing
+colon;
+@item @code{:path}
+The heuristically determined paths will be prepended before the leading
+colon;
+@item @code{path::path}
+The heuristically determined paths will be inserted between the double
+colons;
+@item @code{path}
+With no dangling colons, the heuristically determined paths will be
+ignored entirely.
+@end itemize
+@end defvar
+
 With 1.3 era libtool, if you wanted to know any details of what
 libtool had discovered about your architecture and environment, you
 had to run the script with @option{--config} and grep through the
index a99bbbd64b92ba2e1749f44c026313b719c2f5b6..1fa8a0b912680ff46c52c6ab5196b9672c77011f 100644 (file)
@@ -68,13 +68,12 @@ to use autoconf-mode, which is distributed with GNU Emacs 21, Autoconf itself,
 and all recent releases of XEmacs.
 
 @item
-When building on some GNU/Linux systems for multilib targets
-@command{libtool} sometimes guesses the wrong paths that the linker
-and dynamic linker search by default. If this occurs, you may override
-libtool's guesses at @command{configure} time by setting the
-@command{autoconf} cache variables
-@code{lt_cv_sys_lib_search_path_spec} and
-@code{lt_cv_sys_lib_dlsearch_path_spec} respectively to the correct search
-paths.
+When building on some GNU/Linux systems for multilib targets @command{libtool}
+sometimes guesses the wrong paths that the linker and dynamic linker search by
+default. If this occurs for the dynamic library path, you may use the
+@code{LT_SYS_LIBRARY_PATH} environment variable to adjust. Otherwise, at
+@command{configure} time you may override libtool's guesses by setting the
+@command{autoconf} cache variables @code{lt_cv_sys_lib_search_path_spec} and
+@code{lt_cv_sys_lib_dlsearch_path_spec} respectively.
 
 @end itemize
index 2f52305f0a4d67cdf79c646290030ac18bd84774..fd7108e45a3e66738c81cc27fec011e0a1c15f2a 100644 (file)
@@ -725,6 +725,15 @@ _LT_LIBTOOL_CONFIG_VARS
 _LT_LIBTOOL_TAG_VARS
 # ### END LIBTOOL CONFIG
 
+_LT_EOF
+
+    cat <<'_LT_EOF' >> "$cfgfile"
+## -------------------------------------- ##
+## Shell functions shared with configure. ##
+## -------------------------------------- ##
+
+_LT_PREPARE_MUNGE_PATH_LIST
+
 _LT_EOF
 
   case $host_os in
@@ -2202,6 +2211,47 @@ _LT_DECL([], [striplib], [1])
 ])# _LT_CMD_STRIPLIB
 
 
+# _LT_PREPARE_MUNGE_PATH_LIST
+# ---------------------------
+# Make sure func_munge_path_list() is defined correctly.
+m4_defun([_LT_PREPARE_MUNGE_PATH_LIST],
+[[# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+#       string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+#       string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+#       string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+#       "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+#       VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+    case x@S|@2 in
+    x)
+        ;;
+    *:)
+        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \$@S|@1\"
+        ;;
+    x:*)
+        eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\"
+        ;;
+    *)
+        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+]])# _LT_PREPARE_PATH_LIST
+
+
 # _LT_SYS_DYNAMIC_LINKER([TAG])
 # -----------------------------
 # PORTME Fill in your ld.so characteristics
@@ -2212,6 +2262,7 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_DECL_OBJDUMP])dnl
 m4_require([_LT_DECL_SED])dnl
 m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl
 AC_MSG_CHECKING([dynamic linker characteristics])
 m4_if([$1],
        [], [
@@ -2306,6 +2357,9 @@ hardcode_into_libs=no
 # flags to be left without arguments
 need_version=unknown
 
+AC_ARG_VAR([LT_SYS_LIBRARY_PATH],
+[User-defined run-time library search path.])
+
 case $host_os in
 aix3*)
   version_type=linux # correct to gnu/linux during the next big refactor
@@ -2791,19 +2845,16 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   # before this can be enabled.
   hardcode_into_libs=yes
 
-  # Append ld.so.conf contents to the search path
+  # Ideally, we could use ldconfig to report *all* directores which are
+  # searched for libraries, however this is still not possible.  Aside from not
+  # being certain /sbin/ldconfig is available, command
+  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+  # even though it is searched at run-time.  Try to do the best guess by
+  # appending ld.so.conf contents (and includes) to the search path.
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[  ]*hwcap[        ]/d;s/[:,      ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
     sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
   fi
-  # Ideally we could use /sbin/ldconfig to report what directories are
-  # searched, but (aside from not being certain /sbin/ldconfig is
-  # available) Fedora on 64bit does not report /usr/lib64, even though
-  # it is searched at run-time.
-  case $host_cpu in
-    # match at least x86_64, ia64, powerpc64*, s390x (add other glibc/ELF 64bit cpus here):
-    *64*|s390x) sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 $sys_lib_dlsearch_path_spec" ;;
-  esac
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
   # powerpc, because MkLinux only supported shared libraries with the
@@ -3023,6 +3074,9 @@ fi
 if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
   sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
 fi
+
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
 if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
   sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
 fi