]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2356] introduce the helper m4 macro to identify -R variant linker options
authorJINMEI Tatuya <jinmei@isc.org>
Wed, 31 Oct 2012 22:31:29 +0000 (15:31 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Wed, 31 Oct 2012 22:31:29 +0000 (15:31 -0700)
extracted from the top-level configure.ac.

examples/configure.ac
examples/m4/ax_isc_bind10.m4
examples/m4/ax_isc_rpath.m4 [new file with mode: 0644]

index 937968760d4d881d81f01b3cc7df2ac6d23067c0..fe806fd9a76d43f016ff12317359a5b137fc9b98 100644 (file)
@@ -13,6 +13,9 @@ AC_LANG([C++])
 
 # Checks for BIND 10 headers and libraries
 AX_ISC_BIND10
+if test "x$BIND10_RPATH" != "x"; then
+   LDFLAGS="$LDFLAGS $BIND10_RPATH"
+fi
 
 # For the example host program, we require the BIND 10 DNS library
 if test "x$BIND10_DNS_LIB" = "x"; then
index 7df18c5ca949915ebc121d41c03d0c53072e23f2..3607c913cb1347c22635deb2ce9ab9b4db934084 100644 (file)
@@ -1,4 +1,4 @@
-dnl @synopsis AX_BIND10
+dnl @synopsis AX_ISC_BIND10
 dnl
 dnl @summary figure out how to build C++ programs using ISC BIND 10 libraries
 dnl
@@ -23,6 +23,7 @@ dnl BIND10_xxx_LIB is defined.
 
 AC_DEFUN([AX_ISC_BIND10], [
 AC_REQUIRE([AX_BOOST_INCLUDE])
+AC_REQUIRE([AX_ISC_RPATH])
 AC_LANG_SAVE
 AC_LANG([C++])
 
@@ -82,7 +83,11 @@ do
 #include <util/buffer.h>
 ],[
 isc::util::OutputBuffer buffer(0);
-], [BIND10_LDFLAGS="-L${d}"])
+], [BIND10_LDFLAGS="-L${d}"
+    if test "x$ISC_RPATH_FLAG" != "x"; then
+       BIND10_RPATH="-R${d}"
+    fi
+    ])
   if test "x$BIND10_LDFLAGS" != "x"; then
      break
   fi
diff --git a/examples/m4/ax_isc_rpath.m4 b/examples/m4/ax_isc_rpath.m4
new file mode 100644 (file)
index 0000000..253ecdb
--- /dev/null
@@ -0,0 +1,33 @@
+dnl @synopsis AX_ISC_RPATH
+dnl
+dnl @summary figure out whether and which "rpath" linker option is available
+dnl
+dnl This macro checks if the linker supports an option to embed a path
+dnl to a runtime library (often installed in an uncommon place), such as
+dnl gcc's -rpath option.  If found, it sets the ISC_RPATH_FLAG variable to
+dnl the found option flag.  The main configure.ac can use it as follows:
+dnl if test "x$ISC_RPATH_FLAG" != "x"; then
+dnl     LDFLAGS="$LDFLAGS ${ISC_RPATH_FLAG}/usr/local/lib/some_library"
+dnl fi
+
+AC_DEFUN([AX_ISC_RPATH], [
+
+# check -R and -Wl,-R rather than gcc specific -rpath to be as portable
+# as possible.
+AC_MSG_CHECKING([whether -R flag is available in linker])
+LDFLAGS_SAVED="$LDFLAGS"
+LDFLAGS="$LDFLAGS -R/usr/lib"
+AC_TRY_LINK([],[],
+    [ AC_MSG_RESULT(yes)
+        ISC_RPATH_FLAG=-R
+    ],[ AC_MSG_RESULT(no)
+        AC_MSG_CHECKING([whether -Wl,-R flag is available in linker])
+        LDFLAGS="$LDFLAGS_SAVED -Wl,-R"
+        AC_TRY_LINK([], [],
+            [ AC_MSG_RESULT(yes)
+                ISC_RPATH_FLAG=-Wl,-R
+            ],[ AC_MSG_RESULT(no) ])
+    ])
+LDFLAGS=$LDFLAGS_SAVED
+
+])dnl AX_ISC_RPATH