[commit: ghc] master: Persist build-time GMP ver to `HsIntegerGmp.h` (6d1c8ec)

git at git.haskell.org git at git.haskell.org
Sun Nov 23 21:42:04 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/6d1c8ec79adf566d57d2c35aac8ff6635412d108/ghc

>---------------------------------------------------------------

commit 6d1c8ec79adf566d57d2c35aac8ff6635412d108
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Sun Nov 23 12:21:51 2014 +0100

    Persist build-time GMP ver to `HsIntegerGmp.h`
    
    This creates the additional macro definitions in `HsIntegerGmp.h` which
    are useful for 3rd party `integer-gmp`-addon libraries.
    
    Here's an example for the definitions created for the in-tree GMP:
    
      #define GHC_GMP_INTREE     1
      #define GHC_GMP_VERSION_MJ 5
      #define GHC_GMP_VERSION_MI 0
      #define GHC_GMP_VERSION_PL 4
      #define GHC_GMP_VERSION   (5 * 10000 + 0 * 100 + 4)
    
    And here's an example for a system-installed GMP:
    
      #define GHC_GMP_INTREE     0
      #define GHC_GMP_VERSION_MJ 6
      #define GHC_GMP_VERSION_MI 0
      #define GHC_GMP_VERSION_PL 0
      #define GHC_GMP_VERSION   (6 * 10000 + 0 * 100 + 0)
    
    Part of #9281
    
    Reviewed By: ekmett (via D522)


>---------------------------------------------------------------

6d1c8ec79adf566d57d2c35aac8ff6635412d108
 libraries/integer-gmp2/configure.ac              | 34 ++++++++++++++++++++++--
 libraries/integer-gmp2/include/HsIntegerGmp.h.in | 10 +++++++
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/libraries/integer-gmp2/configure.ac b/libraries/integer-gmp2/configure.ac
index 0794d96..4a9e539 100644
--- a/libraries/integer-gmp2/configure.ac
+++ b/libraries/integer-gmp2/configure.ac
@@ -1,4 +1,5 @@
-AC_INIT([Haskell integer (GMP)], [0.1], [libraries at haskell.org], [integer])
+AC_INIT([Haskell integer (GMP)], [1.0], [libraries at haskell.org], [integer])
+AC_PREREQ(2.52)
 
 # Safety check: Ensure that we are in the correct source directory.
 AC_CONFIG_SRCDIR([cbits/wrappers.c])
@@ -60,11 +61,36 @@ then
         LOOK_FOR_GMP_FRAMEWORK
     fi
 fi
+
+AC_MSG_CHECKING([whether to use in-tree GMP])
 if test "$HaveFrameworkGMP" = "YES" || test "$HaveLibGmp" = "YES"
 then
+    AC_MSG_RESULT([no])
+    UseIntreeGmp=0
     AC_CHECK_HEADER([gmp.h], , [AC_MSG_ERROR([Cannot find gmp.h])])
+
+    AC_MSG_CHECKING([GMP version])
+    AC_COMPUTE_INT(GhcGmpVerMj, __GNU_MP_VERSION, [#include <gmp.h>],
+        AC_MSG_ERROR([Unable to get value of __GNU_MP_VERSION]))
+    AC_COMPUTE_INT(GhcGmpVerMi, __GNU_MP_VERSION_MINOR, [#include <gmp.h>],
+        AC_MSG_ERROR([Unable to get value of __GNU_MP_VERSION_MINOR]))
+    AC_COMPUTE_INT(GhcGmpVerPl, __GNU_MP_VERSION_PATCHLEVEL, [#include <gmp.h>],
+        AC_MSG_ERROR([Unable to get value of __GNU_MP_VERSION_PATCHLEVEL]))
+    AC_MSG_RESULT([$GhcGmpVerMJ.$GhcGmpVerMI.$GhcGmpVerPL])
+
+else
+    AC_MSG_RESULT([yes])
+    UseIntreeGmp=1
+    HaveSecurePowm=1
+
+    AC_MSG_CHECKING([GMP version])
+    GhcGmpVerMj=5
+    GhcGmpVerMi=0
+    GhcGmpVerPl=4
+    AC_MSG_RESULT([$GhcGmpVerMj.$GhcGmpVerMi.$GhcGmpVerPl])
 fi
 
+
 dnl--------------------------------------------------------------------
 dnl * Make sure we got some form of gmp
 dnl--------------------------------------------------------------------
@@ -76,11 +102,15 @@ AC_SUBST(GMP_FRAMEWORK)
 AC_SUBST(HaveLibGmp)
 AC_SUBST(HaveFrameworkGMP)
 AC_SUBST(HaveSecurePowm)
+AC_SUBST(UseIntreeGmp)
+AC_SUBST(GhcGmpVerMj)
+AC_SUBST(GhcGmpVerMi)
+AC_SUBST(GhcGmpVerPl)
 
 AC_CONFIG_FILES([integer-gmp.buildinfo gmp/config.mk include/HsIntegerGmp.h])
 
 dnl--------------------------------------------------------------------
-dnl * Generate the header cbits/GmpDerivedConstants.h
+dnl * Generate output files
 dnl--------------------------------------------------------------------
 
 AC_OUTPUT
diff --git a/libraries/integer-gmp2/include/HsIntegerGmp.h.in b/libraries/integer-gmp2/include/HsIntegerGmp.h.in
index 11c6467..0637ba3 100644
--- a/libraries/integer-gmp2/include/HsIntegerGmp.h.in
+++ b/libraries/integer-gmp2/include/HsIntegerGmp.h.in
@@ -3,4 +3,14 @@
 
 #define HAVE_SECURE_POWM @HaveSecurePowm@
 
+/* Whether GMP is embedded into integer-gmp */
+#define GHC_GMP_INTREE     @UseIntreeGmp@
+
+/* The following values denote the GMP version used during GHC build-time */
+#define GHC_GMP_VERSION_MJ @GhcGmpVerMj@
+#define GHC_GMP_VERSION_MI @GhcGmpVerMi@
+#define GHC_GMP_VERSION_PL @GhcGmpVerPl@
+#define GHC_GMP_VERSION \
+    (@GhcGmpVerMj@ * 10000 + @GhcGmpVerMi@ * 100 + @GhcGmpVerPl@)
+
 #endif /* _HS_INTEGER_GMP_H_ */



More information about the ghc-commits mailing list