From 3c9dcd60c0d872a4a90ca92bccb3526917002eb7 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Tue, 22 Mar 2016 16:04:50 -0500 Subject: [PATCH] krb5-config --libs: include rpath like MIT --- tools/Makefile.am | 1 + tools/krb5-config.1 | 4 +++- tools/krb5-config.in | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/tools/Makefile.am b/tools/Makefile.am index 187cb0d91..aa3e27686 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -25,6 +25,7 @@ endif subst = sed -e "s!@PACKAGE\@!$(PACKAGE)!g" \ -e "s!@VERSION\@!$(VERSION)!g" \ + -e "s!@CANONICAL_HOST\@!$(CANONICAL_HOST)!g" \ -e "s!@prefix\@!$(prefix)!g" \ -e "s!@exec_prefix\@!$(exec_prefix)!g" \ -e "s!@libdir\@!$(libdir)!g" \ diff --git a/tools/krb5-config.1 b/tools/krb5-config.1 index 6d004b54c..ced45de3b 100644 --- a/tools/krb5-config.1 +++ b/tools/krb5-config.1 @@ -60,7 +60,9 @@ Print the exec-prefix if no is specified, otherwise set exec-prefix to .Ar dir . .It Fl Fl libs -Output the set of libraries that should be linked against. +Output the set of libraries that should be linked against. This also +includes rpath flags with the expectation that the C compiler is used +for final link-edits. .It Fl Fl cflags Output the set of flags to give to the C compiler when using the Heimdal libraries. diff --git a/tools/krb5-config.in b/tools/krb5-config.in index 0cc662bae..9e72161e6 100644 --- a/tools/krb5-config.in +++ b/tools/krb5-config.in @@ -168,6 +168,36 @@ if test "$print_exec_prefix" = "yes"; then exit 0 fi +# The following rpath_flag setting code is distilled from MIT Kerberos' +# src/config/shlib.conf. Some of this seems ancient and likely to be +# wrong in some cases, but right for all the cases we probably care +# about. Also, this will very likely be wrong depending on how the +# caller will be doing link-edits (with what compiler-driver or +# link-editor)! There's no fixing this. +# +# In principle this doesn't belong here: application should instead use +# krb5-config --libdir to get the directory to use for the rpath, then +# workout the rpath flags on their own. Of course, there's no --libdir +# option... And MIT's krb5-config does include rpath flags. +# +# Compatibility with MIT is the winning consideration for now. +case "@CANONICAL_HOST@" in +alpha*-dec-osf*) + rpath_flag='-Wl,-rpath -Wl,';; +*-*-hpux*) + rpath_flag='-Wl,+b,';; +*-*-irix* | mips-*-netbsd*) + rpath_flag='-Wl,-rpath -Wl,';; +*-*-netbsd* | *-*-openbsd* | *-*-solaris*) + rpath_flag='-R';; +*-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-freebsd*) + rpath_flag='-Wl,--enable-new-dtags -Wl,-rpath -Wl,';; +*-*-aix*) + rpath_flag='-Wl,-blibpath:';; +*) +rpath_flag=;; +esac + if test "$do_libs" = "yes"; then deplibs="" if test "$lib_gssapi" = yes; then @@ -208,6 +238,9 @@ if test "$do_libs" = "yes"; then fi if test X"$libdir" != X/usr/lib; then lib_flags="-L${libdir} $lib_flags" + if test X"$rpath_flag" != X; then + lib_flags="${rpath_flag}${libdir} $lib_flags" + fi fi echo ${lib_flags}