From: Selva Nair <selva.n...@gmail.com>

- Also make tests that require --wrap option to be
  conditional on this support

Signed-off-by: Selva Nair <selva.n...@gmail.com>
---
 configure.ac                         | 26 ++++++++++++++++++++++++++
 tests/unit_tests/openvpn/Makefile.am |  6 +++++-
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 43487b0..0b7fea9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -582,6 +582,31 @@ AC_COMPILE_IFELSE(
        [AC_MSG_RESULT([no])]
 )
 
+saved_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS -Wl,--wrap=exit"
+AC_MSG_CHECKING([linker supports --wrap])
+AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+               [[
+                       void exit(int);
+                       void __real_exit(int);
+                       void __wrap_exit(int i) {
+                               __real_exit(i);
+                       }
+               ]],
+               [[
+                       exit(0);
+               ]]
+       )],
+       [
+               AC_MSG_RESULT([yes])
+               have_ld_wrap_support=yes
+               AC_DEFINE([HAVE_LD_WRAP_SUPPORT], [1], [Define to 1 if linker 
supports -Wl,--wrap option])
+       ],
+       [AC_MSG_RESULT([no])],
+)
+LDFLAGS="$saved_LDFLAGS"
+
 dnl We emulate signals in Windows
 AC_CHECK_DECLS(
        [SIGHUP],
@@ -1244,6 +1269,7 @@ AM_CONDITIONAL([GIT_CHECKOUT], [test "${GIT_CHECKOUT}" = 
"yes"])
 AM_CONDITIONAL([ENABLE_PLUGIN_AUTH_PAM], [test "${enable_plugin_auth_pam}" = 
"yes"])
 AM_CONDITIONAL([ENABLE_PLUGIN_DOWN_ROOT], [test "${enable_plugin_down_root}" = 
"yes"])
 AM_CONDITIONAL([ENABLE_CRYPTO], [test "${enable_crypto}" = "yes"])
+AM_CONDITIONAL([HAVE_LD_WRAP_SUPPORT], [test "${have_ld_wrap_support}" = 
"yes"])
 
 plugindir="${with_plugindir}"
 sampledir="\$(docdir)/sample"
diff --git a/tests/unit_tests/openvpn/Makefile.am 
b/tests/unit_tests/openvpn/Makefile.am
index fafe6b2..b902b20 100644
--- a/tests/unit_tests/openvpn/Makefile.am
+++ b/tests/unit_tests/openvpn/Makefile.am
@@ -1,6 +1,10 @@
 AUTOMAKE_OPTIONS = foreign
 
-check_PROGRAMS = argv_testdriver buffer_testdriver
+check_PROGRAMS=
+
+if HAVE_LD_WRAP_SUPPORT
+check_PROGRAMS += argv_testdriver buffer_testdriver
+endif
 
 if ENABLE_CRYPTO
 check_PROGRAMS += tls_crypt_testdriver
-- 
2.1.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to