Use -rpath option when linking all the libraries too

Previously this was used only for linking the samples, which ensured
that they found the libraries directly referenced by them, but this
wasn't enough to find the libraries referenced indirectly, via another
library (e.g. wxxml used by wxxrc internally but not necessarily
referenced by the sample using XRC) because DT_RUNPATH is not used in
this case, as documented in Linux ld.so(8).

Ensure that such libraries are found nevertheless by setting runpath
for all the libraries too.

Note that it would probably be more logical to just get rid of
SAMPLES_RPATH_FLAG and use DYLIB_RPATH_FLAG everywhere, but this would
result in a ton of changes, so keep the old variable for now and just
set it to the same value to avoid this and keep the possibility to
change it to a different value if necessary later.
This commit is contained in:
Vadim Zeitlin 2024-01-29 01:15:40 +01:00
parent 91de9867ee
commit 63bcac8c21
5 changed files with 47 additions and 30 deletions

View file

@ -136,6 +136,7 @@ DEFAULT_DEFAULT_wxUSE_QT=0
PROGRAM_EXT=
SAMPLES_CXXFLAGS=
SAMPLES_RPATH_FLAG=
DYLIB_RPATH_FLAG=
DYLIB_RPATH_INSTALL=
DYLIB_RPATH_POSTLINK=
@ -3443,12 +3444,12 @@ if test "$wxUSE_SHARED" = "yes"; then
dnl test for Sun CC which can be used under both Solaris and Linux
if test "x$SUNCXX" = xyes; then
SAMPLES_RPATH_FLAG="-R\$(wx_top_builddir)/lib"
DYLIB_RPATH_FLAG="-R\$(wx_top_builddir)/lib"
WXCONFIG_RPATH="-R\$libdir"
else
case "${host}" in
*-*-linux* | *-*-gnu* )
SAMPLES_RPATH_FLAG="-Wl,-rpath,\$(wx_top_builddir)/lib"
DYLIB_RPATH_FLAG="-Wl,-rpath,\$(wx_top_builddir)/lib"
WXCONFIG_RPATH="-Wl,-rpath,\$libdir"
;;
@ -3469,7 +3470,7 @@ if test "$wxUSE_SHARED" = "yes"; then
[],[])],
[
AC_MSG_RESULT([yes])
SAMPLES_RPATH_FLAG="-Wl,-rpath,\$(wx_top_builddir)/lib"
DYLIB_RPATH_FLAG="-Wl,-rpath,\$(wx_top_builddir)/lib"
WXCONFIG_RPATH="-Wl,-rpath,\$libdir"
],[
AC_MSG_RESULT([no])
@ -3479,7 +3480,7 @@ if test "$wxUSE_SHARED" = "yes"; then
[],[])],
[
AC_MSG_RESULT([yes])
SAMPLES_RPATH_FLAG="-Wl,-R,\$(wx_top_builddir)/lib"
DYLIB_RPATH_FLAG="-Wl,-R,\$(wx_top_builddir)/lib"
WXCONFIG_RPATH="-Wl,-R,\$libdir"
],[
AC_MSG_RESULT([no])
@ -3522,7 +3523,7 @@ EOF
;;
*-*-hpux* )
SAMPLES_RPATH_FLAG="-Wl,+b,\$(wx_top_builddir)/lib"
DYLIB_RPATH_FLAG="-Wl,+b,\$(wx_top_builddir)/lib"
WXCONFIG_RPATH="-Wl,+b,\$libdir"
;;
@ -3530,11 +3531,14 @@ EOF
fi
if test $wxUSE_RPATH = "no"; then
SAMPLES_RPATH_FLAG=''
DYLIB_RPATH_FLAG=''
DYLIB_PATH_POSTLINK=''
WXCONFIG_RPATH=''
fi
dnl Flag for the samples is the same as for the libraries themselves.
SAMPLES_RPATH_FLAG="$DYLIB_RPATH_FLAG"
SHARED=1
else
@ -7804,6 +7808,7 @@ AC_SUBST(DEBUG_FLAG)
TOOLKIT_LOWERCASE=`echo $TOOLKIT | tr '[[A-Z]]' '[[a-z]]'`
AC_SUBST(TOOLKIT_LOWERCASE)
AC_SUBST(TOOLKIT_VERSION)
AC_SUBST(DYLIB_RPATH_FLAG)
AC_SUBST(DYLIB_RPATH_INSTALL)
AC_SUBST(DYLIB_RPATH_POSTLINK)
AC_SUBST(SAMPLES_RPATH_FLAG)