From 1979bd2f15b21383bd47b1423916e8534bd7136a Mon Sep 17 00:00:00 2001 From: danmc Date: Thu, 12 Oct 2006 02:43:08 +0000 Subject: [PATCH] Add a --enable-rpath option which is off by default. When specified this adds the correct rpath flag for the X11 libraries. --- configure.in | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/configure.in b/configure.in index c12b6c778..93848b427 100644 --- a/configure.in +++ b/configure.in @@ -287,6 +287,61 @@ AC_PATH_X AC_PATH_XTRA +dnl Check if the user wants to use the appropriate rpath commands to compile in +dnl the shared library path for the X libraries. This is off by default since +dnl that is how it has been historically. Using --enable-rpath will turn this on + +_use_rpath=no +AC_MSG_CHECKING([if hardcoding of the X11 runtime library path is desired]) +AC_ARG_ENABLE([rpath], + [ --enable-rpath Enable hardcoding the X11 runtime library path [default=disabled]], + [ + if test "X$enable_rpath" = "Xno" ; then + AC_MSG_RESULT([no]) + _use_rpath=no + else + AC_MSG_RESULT([yes]) + _use_rpath=yes + fi + ], + [ + AC_MSG_RESULT([no]) + _use_rpath=no + ] +) + +if test "X$_use_rpath" = "Xyes" ; then + # Try to figure out if we need -Rpath for finding X11 libs + # at runtime. Why autoconf doesn't already do this, I don't + # know... + xlib_path="" + for p in $X_LDFLAGS ; do + case $p in + -L*) + xlib_path="$xlib_path $p" + ;; + esac + done + + _save_LIBS=$LIBS + LIBS="$LIBS $X_LDFLAGS" + rpath="" + for fl in "-Wl,-rpath " "-Wl,--rpath " "-rpath " "--rpath " "-Wl,-R" "-R" "-R " ; do + xlib_rpath=`echo $xlib_path | sed "s/-L/$fl/g"` + LIBS="$_save_LIBS $X_LIBS $xlib_rpath" + AC_MSG_CHECKING([if the compiler accepts ${fl}path for runtime libraries]) + AC_LINK_IFELSE([AC_LANG_PROGRAM()], + AC_MSG_RESULT([yes]) + rpath=$fl, + AC_MSG_RESULT([no])) + test -n "$rpath" && break + done + if test -n "$rpath"; then + X_LDFLAGS="$X_LDFLAGS $xlib_rpath" + fi + LIBS=$_save_LIBS +fi + dnl Checks for X libraries - if X11 wasn't found then don't make following dnl tests and compile without X11 support - otherwise, check if the following dnl libraries are present (error if they are not)