Fix build with external gmp library.
authorgwright@antiope.com <unknown>
Mon, 13 Aug 2007 12:42:11 +0000 (12:42 +0000)
committergwright@antiope.com <unknown>
Mon, 13 Aug 2007 12:42:11 +0000 (12:42 +0000)
ghc fails to build if you use an external gmp library. This is because
ghc requires the header file gmp.h, which used to be provided by the
internal gmp source code.  The file gmp.h is no longer part of the
gmp source code, but is generated as part of the build procedure.
If an external gmp is specified, the internal gmp is not build and the
gmp.h file never gets generated.

Of course, it was a bad idea anyway to use a header file from a potentially
different version of the library.

The patch sets HAVE_LIB_GMP if the gmp library is found during configuration
and conditionalizes including the library header file on it.

configure.ac
includes/Makefile
includes/Regs.h

index 929b640..b35c7e7 100644 (file)
@@ -1075,6 +1075,9 @@ dnl ** check whether this machine has gmp3 installed
 AC_CHECK_LIB(gmp,  __gmpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp,
   AC_CHECK_LIB(gmp3, __gmpz_fdiv_qr,  HaveLibGmp=YES; LibGmp=gmp3,
     HaveLibGmp=NO; LibGmp=not-installed))
 AC_CHECK_LIB(gmp,  __gmpz_fdiv_qr, HaveLibGmp=YES; LibGmp=gmp,
   AC_CHECK_LIB(gmp3, __gmpz_fdiv_qr,  HaveLibGmp=YES; LibGmp=gmp3,
     HaveLibGmp=NO; LibGmp=not-installed))
+  if test $HaveLibGmp = YES; then
+    AC_DEFINE([HAVE_LIB_GMP], [1], [Define to 1 if GMP library is installed.])
+  fi;
 AC_SUBST(HaveLibGmp)
 AC_SUBST(LibGmp)
 
 AC_SUBST(HaveLibGmp)
 AC_SUBST(LibGmp)
 
index e7292cd..2acf075 100644 (file)
@@ -27,7 +27,11 @@ ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
 SRC_CC_OPTS += -DTABLES_NEXT_TO_CODE
 endif
 
 SRC_CC_OPTS += -DTABLES_NEXT_TO_CODE
 endif
 
+ifeq "$(HaveLibGmp)" "YES"
+SRC_CC_OPTS += -I. -I../rts -I$(GMP_INCLUDE_DIRS)
+else
 SRC_CC_OPTS += -I. -I../rts -I../gmp/gmpbuild
 SRC_CC_OPTS += -I. -I../rts -I../gmp/gmpbuild
+endif
 
 ifneq "$(GhcWithSMP)" "YES"
 SRC_CC_OPTS += -DNOSMP
 
 ifneq "$(GhcWithSMP)" "YES"
 SRC_CC_OPTS += -DNOSMP
index 0bfde5b..6524c8f 100644 (file)
@@ -24,6 +24,8 @@
 
 #if defined(HAVE_FRAMEWORK_GMP)
 #include <GMP/gmp.h>
 
 #if defined(HAVE_FRAMEWORK_GMP)
 #include <GMP/gmp.h>
+#elif defined(HAVE_LIB_GMP)
+#include <gmp.h>
 #else
 #include "gmp.h" // Needs MP_INT definition 
 #endif
 #else
 #include "gmp.h" // Needs MP_INT definition 
 #endif