Skip to content

Commit

Permalink
*.ac, *.am, *.m4: Introduce AX_EXTRACT_PATH and configure --enable-li…
Browse files Browse the repository at this point in the history
…nker-add-dependency-rpath [networkupstools#2782]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jan 24, 2025
1 parent 21b61f3 commit a4ff0e7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
27 changes: 26 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ dnl AC_MSG_NOTICE([CXXFLAGS_BEFORE_ACPROG="${CXXFLAGS-}"])
AC_MSG_CHECKING(for autoconf macro to enable system extensions)
m4_version_prereq(2.61, [
AC_MSG_RESULT(yes)
dnl Causes calls to ac_prog stuff, so dittoed below if "no"
dnl Causes calls to ac_prog stuff, so dittoed below if "no"
AC_USE_SYSTEM_EXTENSIONS
], [
AC_MSG_RESULT(no)
Expand Down Expand Up @@ -419,6 +419,31 @@ case "${target_os}" in
;;
esac

NUT_ARG_ENABLE([linker-add-dependency-rpath],
[Usually pkg-config or --with-depname-libs tell us -L/some/path for build-time linking; they may tell or not the -R/some/path for run-time linking (which then relies on LD_LIBRARY_PATH and similar disliked mechanisms). This option lets us enforce conversion of -L to -R. Value can be a colon-separated list of paths to exempt (e.g. /usr/lib), or "only-R" to extract just -R hits if any.],
[auto])
AS_IF([test x"$nut_enable_linker_add_dependency_rpath" = xauto], [
AC_MSG_CHECKING([for auto setting of nut_enable_linker_add_dependency_rpath for ${target_os}])
AS_CASE([${target_os}],
[*mingw*], [nut_enable_linker_add_dependency_rpath=no],
[solaris*|sunos*|SunOS*|illumos*], [
for D in /lib /usr/lib ; do
if ! test -d "$D" ; then continue ; fi
if test x"$nut_enable_linker_add_dependency_rpath" = x ; then
nut_enable_linker_add_dependency_rpath="$D"
else
nut_enable_linker_add_dependency_rpath="${nut_enable_linker_add_dependency_rpath}:${D}"
fi
for S in 32 64 amd64 i386 i86pc sparcv9 sparcv7 sparc ; do
if ! test -d "$D/$S" ; then continue ; fi
nut_enable_linker_add_dependency_rpath="${nut_enable_linker_add_dependency_rpath}:${D}/${S}"
done
done],
[nut_enable_linker_add_dependency_rpath=auto] dnl TBD if any other distros need this by default
)
AC_MSG_RESULT([${nut_enable_linker_add_dependency_rpath}])
]

dnl Note: this deals with run-time settings so that the newly built
dnl programs can be "just executed" to use same configuration files
dnl and filesystem object permissions as an older deployment of NUT
Expand Down
14 changes: 14 additions & 0 deletions m4/ax_extract_rpath.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
dnl Given a LIBS string value in $1 coming from command-line arguments or
dnl pkg-config, prepare a similar string named in $2 with parameters for
dnl the linker -- by picking the "-R/some/path" values, and optionally
dnl converting the "-L/some/path" into "-R" too.
dnl Activity is controlled by $3:
dnl no Do nothing, return empty $2
dnl only-R Only select -R hits (if any are present)
dnl yes Convert all -R and -L hits
dnl /some:/paths Convert all -R and -L hits except "/some" or "/paths"
dnl Copyright (C) 2024-2025 by Jim Klimov

AC_DEFUN([AX_EXTRACT_RPATH],
[
])

0 comments on commit a4ff0e7

Please sign in to comment.