Parcourir la source

[3421] Oops, examples/m4/ax_isc_rpath.m4 was used, moving to m4macros

Tomek Mrugalski il y a 10 ans
Parent
commit
2056325369
4 fichiers modifiés avec 63 ajouts et 4 suppressions
  1. 1 1
      Makefile.am
  2. 1 2
      configure.ac
  3. 1 1
      m4macros/Makefile.am
  4. 60 0
      m4macros/ax_isc_rpath.m4

+ 1 - 1
Makefile.am

@@ -1,4 +1,4 @@
-ACLOCAL_AMFLAGS = -I m4macros -I examples/m4 ${ACLOCAL_FLAGS}
+ACLOCAL_AMFLAGS = -I m4macros ${ACLOCAL_FLAGS}
 # ^^^^^^^^ This has to be the first line and cannot come later in this
 # ^^^^^^^^ This has to be the first line and cannot come later in this
 # Makefile.am due to some bork in some versions of autotools.
 # Makefile.am due to some bork in some versions of autotools.
 
 

+ 1 - 2
configure.ac

@@ -101,8 +101,7 @@ fi
 
 
 # Linker options
 # Linker options
 
 
-# check -R, "-Wl,-R" or -rpath (we share the AX function defined in
-#  examples/m4)
+# check -R, "-Wl,-R" or -rpath
 AX_ISC_RPATH
 AX_ISC_RPATH
 
 
 # Compiler dependent settings: define some mandatory CXXFLAGS here.
 # Compiler dependent settings: define some mandatory CXXFLAGS here.

+ 1 - 1
m4macros/Makefile.am

@@ -1 +1 @@
-EXTRA_DIST  = ax_boost_for_kea.m4
+EXTRA_DIST  = ax_boost_for_kea.m4 ax_isc_rpath.m4

+ 60 - 0
m4macros/ax_isc_rpath.m4

@@ -0,0 +1,60 @@
+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 the
+dnl commonly used -R 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
+dnl
+dnl If you pass --disable-rpath to configure, ISC_RPATH_FLAG is not set
+
+AC_DEFUN([AX_ISC_RPATH], [
+
+AC_ARG_ENABLE(rpath,
+    [AC_HELP_STRING([--disable-rpath], [don't hardcode library path into binaries])],
+    rpath=$enableval, rpath=yes)
+
+if test x$rpath != xno; then
+    # We'll tweak both CXXFLAGS and CCFLAGS so this function will work
+    # whichever language is used in the main script.  Note also that it's not
+    #LDFLAGS; technically this is a linker flag, but we've noticed $LDFLAGS
+    # can be placed where the compiler could interpret it as a compiler
+    # option, leading to subtle failure mode.  So, in the check below using
+    # the compiler flag is safer (in the actual Makefiles the flag should be
+    # set in LDFLAGS).
+    CXXFLAGS_SAVED="$CXXFLAGS"
+    CXXFLAGS="$CXXFLAGS -Wl,-R/usr/lib"
+    CCFLAGS_SAVED="$CCFLAGS"
+    CCFLAGS="$CCFLAGS -Wl,-R/usr/lib"
+
+    # check -Wl,-R and -R rather than gcc specific -rpath to be as portable
+    # as possible.  -Wl,-R seems to be safer, so we try it first.  In some
+    # cases -R is not actually recognized but AC_TRY_LINK doesn't fail due to
+    # that.
+    AC_MSG_CHECKING([whether -Wl,-R flag is available in linker])
+    AC_TRY_LINK([],[],
+        [ AC_MSG_RESULT(yes)
+            ISC_RPATH_FLAG=-Wl,-R
+        ],[ AC_MSG_RESULT(no)
+            AC_MSG_CHECKING([whether -R flag is available in linker])
+
+	    # Apple clang 5.1 is now considers unknown parameters passed to linker (ld) as errors.
+	    # However, the same unknown parameters passed to compiler (g++ ) are merely threated
+	    # as warnings. To make sure that we pick those up, is to use -Werror.
+            CXXFLAGS="$CXXFLAGS_SAVED -R/usr/lib"
+            CCFLAGS="$CCFLAGS_SAVED -R/usr/lib"
+        AC_TRY_LINK([], [],
+            [ AC_MSG_RESULT([yes; note that -R is more sensitive about the position in option arguments])
+                ISC_RPATH_FLAG=-R
+            ],[ AC_MSG_RESULT(no) ])
+        ])
+
+    CXXFLAGS=$CXXFLAGS_SAVED
+    CCFLAGS=$CCFLAGS_SAVED
+fi
+
+])dnl AX_ISC_RPATH