On Tuesday 09 of December 2014 19:38:53 Gary V. Vaughan wrote:
> > .. however, maybe you think that quite problematic the share with ltdl.m4
> > (via sys_lib_dlsearch_path).  That is ?clearly? configure-time only
> > variable which generates variable LT_DLSEARCH_PATH in c-header file.
> 
> We will probably need to promote the macros required to support that to
> libtool.m4 now that we care about setting sys_dlsearch_path_spec, without
> requiring every package to use ltdl.m4.
> 
> > In this case, using LT_SYS_LIBRARY_PATH at runtime would differentiate
> > LT_DLSEARCH_PATH with libtool's 'sys_dlsearch_path_spec' ... and could
> > cause confusion later.
> 
> It's a lot of variables, but technically it seems sound to me.
> 
> > Hmm, due to its requirments, it seems like LT_SYS_LIBRARY_PATH should be
> > AC_ARG_VAR-ed.  The system-wide libtool should be pre-configured correctly
> > according to system's needs anyway.  WDYT?
> 
> I think it would be easier to have both installed and in-tree libtool
> respect LT_SYS_LIBRARY_PATH, otherwise we have to edit the installed script
> to take out the substitution code.

Hi Gary, I tried to patch libtool according to previous discussion.
That requires good review, however.  Patch attached.

Pavel
>From fdc38af01a9079f712787db451ca6003101d53f1 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <prais...@redhat.com>
Date: Sat, 6 Dec 2014 16:35:41 +0100
Subject: [PATCH] libtool: allow adjusting run-time library path

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.
Distributions also have ldconfig configured properly to search
corresponding library PATH.

For libtool, it is quite difficult to detect which approach the
particular GNU/Linux box uses, however.  Glibc's ldconfig does not
provide complete PATH either.  So, by using LT_SYS_LIBRARY_PATH we
are able to enhance the dynamic library search path now, either
during ./configure time, or at run-time.

References:
http://thread.gmane.org/gmane.comp.gnu.libtool.general/8339/focus=8345

* m4/libtool.m4 (_LT_PATH_ENHANCE): New function to parse
the new path format.  Defines func_path_enhance () shell function.
(_LT_SYS_DYNAMIC_LINKER): Requires _LT_PATH_ENHANCE. AC_ARG_VAR
the LT_SYS_LIBRARY_PATH (to survive automatic "autoreconf").
Avoid hardcoding list of CPUs. Call the new func_path_enhance on
sys_lib_dlsearch_path_spec - this propagates results to ltdl.m4.
* build-aux/ltmain.in: Expand the func_path_enhance function.
* Makefile.am (SCRIPT_ENV): Add $(AWK).
(m4_expand, m4_extract): New variables.
(EXTRA_DIST): Mention the two new vars ^.
(bootstrap_edit): Substitute also @libtool_m4@.
($ltmain_sh): Pipe through $(m4_expand) also.
* build-aux/m4-expand: New helper to extract code from m4 file for
other use.
* build-aux/m4-extract: Likewise.
* doc/libtool.texi: Document new LT_SYS_LIBRARY_PATH.
* doc/notes.texi: Likewise.
---
 Makefile.am          | 13 ++++++++----
 build-aux/ltmain.in  |  7 +++++++
 build-aux/m4-expand  | 18 ++++++++++++++++
 build-aux/m4-extract | 17 +++++++++++++++
 doc/libtool.texi     | 20 ++++++++++++++++++
 doc/notes.texi       | 11 +++++-----
 m4/libtool.m4        | 58 +++++++++++++++++++++++++++++++++++++++++++---------
 7 files changed, 125 insertions(+), 19 deletions(-)
 create mode 100755 build-aux/m4-expand
 create mode 100755 build-aux/m4-extract

