]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add --wrap linker option detection
authorOndřej Surý <ondrej@sury.org>
Thu, 14 Jun 2018 07:05:08 +0000 (09:05 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 20 Jun 2018 10:30:07 +0000 (06:30 -0400)
config.h.in
configure
configure.in

index e68e3ed1b7d69315c3b087b59be0304d9afe3b4a..686352be1b16abe3e8006a549566560f1e26cd96 100644 (file)
@@ -566,6 +566,9 @@ int sigwait(const unsigned int *set, int *sig);
 /* Define to allow building of objects for dlopen(). */
 #undef ISC_DLZ_DLOPEN
 
+/* define if the linker supports --wrap option */
+#undef LD_WRAP
+
 /* have __attribute__s used in librpz.h */
 #undef LIBRPZ_HAVE_ATTR
 
index f6a5b5e6e424a6639593b3b50227984e239e71f7..92a608c1cda73f5ebfada2e13508918fb6f55c3c 100755 (executable)
--- a/configure
+++ b/configure
@@ -673,6 +673,7 @@ UNITTESTS
 ATFLIBS
 ATFBIN
 ATFBUILD
+LD_WRAP_TESTS
 CMOCKA_LIBS
 CMOCKA_CFLAGS
 LIBIDN2_LIBS
@@ -22728,6 +22729,47 @@ esac
 
 
 
+#
+# Check for -Wl,--wrap= support
+#
+
+save_LDFLAGS=$LDFLAGS
+LDFLAGS="--wrap=printf"
+
+LD_WRAP_TESTS=false
+enable_ld_wrap=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker support for --wrap option" >&5
+$as_echo_n "checking for linker support for --wrap option... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+__wrap_printf("success"); return (0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  enable_ld_wrap=yes
+     LD_WRAP_TESTS=true
+
+$as_echo "#define LD_WRAP 1" >>confdefs.h
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+# AM_CONDITIONAL([LD_WRAP], [test $enable_ld_wrap = yes])
+
+
+LDFLAGS=$save_LDFLAGS
+
 #
 # Check whether to build Automated Test Framework unit tests
 #
index e0b8e87af93f25a028997d5eec03ce487eb332f9..7d5ed67eab1e47de8ba26253c34375024fe19247 100644 (file)
@@ -4579,6 +4579,28 @@ AS_CASE([$with_cmocka],
 AC_SUBST([CMOCKA_CFLAGS])
 AC_SUBST([CMOCKA_LIBS])
 
+#
+# Check for -Wl,--wrap= support
+#
+
+save_LDFLAGS=$LDFLAGS
+LDFLAGS="--wrap=printf"
+
+LD_WRAP_TESTS=false
+enable_ld_wrap=no
+AC_MSG_CHECKING([for linker support for --wrap option])
+AC_LINK_IFELSE(
+    [AC_LANG_PROGRAM([#include <stdio.h>], [__wrap_printf("success"); return (0);])],
+    [enable_ld_wrap=yes
+     LD_WRAP_TESTS=true
+     AC_DEFINE([LD_WRAP], [1], [define if the linker supports --wrap option])
+     AC_MSG_RESULT([yes])],
+    [AC_MSG_RESULT([no])])
+# AM_CONDITIONAL([LD_WRAP], [test $enable_ld_wrap = yes])
+AC_SUBST([LD_WRAP_TESTS])
+
+LDFLAGS=$save_LDFLAGS
+
 #
 # Check whether to build Automated Test Framework unit tests
 #