From 360dfd98a06a6e75bf91f376b8c9722322313136 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Fri, 11 Apr 2014 16:06:25 +0200
Subject: [PATCH] Skip GMP tests if public key support is disabled.

---
 ChangeLog    |  2 ++
 configure.ac | 50 +++++++++++++++++++++++++++-----------------------
 2 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 831a3280..8ec42181 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2014-04-11  Niels Möller  <nisse@lysator.liu.se>
 
+	* configure.ac: Skip GMP tests if public key support is disabled.
+
 	* eax.c (block16_xor): Fixed bug effecting 32-bit platforms.
 
 	* Makefile.in (DISTFILES): Deleted memxor.c, already included via
diff --git a/configure.ac b/configure.ac
index 02606899..81c9c8d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -673,31 +673,35 @@ if test "x$nettle_cv_fcntl_locking" = "xyes" ; then
 fi
 
 # Checks for libraries
-AC_CHECK_LIB(gmp, __gmpz_getlimbn,,
-    [AC_MSG_WARN(
-[GNU MP not found, or not 3.1 or up, see http://gmplib.org/.
-Support for public key algorithms will be unavailable.])]
-    enable_public_key=no)
-
-# Add -R flags needed to run programs linked with gmp
-LSH_RPATH_FIX
-
-# Check for gmp limb size
-nettle_cv_gmp_numb_bits=0
-if test "$enable_public_key" = yes; then
-  AC_MSG_CHECKING([for GMP limb size])
-  AC_COMPUTE_INT(nettle_cv_gmp_numb_bits, [GMP_NUMB_BITS],
-      [#include <gmp.h>],
-      [AC_MSG_FAILURE([cannot find value of GMP_NUMB_BITS])])
-
-  AC_MSG_RESULT([$nettle_cv_gmp_numb_bits bits])
+if test "x$enable_public_key" = "xyes" ; then
+  AC_CHECK_LIB(gmp, __gmpz_getlimbn,,
+      [AC_MSG_WARN(
+  [GNU MP not found, or not 3.1 or up, see http://gmplib.org/.
+  Support for public key algorithms will be unavailable.])]
+      enable_public_key=no)
+
+  # Add -R flags needed to run programs linked with gmp
+  LSH_RPATH_FIX
 fi
 
-GMP_NUMB_BITS="$nettle_cv_gmp_numb_bits"
-AC_SUBST([GMP_NUMB_BITS])
-
-AH_TEMPLATE([HAVE_MPZ_POWM_SEC], [Define if mpz_powm_sec is available (appeared in GMP-5)])
-AC_CHECK_FUNC(__gmpz_powm_sec, [AC_DEFINE(HAVE_MPZ_POWM_SEC)])
+if test "x$enable_public_key" = "xyes" ; then
+  # Check for gmp limb size
+  nettle_cv_gmp_numb_bits=0
+  if test "$enable_public_key" = yes; then
+    AC_MSG_CHECKING([for GMP limb size])
+    AC_COMPUTE_INT(nettle_cv_gmp_numb_bits, [GMP_NUMB_BITS],
+        [#include <gmp.h>],
+        [AC_MSG_FAILURE([cannot find value of GMP_NUMB_BITS])])
+  
+    AC_MSG_RESULT([$nettle_cv_gmp_numb_bits bits])
+  fi
+  
+  GMP_NUMB_BITS="$nettle_cv_gmp_numb_bits"
+  AC_SUBST([GMP_NUMB_BITS])
+  
+  AH_TEMPLATE([HAVE_MPZ_POWM_SEC], [Define if mpz_powm_sec is available (appeared in GMP-5)])
+  AC_CHECK_FUNC(__gmpz_powm_sec, [AC_DEFINE(HAVE_MPZ_POWM_SEC)])
+fi
 
 AH_TEMPLATE([WITH_HOGWEED], [Defined if public key features are enabled])
 
-- 
GitLab