]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Restructure system PolarSSL detection
authorTiziano Müller <tm@dev-zero.ch>
Mon, 20 May 2013 13:32:02 +0000 (15:32 +0200)
committerTiziano Müller <tm@dev-zero.ch>
Mon, 22 Jul 2013 05:53:51 +0000 (07:53 +0200)
Based on the chapter "Automatic Dependencies with AC_ARG_WITH" of the
Autotools Mythbuster eBook, fix the system PolarSSL detection and
recognize both --with/without-system-polarssl properly. Furthermore,
set the HAVE_LIBPOLARSSL automake variable conditionally. Otherwise pdns will
use the included headers but link against the system polarssl resulting in
subtle breaks.

configure.ac

index 41789051538d5943b4ba0af63de7bc0ea99c8feb..3ee5cf72f37dbab6f371d6bd695939d553913a8d 100644 (file)
@@ -192,31 +192,39 @@ if test $enable_verbose_logging = yes; then AC_DEFINE(VERBOSELOG, 1, [If verbose
 fi
 AC_MSG_RESULT($enable_verbose_logging)
 
-AC_MSG_CHECKING(whether we will try to link in system PolarSSL)
 AC_ARG_WITH([system-polarssl],
- [AC_HELP_STRING([--without-system-polarssl], [do not use system PolarSSL])],
- [system_polarssl=$withval],
- [system_polarssl=yes])
-AC_MSG_RESULT($system_polarssl)
-AM_CONDITIONAL(HAVE_LIBPOLARSSL, false)
-if test x$system_polarssl = xyes; then
- AC_MSG_CHECKING([PolarSSL version >= 1.1])
- AC_COMPILE_IFELSE(
-    [AC_LANG_PROGRAM(
-        [[
-#include <polarssl/version.h>
-        ]],
-        [[
-#if POLARSSL_VERSION_NUMBER < 0x01010000
-#error invalid version
-#endif
-        ]]
-    )], [use_system_polarssl=yes], [use_system_polarssl=no])
- AC_MSG_RESULT($use_system_polarssl)
-fi
-if test x$use_system_polarssl = xyes; then
- AC_CHECK_LIB([polarssl], [sha1_hmac])
-fi
+ AS_HELP_STRING([--without-system-polarssl], [do not use system PolarSSL]))
+
+AS_IF([test "x$with_system_polarssl" != "xno"],
+      [AC_CHECK_LIB([polarssl], [sha1_hmac], [
+        AC_MSG_CHECKING([PolarSSL version >= 1.1])
+        AC_COMPILE_IFELSE(
+                          [AC_LANG_PROGRAM(
+                           [[
+                            #include <polarssl/version.h>
+                            ]],
+                            [[
+                             #if POLARSSL_VERSION_NUMBER < 0x01010000
+                             #error invalid version
+                             #endif
+                             ]]
+                            )],
+                            [have_system_polarssl=yes],
+                            [have_system_polarssl=no])
+        AC_MSG_RESULT($have_system_polarssl) ],
+        [have_system_polarssl=no])],
+      [have_system_polarssl=no]
+)
+
+AS_IF([test "x$have_system_polarssl" = "xyes"],
+      [AC_DEFINE(HAVE_LIBPOLARSSL, 1, [If linking against system polarssl])],
+      [AS_IF([test "x$with_system_polarssl" = "xyes"],
+             [AC_MSG_ERROR([use of system polarssl requested but not found])]
+            )] )
+
+AC_MSG_CHECKING(whether we will try to link in system PolarSSL)
+AC_MSG_RESULT($have_system_polarssl)
+AM_CONDITIONAL(HAVE_LIBPOLARSSL, test "x$have_system_polarssl" = "xyes")
 
 AC_MSG_CHECKING(whether we will be linking in Botan 1.10)
 AC_ARG_ENABLE(botan1.10,