Repository: trafficserver
Updated Branches:
  refs/heads/master fbd482250 -> cb3d5f4ea


TS-4047: consistently handle multiple RPATH options

Using TS_ADDTO to add the custom locations of libraries results in
incorrect "-rpath" directive to the linker. This is because TS_ADDTO
creates a unique list of tokens that it adds to its target.

e.g. ./configure --with-openssl=/usr/local/openssl --with-zlib=/usr/local/zlib

The above results in LIBTOOL_LINK_FLAGS:
  -rpath /usr/local/openssl/lib /usr/local/zlib/lib

The absence of "-rpath" in front of the second path causes an error
in the linker. This is fixed by introducing a new macro TS_ADD_RPATH_TO
that takes a path and adds it with the "-R " prefix.

Also added the influential environmental variable RPATH that can
be used to give an additional value for the rpath.

This closes #324.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/cb3d5f4e
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/cb3d5f4e
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/cb3d5f4e

Branch: refs/heads/master
Commit: cb3d5f4eaee238e349e68bee34bde5764d94a3b0
Parents: fbd4822
Author: Jay Ramamurthi <[email protected]>
Authored: Mon Dec 7 08:31:39 2015 -0800
Committer: James Peach <[email protected]>
Committed: Mon Dec 7 08:35:18 2015 -0800

----------------------------------------------------------------------
 build/ax_check_openssl.m4 |  4 ++--
 build/common.m4           | 10 ++++++++++
 build/jemalloc.m4         |  2 +-
 build/lzma.m4             |  2 +-
 build/pcre.m4             |  2 +-
 build/tcmalloc.m4         |  2 +-
 build/xml.m4              |  4 ++--
 build/zlib.m4             |  2 +-
 configure.ac              |  5 +++++
 9 files changed, 24 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb3d5f4e/build/ax_check_openssl.m4
