diff r c24b1e8f4ba1 r f762203bee23 .hgtags
 a/.hgtags Mon Feb 20 10:52:24 2012 +0100
+++ b/.hgtags Mon Feb 27 10:57:03 2012 +0100
@@ 1,2 +1,5 @@
7b48a0b7db66d47bd5b361fb6b0f690c241a9ef5 mpfr2.4.2.p0
8094e7388f5bae4105a4e3ff49967fd246817559 mpfr2.4.2.p1
+c24b1e8f4ba1fce31bb2ea48bb069bedaebe3d32 mpfr2.4.2.p2
+ad149c890ee193fbe7d2fdbebf94dee20eb6a612 mpfr3.1.0
+834f2c4e0347c2e4249d94188203d93cea44d92a mpfr3.1.0.p0
diff r c24b1e8f4ba1 r f762203bee23 SPKG.txt
 a/SPKG.txt Mon Feb 20 10:52:24 2012 +0100
+++ b/SPKG.txt Mon Feb 27 10:57:03 2012 +0100
@@ 2,17 +2,29 @@
== Description ==
From http://mpfr.org/: The MPFR library is a C library for multipleprecision
floatingpoint computations with correct rounding. MPFR has continuously been
supported by the INRIA and the current main authors come from the CACAO and
Arenaire projectteams at Loria (Nancy, France) and LIP (Lyon, France)
respectively; see more on the credit page. MPFR is based on the GMP
multipleprecision library.
+The MPFR library is a C library for multipleprecision floatingpoint
+computations with correct rounding. MPFR has continuously been supported by
+the INRIA and the current main authors come from the Caramel and ArĂ©naire
+projectteams at Loria (Nancy, France) and LIP (Lyon, France) respectively;
+see more on the credit page. MPFR is based on the GMP multipleprecision
+library.
+
+The main goal of MPFR is to provide a library for multipleprecision
+floatingpoint computation which is both efficient and has a welldefined
+semantics. It copies the good ideas from the ANSI/IEEE754 standard for
+doubleprecision floatingpoint arithmetic (53bit significand).
== License ==
MPFR is free. It is distributed under the GNU Lesser General Public License
(GNU Lesser GPL), version 2.1 or later.
+MPFR is free. It is distributed under the GNU Lesser General Public License
+(GNU Lesser GPL), version 3 or later (2.1 or later for MPFR versions until
+2.4.x). The library has been registered in France by the Agence de Protection
+des Programmes under the number IDDN FR 001 120020 00 R P 2000 000 10800, on
+15 March 2000. This license guarantees your freedom to share and change MPFR,
+to make sure MPFR is free for all its users. Unlike the ordinary General
+Public License, the Lesser GPL enables developers of nonfree programs to use
+MPFR in their programs. If you have written a new function for MPFR or improved
+an existing one, please share your work!
== SPKG Maintainers ==
@@ 26,15 +38,23 @@
== Dependencies ==
 * GMP
+ * MPIR
== IMPORTANT ==
When building Sage binaries for widespead distribution, set the variable
+When building Sage binaries for widespead distribution, set the variable
INCLUDE_MPFR_PATCH to 1, to include a patch, which can cause failures
on sun4v machines.
+on sun4v machines.
== Changelog ==
+=== mpfr3.1.0.p0 (JeanPierre Flori, February 22nd, 2012) ===
+ * #11666: Further cleanups and rebase on #12131, #12366 and #12548.
+ * Let configure get the MPIR flags.
+
+=== mpfr3.1.0 (Mike Hansen, December 17th, 2011) ===
+ * #11666: Upgrade MPFR to 3.1.0
+ * Update spkginstall and spkgcheck files to current standards
+
=== mpfr2.4.2.p2 (Jeroen Demeyer, 20 February 2012) ===
* #12548: do not delete old libraries
@@ 54,31 +74,31 @@
* Make SAGE64 work also on Open Solaris 64 bit
=== mpfr2.4.1p0 (David Kirkby, July 17th 2009) ===
 * Sage TRAC #6453 http://sagetrac.org/sage_trac/ticket/6453
 Implement a patch to mpn_exp.c developed by Paul Zimmermann
 (Paul.Zimmermann@loria.fr) to bypass what may be a Solaris or gcc bug.
 This avoids 20 test failures on a Sun T5240 running Solaris 10 (both
+ * Sage TRAC #6453 http://sagetrac.org/sage_trac/ticket/6453
+ Implement a patch to mpn_exp.c developed by Paul Zimmermann
+ (Paul.Zimmermann@loria.fr) to bypass what may be a Solaris or gcc bug.
+ This avoids 20 test failures on a Sun T5240 running Solaris 10 (both
updates 4 and 7 have been tried on this machine). Since it's only seen
there, the patch is very specific and is only applied on those machines, not
all Solaris systems by default, but can be overridden with an environment
 variable INCLUDE_MPFR_PATCH (set to 1 to include patch, 0 to exclude it).
 If INCLUDE_MPFR_PATCH is unset, the patch will be included on sun4v systems,
+ variable INCLUDE_MPFR_PATCH (set to 1 to include patch, 0 to exclude it).
+ If INCLUDE_MPFR_PATCH is unset, the patch will be included on sun4v systems,
but exluded on all others. Please set it to 1 if building binaries for others.
This is a bug in Solaris's memset() function, for more information see
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40757
* Remove a comment at the bottom of spkginstall telling developers to bypass
 check on release systems. Given failures have occured, it would be unwise to
 bypass any checks.
 Note, the checks were performed in Sage 4.1, so despite a coment saying
 checks should be bypassed in 'releases' they were in fact not bypassed.
 The tests were already executed, which is how the bug was discovered.

 * Add a comment to remind people not to bypass the tests, pointing out
 failures had occured, so it would be unwise to bypass checks.
+ check on release systems. Given failures have occured, it would be unwise to
+ bypass any checks.
+ Note, the checks were performed in Sage 4.1, so despite a coment saying
+ checks should be bypassed in 'releases' they were in fact not bypassed.
+ The tests were already executed, which is how the bug was discovered.
 * Update the source to use the latest patches, as strongly reccommened in the
+ * Add a comment to remind people not to bypass the tests, pointing out
+ failures had occured, so it would be unwise to bypass checks.
+
+ * Update the source to use the latest patches, as strongly reccommened in the
INSTALL file. This brings the code to MPFR 2.4.1 patch level 5, though I'm
considering it mpfr2.4.1p0 for Sage purposes.
@@ 108,4 +128,3 @@
=== mpfr2.3.0 (Michael Abshoff, Sept. 14th, 2007) ===
* upgrade to mpfr 2.3.0 release
* add spkgcheck

diff r c24b1e8f4ba1 r f762203bee23 patches/mpn_exp.c
 a/patches/mpn_exp.c Mon Feb 20 10:52:24 2012 +0100
+++ b/patches/mpn_exp.c Mon Feb 27 10:57:03 2012 +0100
@@ 1,14 +1,13 @@
/* mpfr_mpn_exp  auxiliary function for mpfr_get_str and mpfr_set_str
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by the Arenaire and Cacao projects, INRIA.
Contributed by Alain Delplanque and Paul Zimmermann.
+Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+Contributed by the Arenaire and Caramel projects, INRIA.
This file is part of the GNU MPFR Library.
The GNU MPFR Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at your
+the Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
The GNU MPFR Library is distributed in the hope that it will be useful, but
@@ 17,31 +16,31 @@
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MPFR Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
MA 021101301, USA. */
+along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
+http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
+51 Franklin St, Fifth Floor, Boston, MA 021101301, USA. */
#define MPFR_NEED_LONGLONG_H
#include "mpfrimpl.h"
/* this function computes an approximation of b^e in {a, n}, with exponent
 stored in exp_r. The computed value is rounded towards zero (truncated).
+ stored in exp_r. The computed value is rounded toward zero (truncated).
It returns an integer f such that the final error is bounded by 2^f ulps,
that is:
a*2^exp_r <= b^e <= 2^exp_r (a + 2^f),
where a represents {a, n}, i.e. the integer
 a[0] + a[1]*B + ... + a[n1]*B^(n1) where B=2^BITS_PER_MP_LIMB
+ a[0] + a[1]*B + ... + a[n1]*B^(n1) where B=2^GMP_NUMB_BITS
Return 1 is the result is exact.
Return 2 if an overflow occurred in the computation of exp_r.
*/
long
mpfr_mpn_exp (mp_limb_t *a, mp_exp_t *exp_r, int b, mp_exp_t e, size_t n)
+mpfr_mpn_exp (mp_limb_t *a, mpfr_exp_t *exp_r, int b, mpfr_exp_t e, size_t n)
{
mp_limb_t *c, B;
 mp_exp_t f, h;
+ mpfr_exp_t f, h;
int i;
unsigned long t; /* number of bits in e */
unsigned long bits;
@@ 53,7 +52,7 @@
MPFR_TMP_DECL(marker);
MPFR_ASSERTN(e > 0);
 MPFR_ASSERTN((2 <= b) && (b <= 36));
+ MPFR_ASSERTN((2 <= b) && (b <= 62));
MPFR_TMP_MARK(marker);
@@ 63,13 +62,13 @@
B = (mp_limb_t) b;
count_leading_zeros (h, B);
 bits = BITS_PER_MP_LIMB  h;
+ bits = GMP_NUMB_BITS  h;
B = B << h;
h =  h;
/* allocate space for A and set it to B */
 c = (mp_limb_t*) MPFR_TMP_ALLOC(2 * n * BYTES_PER_MP_LIMB);
+ c = MPFR_TMP_LIMBS_ALLOC (2 * n);
a [n  1] = B;
/* The following couple of lines work around a bug seen so far only on
a Sun T5240 with a pair of T2+ processors. It only happens with some versions
@@ 84,14 +83,14 @@
MPN_ZERO (a, n  1);
/* initial exponent for A: invariant is A = {a, n} * 2^f */
 f = h  (n  1) * BITS_PER_MP_LIMB;
+ f = h  (n  1) * GMP_NUMB_BITS;
/* determine number of bits in e */
count_leading_zeros (t, (mp_limb_t) e);
 t = BITS_PER_MP_LIMB  t; /* number of bits of exponent e */
+ t = GMP_NUMB_BITS  t; /* number of bits of exponent e */
 error = t; /* error <= BITS_PER_MP_LIMB */
+ error = t; /* error <= GMP_NUMB_BITS */
MPN_ZERO (c, 2 * n);
@@ 99,8 +98,8 @@
{
/* determine precision needed */
 bits = n * BITS_PER_MP_LIMB  mpn_scan1 (a, 0);
 n1 = (n * BITS_PER_MP_LIMB  bits) / BITS_PER_MP_LIMB;
+ bits = n * GMP_NUMB_BITS  mpn_scan1 (a, 0);
+ n1 = (n * GMP_NUMB_BITS  bits) / GMP_NUMB_BITS;
/* square of A : {c+2n1, 2(nn1)} = {a+n1, nn1}^2 */
mpn_sqr_n (c + 2 * n1, a + n1, n  n1);
@@ 114,10 +113,10 @@
MPFR_TMP_FREE(marker);
return 2;
}
 /* FIXME: Could f = 2*f + n * BITS_PER_MP_LIMB be used? */
+ /* FIXME: Could f = 2*f + n * GMP_NUMB_BITS be used? */
f = 2*f;
 MPFR_SADD_OVERFLOW (f, f, n * BITS_PER_MP_LIMB,
 mp_exp_t, mp_exp_unsigned_t,
+ MPFR_SADD_OVERFLOW (f, f, n * GMP_NUMB_BITS,
+ mpfr_exp_t, mpfr_uexp_t,
MPFR_EXP_MIN, MPFR_EXP_MAX,
goto overflow, goto overflow);
if ((c[2*n  1] & MPFR_LIMB_HIGHBIT) == 0)
@@ 133,14 +132,14 @@
MPN_COPY (a, c + n, n);
if ((error == t) && (2 * n1 <= n) &&
 (mpn_scan1 (c + 2 * n1, 0) < (n  2 * n1) * BITS_PER_MP_LIMB))
+ (mpn_scan1 (c + 2 * n1, 0) < (n  2 * n1) * GMP_NUMB_BITS))
error = i;
 if (e & ((mp_exp_t) 1 << i))
+ if (e & ((mpfr_exp_t) 1 << i))
{
/* multiply A by B */
c[2 * n  1] = mpn_mul_1 (c + n  1, a, n, B);
 f += h + BITS_PER_MP_LIMB;
+ f += h + GMP_NUMB_BITS;
if ((c[2 * n  1] & MPFR_LIMB_HIGHBIT) == 0)
{ /* shift A by one bit to the left */
mpn_lshift (a, c + n, n, 1);
@@ 164,7 +163,7 @@
if (error == t)
return 1; /* result is exact */
 else /* error <= t2 <= BITS_PER_MP_LIMB2
+ else /* error <= t2 <= GMP_NUMB_BITS2
err_s_ab, err_s_a2 <= t1 */
{
/* if there are p loops after the first inexact result, with
@@ 174,11 +173,11 @@
*/
error = error + err_s_ab + err_s_a2 / 2 + 3; /* <= 5t/21/2 */
#if 0
 if ((error  1) >= ((n * BITS_PER_MP_LIMB  1) / 2))
 error = n * BITS_PER_MP_LIMB; /* result is completely wrong:
+ if ((error  1) >= ((n * GMP_NUMB_BITS  1) / 2))
+ error = n * GMP_NUMB_BITS; /* result is completely wrong:
this is very unlikely since error is
at most 5/2*log_2(e), and
 n * BITS_PER_MP_LIMB is at least
+ n * GMP_NUMB_BITS is at least
3*log_2(e) */
#endif
return error;
diff r c24b1e8f4ba1 r f762203bee23 patches/mpn_exp.c.patch
 a/patches/mpn_exp.c.patch Mon Feb 20 10:52:24 2012 +0100
+++ b/patches/mpn_exp.c.patch Mon Feb 27 10:57:03 2012 +0100
@@ 1,8 +1,8 @@
 mpn_exp.c.orig Fri Feb 20 01:43:17 2009
+++ mpn_exp.c Thu Jul 16 17:25:20 2009
@@ 71,7 +71,18 @@
+ ../src/src/mpn_exp.c 20111003 09:17:09.000000000 +0100
++++ mpn_exp.c 20111217 09:57:30.000000000 +0000
+@@ 70,7 +70,18 @@
/* allocate space for A and set it to B */
 c = (mp_limb_t*) MPFR_TMP_ALLOC(2 * n * BYTES_PER_MP_LIMB);
+ c = MPFR_TMP_LIMBS_ALLOC (2 * n);
a [n  1] = B;
 MPN_ZERO (a, n  1);
+ /* The following couple of lines work around a bug seen so far only on
@@ 18,5 +18,5 @@
+ MPN_ZERO (a, n  1);
+
/* initial exponent for A: invariant is A = {a, n} * 2^f */
 f = h  (n  1) * BITS_PER_MP_LIMB;
+ f = h  (n  1) * GMP_NUMB_BITS;
diff r c24b1e8f4ba1 r f762203bee23 spkgcheck
 a/spkgcheck Mon Feb 20 10:52:24 2012 +0100
+++ b/spkgcheck Mon Feb 27 10:57:03 2012 +0100
@@ 1,8 +1,18 @@
+#!/usr/bin/env bash
+
+if [ z "$SAGE_LOCAL" ]; then
+ echo "Error: SAGE_LOCAL undefined  exiting..."
+ echo "Maybe run 'sage sh'?"
+ exit 1
+fi
+
+# unset RM since it messes with libtool
+unset RM
+
cd src
make check
+$MAKE check
if [ $? ne 0 ]; then
 echo "There was a problem during the mpfr tests."
+ echo "Error: the MPFR test suite failed."
exit 1
fi

diff r c24b1e8f4ba1 r f762203bee23 spkginstall
 a/spkginstall Mon Feb 20 10:52:24 2012 +0100
+++ b/spkginstall Mon Feb 27 10:57:03 2012 +0100
@@ 1,36 +1,28 @@
#!/bin/sh
+#!/usr/bin/env bash
if [ "$SAGE_LOCAL" = "" ]; then
 echo "SAGE_LOCAL undefined ... exiting";
 echo "Maybe run 'sage sh'?"
 exit 1
+if [ z "$SAGE_LOCAL" ]; then
+ echo "Error: SAGE_LOCAL undefined  exiting..."
+ echo "Maybe run 'sage sh'?"
+ exit 1
fi
# unset RM since it messes with libtool for "make check"
+# unset RM since it messes with libtool
unset RM
build()
+mpfr_patch()
{
 if [ "$SAGE64" = "yes" ]; then
 echo "64 bit build"
 CFLAGS="O2 g m64 "; export CFLAGS
 CXXFLAGS="O2 g m64 "; export CXXFLAGS
 CPPFLAGS="O2 g m64 "; export CPPFLAGS
 fi

 EXTRA=""
# Apply a patch on Solaris, but only on the sun4v architecture
 # by default. On other Solaris systems, it can be overridden
+ # by default. On other Solaris systems, it can be overridden
# The patch to the C code was developed by Paul Zimmermann, the patch
 # to the spkginstall by David Kirkby. See Ticket #6453
+ # to the spkginstall by David Kirkby. See Ticket #6453
if [ `uname` = "SunOS" ]; then
# Add a patch to MPFR on Solaris if either:
# 1) The machine is a sun4v architecture
# 2) The environment variable INCLUDE_MPFR_PATCH is set to 1
 # This will allow creating of binaries on a machine other than
 # sun4v, which will run on sun4v.
+ # This will allow creating of binaries on a machine other than
+ # sun4v, which will run on sun4v.
echo "\nThis computer is running Solaris on which some problems have been observed"
echo "with the MPFR library running on a T2+ processor (sun4v architecture)."
echo "See http://sagetrac.org/sage_trac/ticket/6453 A patch can be applied"
@@ 49,15 +41,15 @@
# Note, "/usr/bin/arch" will return "sun4" on any SPARC system
# If given the 'k' option, aditional information will be displayed
 # to indicate if the system is sun4m (very old), sun4u or sun4v
+ # to indicate if the system is sun4m (very old), sun4u or sun4v
# Set the variable PATCH_MPFR to something other than 0 or 1"
PATCH_MPFR="${INCLUDE_MPFR_PATCH2}"
if [ $PATCH_MPFR = "1" ] ; then
echo "Since INCLUDE_MPFR_PATCH was set to 1, the MPFR library will be patched."
echo "The binaries should be safe on any Solaris system"
 cp ../patches/mpn_exp.c mpn_exp.c
 elif [ $PATCH_MPFR = "0" ] ; then
+ cp ../patches/mpn_exp.c src/mpn_exp.c
+ elif [ $PATCH_MPFR = "0" ] ; then
echo "Since INCLUDE_MPFR_PATCH was set to 0, the MPFR library will not"
echo "be patched. You would be unwise to distribute SPARC binaries"
echo "unless you are sure they will not be used on sun4v systems"
@@ 65,7 +57,7 @@
echo "This is a sun4v system, so the MPFR library will be patched. The binaries"
echo "should run correctly on any SPARC system whose operating system is"
echo "no older than the system used to build the binaries."
 cp ../patches/mpn_exp.c mpn_exp.c
+ cp ../patches/mpn_exp.c src/mpn_exp.c
elif [ $PATCH_MPFR = "2" a `arch k` != "sun4v" ] ; then
echo "Since this is not a sun4v system, the MPFR binary will not"
echo "be patched"
@@ 78,33 +70,167 @@
fi
else
echo "The environment variable INCLUDE_MPFR_PATCH was set incorrectly The MPFR"
 echo "library will be patched as a precaution."
 cp ../patches/mpn_exp.c mpn_exp.c
+ echo "library will be patched as a precaution."
+ cp ../patches/mpn_exp.c src/mpn_exp.c
fi
fi
+
+}
+
+mpfr_get_upstream_selected_cflags() # Get MPFR's choice on empty CC and CFLAGS.
+{
+ if [ $# ne 1 ]; then
+ echo "Error: mpfr_get_upstream_selected_cflags() requires 'file' parameter."
+ exit 1
+ fi
+ header_file=$1
+ mpfr_cc_pat="s/^CC='\([^']*\)'/\1/p"
+ mpfr_cflags_pat="s/^CFLAGS='\([^']*\)'/\1/p"
+ if ! [ f "$header_file" ]; then
+ upstream_cc=""
+ upstream_cflags=""
+ return 1
+ fi
+ upstream_cc=`sed n e "$mpfr_cc_pat" "$header_file"`
+ upstream_cflags=`sed n e "$mpfr_cflags_pat" "$header_file"`
+ return 0
+}
+
+mpfr_configure()
+{
+ sage_cc=$CC # Save Sage CC, because we need to unset it later.
+ user_cflags=$CFLAGS # Save them. 'sageenv' sets CC, but not CFLAGS.
+ required_cflags="" # Additional mandatory settings required by Sage, accumulated below.
+ default_cflags="" # Spkg defaults that can and might get overridden.
+
+ if [ "$SAGE_DEBUG" = yes ]; then
+ # Disable optimization, add debug symbols:
+ required_cflags="$required_cflags g O0"
+ echo "Warning: Building MPFR with SAGE_DEBUG=yes disables optimization."
+ else
+ # Add debug symbols by default, enable optimization, but do not (yet)
+ # add processorspecific flags (these are eventually added later):
+ default_cflags="$default_cflags g O3"
+ fi
+
+ if [ "$SAGE64" = "yes" ]; then
+ echo "Building a 64bit version of MPFR."
+ default_cflags="$default_cflags m64"
+ else
+ default_cflags="$default_cflags"
+ fi
+
+ SAGE_CONF_OPTS="libdir=$SAGE_LOCAL/lib disablethreadsafe"
if [ ! f "$SAGE_LOCAL/include/gmp.h" ]; then
 EXTRA="disablestatic enableshared"
+ SAGE_CONF_OPTS="$SAGE_CONF_OPTS disablestatic enableshared"
fi
if [ $UNAME = "CYGWIN" ]; then
 EXTRA="disablestatic enableshared"
+ SAGE_CONF_OPTS="$SAGE_CONF_OPTS disablestatic enableshared"
+
fi
 ./configure prefix=$SAGE_LOCAL libdir="$SAGE_LOCAL/lib" withgmp=$SAGE_LOCAL \
 CFLAGS="$CFLAGS $SHAREDFLAGS O2" CXX="$CXX" \
 CXXFLAGS="$CXXFLAGS $SHAREDFLAGS" LDFLAGS="$LDFLAGS" \
 GMP_PREFIX="$SAGE_LOCAL" $EXTRA
 if [ $? ne 0 ]; then
 echo >&2 "Error configuring mpfr."
+ # Preconfigure MPFR to get the settings it would use if CC and CFLAGS were empty:
+ echo "Checking what CC and CFLAGS MPFR would use if they were empty..."
+ if (unset CC CFLAGS CPPFLAGS CXXFLAGS &&
+ ./configure withgmp="$SAGE_LOCAL" $SAGE_CONF_OPTS $MPFR_EXTRA_OPTS) &>/dev/null;
+ then
+ if mpfr_get_upstream_selected_cflags config.status; then
+ mpfr_cflags=$upstream_cflags
+ mpfr_cc=$upstream_cc
+ echo "Settings chosen by MPFR when configuring with CC and CFLAGS unset:"
+ echo " CC: $mpfr_cc"
+ echo " CFLAGS: $mpfr_cflags"
+ else
+ echo "Warning: Couldn't determine MPFRselected CC and CFLAGS from 'mpfr.h'"
+ fi
+ else
+ # We ignore errors in the first place, since we redirected all
+ # messages to /dev/null. (The messages can be found in the 'config.log'
+ # files if someone really wants to read them.)
+ :;
+ fi
+ find . name config.cache o name config.status exec rm f {} \;
+ CC=$sage_cc
+
+ echo "Settings required to properly build MPFR, taking into account SAGE_DEBUG etc.:"
+ echo " CFLAGS: $required_cflags"
+ echo " LDFLAGS: $LDFLAGS" # Might be empty, or specified by the user.
+ echo " ABI: $ABI" # Might be empty, or specified by the user.
+ echo "Settings from the \"global\" environment:"
+ echo " CC: $CC" # Set by Sage, maybe overridden by the user.
+ echo " CFLAGS: $user_cflags"
+ echo " (CPPFLAGS, CXX and CXXFLAGS are listed below; these don't get modified.)"
+
+ if [ z "$user_cflags" ]; then
+ # No CFLAGS specified by user => Use either MPFR's or our default ones,
+ # plus those required by Sage for the package to build properly:
+ if [ n "$mpfr_cflags" ]; then
+ # Fine. Use upstream settings.
+ echo "Using MPFR's settings (plus mandatory ones)."
+ CFLAGS="$mpfr_cflags $required_cflags"
+ else # Use spkg's defaults.
+ echo "Using the spkg's (i.e. Sage's) default (plus mandatory) settings."
+ CFLAGS="$default_cflags $required_cflags"
+ fi
+ else
+ # CFLAGS were specified by the user, so don't override them (unless
+ # necessary).
+ echo "Using userspecified settings (overriding defaults), with some additions."
+ CFLAGS="$default_cflags $user_cflags $required_cflags"
+ fi
+
+ echo "Finally using the following settings:"
+ echo " CC=$CC"
+ echo " CFLAGS=$CFLAGS"
+ echo " CPPFLAGS=$CPPFLAGS"
+ echo " CXX=$CXX"
+ echo " CXXFLAGS=$CXXFLAGS"
+ echo " LDFLAGS=$LDFLAGS"
+ echo " ABI=$ABI"
+ echo "(These settings may still get overridden by 'configure' or Makefiles.)"
+
+ ###############################################################################
+ # Now really configure MPFR with proper settings:
+ ###############################################################################
+ if [ z "$MPFR_EXTRA_OPTS" ]; then
+ echo "Configuring MPFR with the following options:"
+ echo " prefix=\"$SAGE_LOCAL\" withgmp=\"$SAGE_LOCAL\" $SAGE_CONF_OPTS"
+ echo "You can set MPFR_EXTRA_OPTS to pass additional parameters."
+ else
+ echo "Using additional 'configure' options as specified with" \
+ "MPFR_EXTRA_OPTS:"
+ echo " $MPFR_EXTRA_OPTS"
+ echo "Configuring MPFR with the following options:"
+ echo " prefix=\"$SAGE_LOCAL\" withgmp=\"$SAGE_LOCAL\" $SAGE_CONF_OPTS $MPFR_EXTRA_OPTS"
+ fi
+
+ ./configure prefix="$SAGE_LOCAL" withgmp="$SAGE_LOCAL" $SAGE_CONF_OPTS $MPFR_EXTRA_OPTS
+}
+
+mpfr_build()
+{
+ echo "Patching MPFR"
+ mpfr_patch
+ if [ $? ne 0 ]; then
+ echo >&2 "Error patching MPFR."
exit 1
 fi
+ fi
+
+ echo "Configuring MPFR"
+ mpfr_configure
+ if [ $? ne 0 ]; then
+ echo >&2 "Error configuring MPFR."\
+ "(See above for the options passed to it.)"
+ exit 1
+ fi
echo "Building MPFR"
$MAKE
 if [ $? ne 0 ]; then
 echo >&2 "Error building mpfr."
+ if [ $? ne 0 ]; then
+ echo >&2 "Error building MPFR."
exit 1
 fi
+ fi
echo "Deleting old headers"
rm f "$SAGE_LOCAL"/include/*mpfr*
@@ 114,12 +240,12 @@
echo "Installing MPFR"
$MAKE install
 if [ $? ne 0 ]; then
 echo >&2 "Error installing mpfr."
+ if [ $? ne 0 ]; then
+ echo >&2 "Error installing MPFR."
exit 1
 fi
+ fi
}
cd src
build
+mpfr_build