This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Conpigure support for GMP
- From: Paul Brook <paul at nowt dot org>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: "gcc-g95 List" <gcc-g95-devel at lists dot sourceforge dot net>
- Date: Thu, 31 Jul 2003 21:10:41 +0100
- Subject: [tree-ssa] Conpigure support for GMP
The attached patch adds configure support for the GMP library, as required
by g95.
It's cobbled togeter from varioous bits i found lying about, but it seems to
work. Anyone care to test or pass judgement?
Tested with and without GMP installed on x86 linux.
Paul
2003-07-31 Paul Brook <paul@nowt.org>
* Makefile.in (GMPINC): Set and use.
(GMPLIBS): Set it.
* configure.in: Add test and switches for the GMP library.
* fortran/Make-lang.in: Use GMPLIBS.
* fortran/config-lang.in: Set need_gmp.
diff -urxCVS clean/tree-ssa/gcc/Makefile.in gcc/gcc/Makefile.in
--- clean/tree-ssa/gcc/Makefile.in 2003-07-31 19:54:26.000000000 +0100
+++ gcc/gcc/Makefile.in 2003-07-31 20:21:50.000000000 +0100
@@ -261,6 +261,10 @@
ZLIB = @zlibdir@ -lz
ZLIBINC = @zlibinc@
+# This is where to find the GMP library
+GMPLIBS = @gmplibs@
+GMPINC = @gmpinc@
+
BANSHEELIB = @BANSHEELIB@
BANSHEEINC = @BANSHEEINC@
# Substitution type for target's getgroups 2nd arg.
@@ -748,7 +752,7 @@
# libintl.h will be found in ../intl if we are using the included libintl.
INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
-I$(srcdir)/config -I$(srcdir)/../include @INCINTL@ \
- $(BANSHEEINC)
+ $(BANSHEEINC) $(GMPINC)
# Always use -I$(srcdir)/config when compiling.
.c.o:
diff -urxCVS clean/tree-ssa/gcc/configure.in gcc/gcc/configure.in
--- clean/tree-ssa/gcc/configure.in 2003-07-25 17:49:03.000000000 +0100
+++ gcc/gcc/configure.in 2003-07-31 20:30:35.000000000 +0100
@@ -2867,6 +2867,52 @@
AC_SUBST(gcc_tooldir)
AC_SUBST(dollar)
+# Only check for GMP if one of the frontends needs it.
+if test "x$need_gmp" = xyes; then
+ # Specify a location for gmp
+ AC_ARG_WITH(gmp-dir, [ --with-gmp-dir=PATH Specify source directory for GMP library])
+
+ if test "x$with_gmp_dir" != x -a -d "$with_gmp_dir"; then
+ gmplibs="$with_gmp_dir/.libs/libgmp.a"
+ gmpinc="-I$with_gmp_dir"
+ fi
+
+ AC_ARG_WITH(gmp, [ --with-gmp=PATH Specify directory for installed GMP library])
+
+ if test "x$with_gmp" != x -a -d "$with_gmp"; then
+ gmplibs="-L$with_gmp/lib -lgmp"
+ gmpinc="-I$with_gmp/include"
+ fi
+
+ # Use system gmp if nothing else specified
+ if test "x$gmplibs" = x; then
+ gmplibs="-lgmp"
+ fi
+
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $gmpinc"
+ # Check GMP actually works
+ AC_MSG_CHECKING([for correct version of gmp.h])
+ AC_TRY_COMPILE([#include "gmp.h"],[
+#if __GNU_MP_VERSION < 3
+ choke me
+#endif
+], [AC_MSG_RESULT([yes])],
+ [AC_MSG_ERROR([gmp version 3.0 or later is required])])
+
+ AC_MSG_CHECKING([for mpf_init in -lgmp])
+
+ saved_LIBS="$LIBS"
+ LIBS="$LIBS $gmplibs"
+ AC_TRY_LINK([#include <gmp.h>], [mpf_t n; mpf_init(n);],
+ [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([could not link with libgmp])])
+ LIBS="$saved_LIBS"
+ CFLAGS="$saved_CFLAGS"
+fi
+
+AC_SUBST(gmplibs)
+AC_SUBST(gmpinc)
+
# Find a directory in which to install a shared libgcc.
AC_ARG_ENABLE(version-specific-runtime-libs,
diff -urxCVS clean/tree-ssa/gcc/fortran/Make-lang.in gcc/gcc/fortran/Make-lang.in
--- clean/tree-ssa/gcc/fortran/Make-lang.in 2003-07-27 15:24:00.000000000 +0100
+++ gcc/gcc/fortran/Make-lang.in 2003-07-29 23:16:18.000000000 +0100
@@ -86,7 +86,7 @@
tree-alias-common.o tree-alias-type.o gimplify.o
# G95 uses GMP for its internal arithmetics.
-F95_LIBS = $(LIBS) -lgmp
+F95_LIBS = $(GMPLIBS) $(LIBS)
#
# Define the names for selecting gfortran in LANGUAGES.
diff -urxCVS clean/tree-ssa/gcc/fortran/config-lang.in gcc/gcc/fortran/config-lang.in
--- clean/tree-ssa/gcc/fortran/config-lang.in 2003-07-24 22:50:18.000000000 +0100
+++ gcc/gcc/fortran/config-lang.in 2003-07-30 22:22:43.000000000 +0100
@@ -16,5 +16,7 @@
gtfiles="\$(srcdir)/fortran/f95-lang.c \$(srcdir)/fortran/trans-decl.c \$(srcdir)/fortran/trans-intrinsic.c \$(srcdir)/fortran/trans-io.c \$(srcdir)/fortran/trans-types.c \$(srcdir)/fortran/trans-types.h \$(srcdir)/fortran/trans.h \$(srcdir)/fortran/trans-const.h"
+need_gmp="yes"
+
#outputs=g95/Makefile