----------------------------------------------------------------------
diff --git a/build/ax_check_openssl.m4 b/build/ax_check_openssl.m4
index b490c91..92e0dc0 100644
--- a/build/ax_check_openssl.m4
+++ b/build/ax_check_openssl.m4
@@ -83,12 +83,12 @@ AC_DEFUN([AX_CHECK_OPENSSL], [
                 if test -d "$ssldir/lib64"; then
                   OPENSSL_LDFLAGS="-L$ssldir/lib64"
                   if test "$overriden_with_ssl"; then
-                    TS_ADDTO(LIBTOOL_LINK_FLAGS, [-rpath ${ssldir}/lib64])
+                    TS_ADDTO_RPATH(${ssldir}/lib64)
                   fi
                 else
                   OPENSSL_LDFLAGS="-L$ssldir/lib"
                   if test "$overriden_with_ssl"; then
-                    TS_ADDTO(LIBTOOL_LINK_FLAGS, [-rpath ${ssldir}/lib])
+                    TS_ADDTO_RPATH(${ssldir}/lib)
                   fi
                 fi
                 OPENSSL_LIBS="-lssl -lcrypto"

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb3d5f4e/build/common.m4
----------------------------------------------------------------------
diff --git a/build/common.m4 b/build/common.m4
index 627cb3a..1be57e6 100644
--- a/build/common.m4
+++ b/build/common.m4
@@ -137,6 +137,16 @@ AC_DEFUN([TS_ADDTO], [
 ])dnl
 
 dnl
+dnl TS_ADDTO_RPATH(path)
+dnl
+dnl   Adds path to variable with the '-rpath' directive.
+dnl
+AC_DEFUN([TS_ADDTO_RPATH], [
+  AC_MSG_NOTICE([adding $1 to RPATH])
+  TS_ADDTO(LIBTOOL_LINK_FLAGS, [-R$1])
+])dnl
+
+dnl
 dnl TS_REMOVEFROM(variable, value)
 dnl
 dnl Remove a value from a variable

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb3d5f4e/build/jemalloc.m4
----------------------------------------------------------------------
diff --git a/build/jemalloc.m4 b/build/jemalloc.m4
index 525d281..a8c60b3 100644
--- a/build/jemalloc.m4
+++ b/build/jemalloc.m4
@@ -56,7 +56,7 @@ if test "$enable_jemalloc" != "no"; then
   if test "$jemalloc_base_dir" != "/usr"; then
     TS_ADDTO(CPPFLAGS, [-I${jemalloc_include}])
     TS_ADDTO(LDFLAGS, [-L${jemalloc_ldflags}])
-    TS_ADDTO(LIBTOOL_LINK_FLAGS, [-R${jemalloc_ldflags}])
+    TS_ADDTO_RPATH(${jemalloc_ldflags})
   fi
   # On Darwin, jemalloc symbols are prefixed with je_. Search for that first, 
then fall back
   # to unadorned symbols.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb3d5f4e/build/lzma.m4
----------------------------------------------------------------------
diff --git a/build/lzma.m4 b/build/lzma.m4
index f63d09c..b951a6e 100644
--- a/build/lzma.m4
+++ b/build/lzma.m4
@@ -82,7 +82,7 @@ if test "$enable_lzma" != "no"; then
   if test "$lzma_base_dir" != "/usr"; then
     TS_ADDTO(CPPFLAGS, [-I${lzma_include}])
     TS_ADDTO(LDFLAGS, [-L${lzma_ldflags}])
-    TS_ADDTO(LIBTOOL_LINK_FLAGS, [-R${lzma_ldflags}])
+    TS_ADDTO_RPATH(${lzma_ldflags})
   fi
   AC_SEARCH_LIBS([lzma_code], [lzma], [lzma_have_libs=1])
   if test "$lzma_have_libs" != "0"; then

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb3d5f4e/build/pcre.m4
----------------------------------------------------------------------
diff --git a/build/pcre.m4 b/build/pcre.m4
index e0eff08..978e95b 100644
--- a/build/pcre.m4
+++ b/build/pcre.m4
@@ -93,7 +93,7 @@ if test "$enable_pcre" != "no"; then
   if test "$pcre_base_dir" != "/usr"; then
     TS_ADDTO(CPPFLAGS, [-I${pcre_include}])
     TS_ADDTO(LDFLAGS, [-L${pcre_ldflags}])
-    TS_ADDTO(LIBTOOL_LINK_FLAGS, [-R${pcre_ldflags}])
+    TS_ADDTO_RPATH(${pcre_ldflags})
   fi
   AC_SEARCH_LIBS([pcre_exec], [pcre], [pcre_have_libs=1])
   if test "$pcre_have_libs" != "0"; then

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb3d5f4e/build/tcmalloc.m4
----------------------------------------------------------------------
diff --git a/build/tcmalloc.m4 b/build/tcmalloc.m4
index e369d73..1533df4 100644
--- a/build/tcmalloc.m4
+++ b/build/tcmalloc.m4
@@ -41,7 +41,7 @@ AC_ARG_WITH([tcmalloc], 
[AC_HELP_STRING([--with-tcmalloc=DIR], [use the tcmalloc
     if test "x$withval" != "xyes" && test "x$withval" != "x"; then
       tcmalloc_ldflags="$withval/lib"
       TS_ADDTO(LDFLAGS, [-L${tcmalloc_ldflags}])
-      TS_ADDTO(LIBTOOL_LINK_FLAGS, [-rpath ${tcmalloc_ldflags}])
+      TS_ADDTO_RPATH(${tcmalloc_ldflags})
     fi
     AC_SEARCH_LIBS([tc_cfree], ${with_tcmalloc_lib}, [tcmalloc_have_lib=1])
     if test "$tcmalloc_have_lib" != "0"; then

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb3d5f4e/build/xml.m4
----------------------------------------------------------------------
diff --git a/build/xml.m4 b/build/xml.m4
index 47a96e1..2793fea 100644
--- a/build/xml.m4
+++ b/build/xml.m4
@@ -92,7 +92,7 @@ AC_DEFUN([TS_CHECK_XML_LIBXML2], [
       fi
       if test -d "$libxml2_ldflags" ; then
         TS_ADDTO(LDFLAGS, [-L${libxml2_ldflags}])
-        TS_ADDTO(LIBTOOL_LINK_FLAGS, [-R${libxml2_ldflags}])
+        TS_ADDTO_RPATH(${libxml2_ldflags})
       fi
       TS_ADDTO(LIBS, -lxml2)
       enable_xml=yes
@@ -179,7 +179,7 @@ if test "$enable_expat" != "no"; then
   if test "$expat_base_dir" != "/usr"; then
     TS_ADDTO(CPPFLAGS, [-I${expat_include}])
     TS_ADDTO(LDFLAGS, [-L${expat_ldflags}])
-    TS_ADDTO(LIBTOOL_LINK_FLAGS, [-R${expat_ldflags}])
+    TS_ADDTO_RPATH(${expat_ldflags})
   fi
   AC_SEARCH_LIBS([XML_SetUserData], [expat], [expat_have_libs=1])
   if test "$expat_have_libs" != "0"; then

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb3d5f4e/build/zlib.m4
----------------------------------------------------------------------
diff --git a/build/zlib.m4 b/build/zlib.m4
index eac1bf5..d54afb1 100644
--- a/build/zlib.m4
+++ b/build/zlib.m4
@@ -82,7 +82,7 @@ if test "$enable_zlib" != "no"; then
   if test "$zlib_base_dir" != "/usr"; then
     TS_ADDTO(CPPFLAGS, [-I${zlib_include}])
     TS_ADDTO(LDFLAGS, [-L${zlib_ldflags}])
-    TS_ADDTO(LIBTOOL_LINK_FLAGS, [-rpath ${zlib_ldflags}])
+    TS_ADDTO_RPATH(${zlib_ldflags})
   fi
   AC_SEARCH_LIBS([compressBound], [z], [zlib_have_libs=1])
   if test "$zlib_have_libs" != "0"; then

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cb3d5f4e/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 889a149..22f8a59 100644
--- a/configure.ac
+++ b/configure.ac
@@ -667,6 +667,7 @@ AM_PATH_PYTHON([2.4], [
   :
 ])
 
+AC_ARG_VAR(RPATH, [path to be added to rpath])
 AC_ARG_VAR(SPHINXBUILD, [the sphinx-build documentation generator])
 AC_ARG_VAR(SPHINXOPTS, [additional sphinx-build options])
 AC_CHECK_PROG([SPHINXBUILD], [sphinx-build], [sphinx-build], [false])
@@ -1814,6 +1815,10 @@ AC_SUBST([SHARED_CXXFLAGS])
 AC_SUBST([SHARED_CXXLINKFLAGS])
 AC_SUBST([SHARED_LDFLAGS])
 
+AS_IF([test "x$RPATH" != "x"], [
+       TS_ADDTO_RPATH([$RPATH])
+])
+
 # -----------------------------------------------------------------------------
 # 6. OUTPUT FILES
 

Reply via email to