diff --git a/Makefile.am b/Makefile.am
index f1b7ead..f7a2078 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,7 +54,7 @@ rebuild = rebuild=:; revision=`$(lt__cd) $(srcdir) && $(git_version_gen) | $(SED
 # Bootstrap. #
 # ---------- #
 
-SCRIPT_ENV	= GREP='$(GREP)' SED='$(SED)'
+SCRIPT_ENV	= GREP='$(GREP)' SED='$(SED)' AWK='$(AWK)'
 
 build_scripts	= $(srcdir)/$(aux_dir)/announce-gen \
 		  $(srcdir)/$(aux_dir)/do-release-commit-and-tag \
@@ -86,16 +86,20 @@ ltmain_in	= $(srcdir)/$(aux_dir)/ltmain.in
 libtool_m4	= $(srcdir)/$(macro_dir)/libtool.m4
 ltversion_in	= $(srcdir)/$(macro_dir)/ltversion.in
 ltversion_m4	= $(srcdir)/$(macro_dir)/ltversion.m4
+m4_expand	= $(srcdir)/$(aux_dir)/m4-expand
+m4_extract	= $(srcdir)/$(aux_dir)/m4-extract
 options_parser	= $(srcdir)/$(aux_dir)/options-parser
 
 EXTRA_DIST     += $(extract_trace) $(funclib_sh) $(inline_source) \
 		  $(libtoolize_in) $(ltmain_in) $(ltmain_sh) \
-		  $(ltversion_in) $(ltversion_m4) $(options_parser)
+		  $(ltversion_in) $(ltversion_m4) $(options_parser) \
+		  $(m4_extract) $(m4_expand)
 
 ## These are the replacements that need to be made at bootstrap time,
 ## because they must be static in distributed files, and not accidentally
 ## changed by configure running on the build machine.
 bootstrap_edit  = $(SED) \
+		  -e 's|@libtool_m4\@|$(libtool_m4)|g' \
 		  -e 's|@MACRO_VERSION\@|$(VERSION)|g' \
 		  -e "s|@MACRO_REVISION\@|$$revision|g" \
 		  -e "s|@MACRO_SERIAL\@|$$serial|g" \
@@ -162,8 +166,9 @@ $(ltmain_sh): $(ltmain_in) $(dotversion)
 	  rm -f '$@'; \
 	  if test 0 = '$(AM_DEFAULT_VERBOSITY)' && test 1 != '$(V)'; \
 	    then echo "  GEN     " $@; \
-	  else echo "$(inline_source) '$(ltmain_in)' |" $(bootstrap_edit) "> '$@'"; fi; \
-	  $(SCRIPT_ENV) '$(inline_source)' '$(ltmain_in)' | $(bootstrap_edit) > '$@'; \
+	  else echo "$(inline_source) '$(ltmain_in)' |" $(bootstrap_edit) "|" $(m4_expand) "> '$@'"; fi; \
+	  $(SCRIPT_ENV) '$(inline_source)' '$(ltmain_in)' | $(bootstrap_edit) \
+	      | $(SCRIPT_ENV) $(m4_expand) > '$@'; \
 	  chmod a-w '$@'; \
 	fi
 
diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index a72c007..34a9ae0 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -53,6 +53,11 @@ package_revision=@package_revision@
 : ${AUTOCONF="autoconf"}
 : ${AUTOMAKE="automake"}
 
+## --------------------------------------- ##
+## External functions defined in m4 files. ##
+## --------------------------------------- ##
+
+## m4-expand @libtool_m4@ _LT_PATH_ENHANCE
 
 ## -------------------------- ##
 ## Source external libraries. ##
@@ -5525,6 +5530,8 @@ func_mode_link ()
     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
 
+    func_path_enhance sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
+
     func_dirname "$output" "/" ""
     output_objdir=$func_dirname_result$objdir
     func_to_tool_file "$output_objdir/"
diff --git a/build-aux/m4-expand b/build-aux/m4-expand
new file mode 100755
index 0000000..67fc143
--- /dev/null
+++ b/build-aux/m4-expand
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+: ${AWK=awk}
+: ${SED=sed}
+
+builddir=`echo "$0" | $SED 's|[^/]*$||'`
+
+$AWK '
+/## m4-expand / {
+  cmd = sprintf("%s %s %s", "'$builddir/m4-extract'", $3, $4);
+  system (cmd);
+  next;
+}
+
+/.*/ {
+  print;
+  next;
+}'
diff --git a/build-aux/m4-extract b/build-aux/m4-extract
new file mode 100755
index 0000000..07594d1
--- /dev/null
+++ b/build-aux/m4-extract
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+: ${M4=m4}
+
+$M4 \
+    -D__lt_file_to_extract_from="$1" \
+    -D__lt_definition_to_extract="$2" \
+<<EOF
+divert(-1)
+changequote()
+changequote([, ])
+define([m4_define],   defn([define]))
+define([m4_defun],    defn([define]))
+include(__lt_file_to_extract_from)
+divert[]dnl
+__lt_definition_to_extract[]dnl
+EOF
diff --git a/doc/libtool.texi b/doc/libtool.texi
index 90aeb8f..c2356a1 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -2419,6 +2419,26 @@ 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 is trying heavily to detect what the system run-time search path for
+libraries is.  If the guesses are not good enough, this variable can be used to
+enhance (or replace completely) the path.  The syntax of this variable is
+following (@code{path} may be any path of form @code{dir[:dir]}:
+@itemize @bullet
+@item @code{path:}
+Content of @code{path} is going to be prepended before automatically detected
+path,
+@item @code{:path}
+in this form @code{path} is going to be appended,
+@item @code{path_p::path_a}
+here @code{path_p} is going to be prepended, @code{path_a} is going to
+be appended to automatically detected path.
+@item @code{path}
+This way, libtool-detected path is going to be overwritten completely by
+@code{path}.
+@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
diff --git a/doc/notes.texi b/doc/notes.texi
index a99bbbd..7f9ca3e 100644
--- a/doc/notes.texi
+++ b/doc/notes.texi
@@ -70,11 +70,12 @@ 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
+and dynamic linker search by default.
+If this occurs for the dynamic library path, you may use the
+@code{LT_SYS_LIBRARY_PATH} 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 to the correct search
-paths.
+@code{lt_cv_sys_lib_dlsearch_path_spec} respectively.
 
 @end itemize
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 2f52305..b103954 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -2201,6 +2201,41 @@ _LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
 _LT_DECL([], [striplib], [1])
 ])# _LT_CMD_STRIPLIB
 
+m4_defun([_LT_PATH_ENHANCE],
+[# func_path_enhance VARIABLE PATH
+# -------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be enhanced by 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_path_enhance ()
+{
+    case $[]2 in
+    "")
+        ;;
+    *:)
+        eval $[]1=\"`$ECHO $[]2 | $SED 's/:/ /g'` \$$[]1\"
+        ;;
+    :*)
+        eval $[]1=\"\$$[]1 `$ECHO $[]2 | $SED 's/:/ /g'`\"
+        ;;
+    *::*)
+        eval $[]1=\"\$$[]1\ `$ECHO $[]2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+        eval $[]1=\"`$ECHO $[]2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$[]1\"
+        ;;
+    *)
+        eval $[]1=\"`$ECHO $[]2 | $SED 's/:/ /g'`\"
+        ;;
+    esac
+}
+])
 
 # _LT_SYS_DYNAMIC_LINKER([TAG])
 # -----------------------------
@@ -2212,6 +2247,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_PATH_ENHANCE])dnl
 AC_MSG_CHECKING([dynamic linker characteristics])
 m4_if([$1],
 	[], [
@@ -2306,6 +2342,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 +2830,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
@@ -3019,10 +3055,12 @@ variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
 if test yes = "$GCC"; then
   variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 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_path_enhance 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
-- 
1.9.3

_______________________________________________
https://lists.gnu.org/mailman/listinfo/libtool

Reply via email to