This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] Configure support for GMP


On Thursday 31 July 2003 9:41 pm, Joseph S. Myers wrote:
> On Thu, 31 Jul 2003, Paul Brook wrote:
> > 	* fortran/config-lang.in: Set need_gmp.
>
> The new config-lang.in variable should be documented in sourcebuild.texi,
> where the config-lang.in interface is documented.

Updated patch attached which addresses these and other issues.

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.
	(al_need_gmp): Set from config-lang.in.
	* fortran/Make-lang.in: Use GMPLIBS.
	* fortran/config-lang.in: Set need_gmp.
	* sourcebuild.texi: Document need_gmp.
diff -urpxCVS 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 @@ OUTPUT_OPTION = @OUTPUT_OPTION@
 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 @@ BUILD_VARRAY = $(BUILD_PREFIX)varray.o
 # 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 -urpxCVS 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 22:31:06.000000000 +0100
@@ -2715,6 +2715,7 @@ all_gtfiles="$target_gtfiles"
 # Files for gengtype with language
 all_gtfiles_files_langs=
 all_gtfiles_files_files=
+all_need_gmp="no"
 
 # Add the language fragments.
 # Languages are added via two mechanisms.  Some information must be
@@ -2736,6 +2737,7 @@ do
 		stagestuff=
 		outputs=
 		gtfiles=
+		need_gmp=
 		. ${srcdir}/$s/config-lang.in
 		if test "x$language" = x
 		then
@@ -2763,6 +2765,10 @@ do
                          all_gtfiles_files_files="$all_gtfiles_files_files ${f} "
                      fi
                 done
+		if test "x$need_gmp" = xyes
+		then
+			all_need_gmp="yes"
+		fi
 	fi
 done
 
@@ -2867,6 +2873,54 @@ fi
 AC_SUBST(gcc_tooldir)
 AC_SUBST(dollar)
 
+gmplibs=
+gmpinc=
+# Only check for GMP if one of the frontends needs it.
+if test "x$all_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 && test -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 && test -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 -urpxCVS clean/tree-ssa/gcc/doc/sourcebuild.texi gcc/gcc/doc/sourcebuild.texi
--- clean/tree-ssa/gcc/doc/sourcebuild.texi	2003-07-26 17:01:08.000000000 +0100
+++ gcc/gcc/doc/sourcebuild.texi	2003-07-31 21:59:43.000000000 +0100
@@ -670,6 +670,10 @@ If defined, a space-separated list of fi
 gengtype.c to generate the garbage collection tables and routines for
 this language.  This excludes the files that are common to all front
 ends. @xref{Type Information}.
+@item need_gmp
+If defined  to @samp{yes}, this frontend requires the GMP library.
+Enables configure tests for GMP, which set @code{GMPLIBS} and
+@code{GMPINC} appropriately.
 
 @end table
 
diff -urpxCVS 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 @@ F95_ADDITIONAL_OBJS = \
 	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 -urpxCVS 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 @@ target_libs=target-libgfortran
 
 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
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]