diff options
-rw-r--r-- | am/rpath.m4 | 153 | ||||
-rw-r--r-- | configure.ac | 12 | ||||
-rw-r--r-- | mu-aux/ltmain.sh | 17 | ||||
-rw-r--r-- | mu-aux/ltmain.sh.patch | 38 |
4 files changed, 52 insertions, 168 deletions
diff --git a/am/rpath.m4 b/am/rpath.m4 deleted file mode 100644 index b26ec0c48..000000000 --- a/am/rpath.m4 +++ /dev/null @@ -1,153 +0,0 @@ -dnl This file is part of GNU mailutils. -dnl Copyright (C) 2019 Free Software Foundation, Inc. -dnl -dnl GNU Mailutils is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3 of the License, or -dnl (at your option) any later version. -dnl -dnl GNU Mailutils is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. - -# Some packages provide configuration helper tools that emit the cc -# flags to be used when linking a program with that package. Normally -# the output of such a tool consists of a series of -l (eventualy -L) -# options in the right order. However, some tools emit linker -rpath -# options (-Wl,-rpath) as well. The most notorious example of these is -# krb5-config. When such options are passed to libtool in CC mode, the -# created run-time wrapper script looks for the libraries first in the -# directories supplied with the linker options and then in the local source -# tree. When this wrapper is run (i.e. when the program is invoked from the -# source tree), it uses the libraries installed in the system instead of -# their local versions from the source tree. -# -# Obviously, this is a libtool bug. Until it is fixed, this autoconf module -# provides a workaround. It translates all -Wl,-rpath,DIR (or -Wl,-rpath -# -Wl,DIR) options to -R DIR form. Libtool treats '-R' options differently: -# the directories listed in them are appended to the constructed rpath, -# so that when wrappers are run, source tree directories are scanned first. -# -# For the record, there are also other issues that can cause wrong libraries -# to be used on some systems. See, for example this libtool bug report: -# https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27510 -# This issue has not been addressed yet. - -dnl MU_RPATH_FIXUP_INIT -dnl ------------------- -dnl Initialize the rpath fixup procedure by emitting auxiliary shell -dnl functions used in it. -dnl Normally you don't need to use this macro explicitly, as it will be -dnl called exactly once by the first expansion of the MU_RPATH_FIXUP_VAR or -dnl MU_RPATH_FIXUP_SUBST (see below). -AC_DEFUN([MU_RPATH_FIXUP_INIT],[ -m4_ifdef([MU_RPATH_FIXUP_INIT_SENTINEL],[], -[# The following three functions were inspired by libtool. - -# mu_arg_append VAR STRING -# ------------------------ -# Append STRING to the value of the variable VAR. Unless VAR is empty -# or undefined, precede STRING with a single space -mu_arg_append() -{ - eval "@S|@1=\@S|@@S|@1\@S|@{@S|@1:+ }\@S|@2" -} - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='s|\([`"@S|@\\]\)|\\\1|g' - -# mu_quote_for_eval ARG... -# ------------------------ -# Quote ARGs to be evaled later. Leave return in the variable -# mu_quote_for_eval_result. -mu_quote_for_eval() -{ - mu_quote_for_eval_result= - for arg - do - case @S|@arg in - *[\\\`\"\@S|@]*) - _G_arg=`echo "@S|@arg" | @S|@{SED:-sed} "@S|@sed_quote_subst"` ;; - *) - _G_arg=@S|@1 ;; - esac - mu_arg_append mu_quote_for_eval_result "@S|@_G_arg" - done -} - -# mu_arg_append_quoted VAR STRING -# ------------------------------- -# Append space character and STRING to the value of the variable VAR. -# Take care to properly quote the STRING, so that @S|@VAR will be evaled -# correctly. -mu_arg_append_quoted() -{ - mu_quote_for_eval "@S|@2" - eval "@S|@1=\@S|@@S|@1\\ \@S|@mu_quote_for_eval_result" -} - -# mu_rpath_translate_args VAR ARG... -# ---------------------------------- -# Concatenate ARGs into shell variable VAR, translating each occurrence of -# -Wl,-rpath,DIR or -Wl,-rpath -WlDIR to the -R DIR option. -mu_rpath_translate_args() -{ - elim_linker_options_var=@S|@1 - shift - eval @S|@elim_linker_options_var= - while test @S|@# -gt 0 - do - case @S|@1 in - -Wl,-rpath,*) - mu_arg_append_quoted @S|@elim_linker_options_var '-R' - mu_arg_append_quoted @S|@elim_linker_options_var @S|@{1##*,} - ;; - -Wl,-rpath) - shift - mu_arg_append_quoted @S|@elim_linker_options_var '-R' - mu_arg_append_quoted @S|@elim_linker_options_var "@S|@{1##-Wl,}" - ;; - *) mu_arg_append_quoted @S|@elim_linker_options_var "@S|@1" - esac - shift - done -} - -# mu_rpath_translate VAR -# ---------------------- -# Replace -Wl,-rpath options in the value of VAR to corresponding -R -# options. -mu_rpath_translate() -{ - eval mu_rpath_translate_args @S|@1 \@S|@@S|@1 -} -m4_define([MU_RPATH_FIXUP_INIT_SENTINEL],[TRUE])]) -]) - -dnl MU_RPATH_FIXUP_VAR(VARNAME) -dnl --------------------------- -dnl Mark shell variable VARNAME as needing rpath option fixup. -AC_DEFUN([MU_RPATH_FIXUP_VAR],[MU_RPATH_FIXUP_INIT -m4_set_add(mu_linker_substvars,$1)]) - -dnl MU_RPATH_FIXUP_SUBST(VARNAME) -dnl ----------------------------- -dnl AC_SUBST the variable VARNAME and mark it as needing rpath option -dnl fixup. -AC_DEFUN([MU_RPATH_FIXUP_SUBST],[AC_SUBST($@) -MU_RPATH_FIXUP_VAR($1)]) - -dnl MU_RPATH_FIXUP_COMMIT -dnl --------------------- -dnl Commit the changes by fixing up the variables marked by prior expansions -dnl of MU_RPATH_FIXUP_VAR|MU_RPATH_FIXUP_SUBST. -AC_DEFUN([MU_RPATH_FIXUP_COMMIT],[m4_set_foreach(mu_linker_substvars,VAR, - [mu_rpath_translate VAR -])]) - -dnl END of rpath.m4 diff --git a/configure.ac b/configure.ac index 75053cf35..7dcfeeeab 100644 --- a/configure.ac +++ b/configure.ac @@ -50,8 +50,6 @@ dnl Other variables AC_SUBST(mu_aux_dir,'$(top_srcdir)/mu-aux') AC_SUBST(MU_SIEVE_MODDIR,'$(libdir)/$(PACKAGE)') -MU_RPATH_FIXUP_VAR([LTLIBINTL]) -MU_RPATH_FIXUP_VAR([LTLIBICONV]) AC_SUBST(MU_COMMON_LIBRARIES,'$(LTLIBINTL) $(LTLIBICONV)') AC_SUBST(MU_APP_LIBRARIES,'${top_builddir}/lib/libmuaux.la') @@ -160,7 +158,7 @@ AC_ARG_ENABLE([experimental], # Initialize authlibs -MU_RPATH_FIXUP_SUBST(MU_AUTHLIBS) +AC_SUBST(MU_AUTHLIBS) AC_SUBST(MU_AUTHINCS) dnl Check for arguments @@ -235,7 +233,7 @@ case "${withval}" in *) AC_MSG_ERROR(bad value ${withval} for --without-readline) ;; esac],[status_readline=probe]) -MU_RPATH_FIXUP_SUBST(SERV_AUTHLIBS) +AC_SUBST(SERV_AUTHLIBS) AC_SUBST(SERV_AUTHINCS) AC_ARG_WITH([gssapi], @@ -334,7 +332,7 @@ AH_BOTTOM( ################################## # DBM Support ################################## -MU_RPATH_FIXUP_SUBST(DBMLIBS) +AC_SUBST(DBMLIBS) AC_SUBST(DBMINCLUDES) enable_dbm= @@ -1201,7 +1199,7 @@ case "${enableval}" in *) AC_MSG_ERROR(bad value ${enableval} for --enable-python) ;; esac],[status_python=yes]) -MU_RPATH_FIXUP_SUBST(PYTHON_LIBS) +AC_SUBST(PYTHON_LIBS) AC_SUBST(PYTHON_INCLUDES) AC_SUBST(PYTHON_MAJOR) @@ -1394,8 +1392,6 @@ if test -z "$PERL"; then fi AC_SUBST([GITINFO],'$(PERL) $(mu_aux_dir)/gitinfo') -MU_RPATH_FIXUP_COMMIT - AC_CONFIG_COMMANDS([status],[ cat <<EOF diff --git a/mu-aux/ltmain.sh b/mu-aux/ltmain.sh index 5b0b7292b..1cb4f22c5 100644 --- a/mu-aux/ltmain.sh +++ b/mu-aux/ltmain.sh @@ -6561,6 +6561,7 @@ func_mode_link () vinfo= vinfo_number=no weak_libs= + rpath_arg= single_module=$wl-single_module func_infer_tag $base_compile @@ -7434,8 +7435,20 @@ func_mode_link () # Now actually substitute the argument into the commands. if test -n "$arg"; then - func_append compile_command " $arg" - func_append finalize_command " $arg" + if test -n "$rpath_arg"; then + func_append finalize_rpath " ${arg##*,}" + unset rpath_arg + else + case $arg in + -Wl,-rpath,*) + func_append finalize_rpath " ${arg##*,}";; + -Wl,-rpath) + rpath_arg=1;; + *) + func_append compile_command " $arg" + func_append finalize_command " $arg" + esac + fi fi done # argument parsing loop diff --git a/mu-aux/ltmain.sh.patch b/mu-aux/ltmain.sh.patch index 239017e0c..b2e395749 100644 --- a/mu-aux/ltmain.sh.patch +++ b/mu-aux/ltmain.sh.patch @@ -1,7 +1,7 @@ Index: build-aux/ltmain.sh ---- build-aux.orig/ltmain.sh 2019-11-30 19:38:53.588892479 +0200 -+++ build-aux/ltmain.sh 2019-12-03 23:05:41.766760636 +0200 -@@ -6556,6 +6556,7 @@ func_mode_link () +--- build-aux.origin.sh 2019-11-30 19:38:53.588892479 +0200 ++++ build-aux/ltmain.sh 2019-12-04 10:21:15.159881873 +0200 +@@ -6556,10 +6556,12 @@ func_mode_link () xrpath= perm_rpath= temp_rpath= @@ -9,7 +9,35 @@ Index: build-aux/ltmain.sh thread_safe=no vinfo= vinfo_number=no -@@ -8088,7 +8089,10 @@ func_mode_link () + weak_libs= ++ rpath_arg= + single_module=$wl-single_module + func_infer_tag $base_compile + +@@ -7433,8 +7435,20 @@ func_mode_link () + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then +- func_append compile_command " $arg" +- func_append finalize_command " $arg" ++ if test -n "$rpath_arg"; then ++ func_append finalize_rpath " ${arg##*,}" ++ unset rpath_arg ++ else ++ case $arg in ++ -Wl,-rpath,*) ++ func_append finalize_rpath " ${arg##*,}";; ++ -Wl,-rpath) ++ rpath_arg=1;; ++ *) ++ func_append compile_command " $arg" ++ func_append finalize_command " $arg" ++ esac ++ fi + fi + done # argument parsing loop + +@@ -8088,7 +8102,10 @@ func_mode_link () # Make sure the rpath contains only unique directories. case $temp_rpath: in *"$absdir:"*) ;; @@ -21,7 +49,7 @@ Index: build-aux/ltmain.sh esac fi -@@ -8538,6 +8542,9 @@ func_mode_link () +@@ -8538,6 +8555,9 @@ func_mode_link () fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs |