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]

RFA/RFC: Adding support for gmp and mpfr sources in the build tree


Hi Guys,

  Would anyone care to comment on, or possibly even approve the
  attached patch ?  It adds support for the sources for the GMP and
  MPFR libraries being present at the top level in the source tree.
  It does not actually import these sources, nor am I suggesting that
  this should be done.  But in a combined source tree with say gcc,
  binutils and gdb sources it can also be very helpful to have these
  two libraries present.  In this way there would be no dependency
  upon (up-to-date versions of) the libraries being installed on the
  build machine.

  There are two points about the patch which I think might make it
  unacceptable.  The first is that if the local sources are being
  used, the configure test to check the version numbers in the gmp and
  mpfr headers is disabled.  This is because at configure time the
  gmp.h header file is not available (it has not been built yet) and
  my assumption is that if you are using local sources, you will have
  already made sure that you have obtained the latest versions.

  The other point is that I had to apply a patch to the configure file
  in the GMP sources (also attached, but not yet submitted to the GMP
  project).  The reason for this is that the top level gcc Makefile
  will always include a "--target=..." switch when configuring in the
  GMP sources, even though it is creating a build tool and not a
  target tool.  (I could find no clean way to disable this).  For
  cross compilers however the GMP configure however will complain
  that:
  
    configure: error: --target is not appropriate for GMP

  I tried adding a second "--target=..." switch to the GMP configure
  command line to override the earlier one and reset the target back
  to the build machine, but this fails with:

    configure: error: `target_alias' has changed since the previous run:

  So instead I invented a new configure switch
  "--enable-target={yes|no}" which if set to "no", tells the GMP
  configure script to ignore any "--target=..." switch on its command
  line.  Not a very clean solution, but the best that I could come up
  with.

  So, what do people think ?  OK for inclusion or a bit too dirty ?

Cheers
  Nick

<toplevel>/ChangeLog
2006-11-21  Nick Clifton  <nickc@redhat.com>

	* Makefile.def (build_modules): Add gmp and mpfr.
	(all-gcc): Add dependency on gmp and mpfr.
	* Makefile.in: Regenerate.
	* configure.in (build-tools): Add gmp and mpfr.
	Add code to detect gmp and mpfr sources in the source tree and use
	them if no explicit gmp/mpfr installations have been specified.
	* configure: Regenerate.

gmp/ChangeLog
2006-11-21  Nick Clifton  <nickc@redhat.com>

	* configure.in: Add --enable-target switch.  If --enable-target=no
	is passed on the configure command line then ignore the --target
	configure switch.

Index: Makefile.def
===================================================================
--- Makefile.def	(revision 119043)
+++ Makefile.def	(working copy)
@@ -30,6 +30,8 @@ build_modules= { module= byacc; };
 build_modules= { module= flex; };
 build_modules= { module= m4; };
 build_modules= { module= texinfo; };
+build_modules= { module= gmp; extra_configure_flags="--enable-target=no"; };
+build_modules= { module= mpfr; extra_configure_flags= '--with-gmp-build=$${r}/$(BUILD_SUBDIR)/gmp'; };
 build_modules= { module= fixincludes;
 		 extra_configure_args='--target=$(target)'; };
 
@@ -285,6 +287,8 @@ dependencies = { module=all-gcc; on=all-
 dependencies = { module=all-gcc; on=all-libdecnumber; hard=true; };
 dependencies = { module=all-gcc; on=all-libiberty; };
 dependencies = { module=all-gcc; on=all-fixincludes; };
+dependencies = { module=all-gcc; on=all-build-gmp; hard=true; };
+dependencies = { module=all-gcc; on=all-build-mpfr; hard=true; };
 dependencies = { module=install-gcc ; on=install-fixincludes; };
 
 dependencies = { module=configure-libcpp; on=configure-libiberty; hard=true; };
Index: configure.in
===================================================================
--- configure.in	(revision 119043)
+++ configure.in	(working copy)
@@ -120,6 +120,7 @@ build_libs="build-libiberty"
 
 # these tools are built for the build environment
 build_tools="build-texinfo build-byacc build-flex build-bison build-m4 build-fixincludes"
+build_tools="${build_tools} build-mpfr build-gmp"
 
 # these libraries are used by various programs built for the host environment
 #
@@ -1055,6 +1056,8 @@ ACX_PROG_CMP_IGNORE_INITIAL
 gmplibs=
 gmpinc=
 have_gmp=yes
+test_gmp_version=yes
+orig_gmplibs=
 # Specify a location for mpfr
 # check for this first so it ends up on the link line before gmp.
 AC_ARG_WITH(mpfr-dir, [  --with-mpfr-dir=PATH    Specify source directory for MPFR library])
@@ -1079,6 +1082,18 @@ if test "x$with_mpfr" != x; then
   gmpinc="-I$with_mpfr/include"
 fi
 
+# If no explicit mpfr installation or directory has been given, but
+# the sources for mpfr are available in the source tree, then use them.
+if test "x$with_mpfr" == x && test "x$with_mpfr_dir" == x && test -d ${srcdir}/mpfr; then
+  gmplibs="-L ../${build_subdir}/mpfr/.libs -L ../${build_subdir}/mpfr/_libs -lmpfr"
+  gmpinc="-I ../${build_subdir}/mpfr -I${srcdir}/mpfr"
+  # Do not test the mpfr version.  Assume that it is sufficient, since
+  # it is in the source tree, and the library has not been built yet
+  # but it would be included on the link line in the version check below
+  # hence making the test fail.
+  test_gmp_version=no
+fi
+
 # Specify a location for gmp
 AC_ARG_WITH(gmp-dir, [  --with-gmp-dir=PATH     Specify source directory for GMP library])
 
@@ -1091,6 +1106,7 @@ if test "x$with_gmp_dir" != x; then
   fi
   # One of the later tests will catch the error if neither library is present.
 else
+  orig_gmplibs=$gmplibs
   gmplibs="$gmplibs -lgmp"
 fi
 
@@ -1101,37 +1117,50 @@ if test "x$with_gmp" != x; then
   gmpinc="-I$with_gmp/include $gmpinc"
 fi
 
-saved_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 no explicit gmp directory has been given, but the sources
+# for gmp are available in the source tree, then use them.
+if test "x$with_gmp_dir" == x && test "x$with_gmp" == x && test -d ${srcdir}/gmp; then
+  gmplibs="$orig_gmplibs -L ../${build_subdir}/gmp/.libs -L ../${build_subdir}/gmp/_libs -lgmp"
+  gmpinc="$gmpinc -I ../${build_subdir}/gmp"
+  # Do not test the gmp version.  Assume that it is sufficient, since
+  # it is in the source tree, and the gmp.h header has not been created
+  # yet.
+  test_gmp_version=no
+fi
+
+if test "x$test_gmp_version" == xyes; then	
+  saved_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 < 4 || (__GNU_MP_VERSION == 4 && __GNU_MP_VERSION_MINOR < 1)
 choke me
 #endif
 ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_gmp=no])
 
-if test x"$have_gmp" = xyes; then
-  saved_LIBS="$LIBS"
-  LIBS="$LIBS $gmplibs"
-  AC_MSG_CHECKING([for correct version of mpfr.h])
-  AC_TRY_LINK([#include <gmp.h>
+  if test x"$have_gmp" = xyes; then
+    saved_LIBS="$LIBS"
+    LIBS="$LIBS $gmplibs"
+    AC_MSG_CHECKING([for correct version of mpfr.h])
+    AC_TRY_LINK([#include <gmp.h>
 #include <mpfr.h>],[
 #if MPFR_VERSION_MAJOR < 2 || (MPFR_VERSION_MAJOR == 2 && MPFR_VERSION_MINOR < 2)
   choke me
 #endif
   mpfr_t n; mpfr_init(n);
 ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_gmp=no])
-  LIBS="$saved_LIBS"
-fi
-CFLAGS="$saved_CFLAGS"
+    LIBS="$saved_LIBS"
+  fi
+  CFLAGS="$saved_CFLAGS"
 
-if test -d ${srcdir}/gcc && test x$have_gmp != xyes; then
-  AC_MSG_ERROR([Building GCC requires GMP 4.1+ and MPFR 2.2+.
+  if test -d ${srcdir}/gcc && test x$have_gmp != xyes; then
+    AC_MSG_ERROR([Building GCC requires GMP 4.1+ and MPFR 2.2+.
 Try the --with-gmp and/or --with-mpfr options to specify their locations.
 Copies of these libraries' source code can be found at their respective
 hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
 See also http://gcc.gnu.org/install/prerequisites.html for additional info.])
+  fi
 fi
 
 # Flags needed for both GMP and/or MPFR
*** /home/nickc/gmp-4.2.1/configure.in	2006-04-30 00:31:08.000000000 +0100
--- configure.in	2006-11-16 09:54:05.000000000 +0000
*************** m4_pattern_allow(GMP_MPARAM_H_SUGGEST)
*** 38,43 ****
--- 38,53 ----
  m4_pattern_allow(GMP_NAIL_BITS)
  m4_pattern_allow(GMP_NUMB_BITS)
  
+ # start-sanitize-redhat	
+ AC_ARG_ENABLE(target,
+   AC_HELP_STRING([ --enable-target={yes|no}  Honour (or ignore) the --target switch ]),
+   [case $enableval in
+ 	yes) ;;
+ 	no) target_alias=$host_alias ;;
+ 	*) AC_MSG_ERROR([only 'yes' or 'no' are accepted for --enable-target]) ;;
+   esac],
+   [enable_target=yes])
+ # end-sanitize-redhat
  # If --target is not used then $target_alias is empty, but if say
  # "./configure athlon-pc-freebsd3.5" is used, then all three of
  # $build_alias, $host_alias and $target_alias are set to

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