From b1137d3beff5880e00bfbb30a2072779b10f95d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= <gruenich@dune-project.org>
Date: Sun, 11 Nov 2012 08:17:08 +0000
Subject: [PATCH] [gmp.m4] Add support for configure caching.

[[Imported from SVN: r7058]]
---
 m4/gmp.m4 | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/m4/gmp.m4 b/m4/gmp.m4
index 99d32c56c..f351019a7 100644
--- a/m4/gmp.m4
+++ b/m4/gmp.m4
@@ -30,15 +30,29 @@ AC_DEFUN([DUNE_PATH_GMP],[
   AS_IF([test x"$with_gmp" = x"no"], [
     AC_MSG_NOTICE([skipping check for GMP])
   ], [
-    AS_IF([test x"$with_gmp" = x || test x"$with_gmp" = xyes], [
-      for d in /usr /usr/local; do
-        AC_MSG_NOTICE([searching for GMP in $d...])
-        DUNE_CHECK_PATH_GMP($d)
-        AS_IF([test $HAVE_GMP = yes],[break])
-      done],[
-      DUNE_CHECK_PATH_GMP($with_gmp)
+    AC_CACHE_CHECK([for GMP], dune_cv_gmp_path, [
+      dune_cv_gmp_path=no
+      AS_IF([test x"$with_gmp" = x || test x"$with_gmp" = xyes], [
+        for d in /usr /usr/local; do
+          AC_MSG_NOTICE([searching for GMP in $d...])
+          DUNE_CHECK_PATH_GMP($d)
+          AS_IF([test $HAVE_GMP = yes],[
+            dune_cv_gmp_path=$d
+            break
+          ])
+        done],[
+        DUNE_CHECK_PATH_GMP($with_gmp)
+        AS_IF([test $HAVE_GMP = yes],[
+          dune_cv_gmp_path=$with_gmp
+        ])
+      ])
     ])
 
+    if test "x$dune_cv_gmp_path" != xno; then
+      HAVE_GMP=yes
+      GMP_CPPFLAGS="-I$dune_cv_gmp_path/include -DENABLE_GMP=1"
+      GMP_LIBS="-L$dune_cv_gmp_path/lib -lgmpxx -lgmp"
+    fi
   ])
 
   AS_IF([test $HAVE_GMP = yes],[
-- 
GitLab