>From fdc38af01a9079f712787db451ca6003101d53f1 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup 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 @address@hidden ($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 @@ address@hidden@ : ${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" \ +</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