Ticket #12830: ecm-6.3.p4-p6.diff

File ecm-6.3.p4-p6.diff, 23.8 KB (added by leif, 4 years ago)

Diff between the previous spkg in Sage and my new p6 spkg. For reference / review only.

  • .hgignore

    diff --git a/.hgignore b/.hgignore
    a b  
    11src
    2 patches/configure
    3 patches/configure.in
  • .hgtags

    diff --git a/.hgtags b/.hgtags
    a b  
    114fb2b9ca03a2973d035fad8c9cfe6062c79cc6f2 ecm-6.3.p2
    224d6646f19caecfa0810d3341a8a1361cb529a7b4 ecm-6.3.p3
    3362e5a142f7157c6dfa8ab59fc9228208326507ad ecm-6.3.p4
     414c0237361c1ffefdcece11d745f3381ec009a46 ecm-6.3.p5
     57ac46fc5997fb25668f35b8571f48af69f5859f4 ecm-6.3.p6
  • SPKG.txt

    diff --git a/SPKG.txt b/SPKG.txt
    a b  
    2121== Dependencies ==
    2222
    2323 * GMP/MPIR (Note: Python is *not* required for ordinary builds.)
     24 * GNU patch
    2425
    2526== Special Update/Build Instructions ==
    2627
    27  * src/ contains "stable" upstream code, to which we currently apply
    28    two upstream patches (both to 'configure.in'). These (i.e. the
    29    files 'patches/configure.in' and 'patches/configure') should be
    30    removed on the next upgrade to a stable release.
     28 * src/ contains "stable" upstream code, to which we currently apply a single
     29   upstream patch (to 'configure'). The patch should be removed on the next
     30   upgrade to a stable release.
     31   Note that all autotools-generated files (and their support files) in src/
     32   have been regenerated with newer versions of autotools (autoconf 2.68,
     33   automake 1.11.3 and libtool 2.4.2), to make the size of the patch to the
     34   also generated `configure` acceptable.  (See "Patches" section below for
     35   why we don't patch `configure.in`, from which `configure` is created.)
    3136 * GMP-ECM comes with a self-tuning feature; we could support
    3237   that as an option ($SAGE_TUNE_*=yes) in the future.
    3338 * We currently work around a linker bug on MacOS X 10.5 PPC (with
     
    3540   This *might* get fixed in later upstream releases.
    3641 * ECM currently does not (by itself) use the CC and CFLAGS settings
    3742   from 'gmp.h' since we pass (other) options in CFLAGS, and CC is set
    38    by Sage and might got set by the user (though MPIR currently doesn't
    39    use its own CFLAGS for the same reason, which is fixed in an MPIR
    40    2.1.3.p2 spkg). We now at least partially fix that s.t. "optimized"
    41    code generation options ('-mcpu=...', '-mtune=...') are used by gcc.
     43   by Sage and might got set by the user.  We now at least partially fix that
     44   such that "optimized" code generation options ('-mcpu=...', '-mtune=...')
     45   are used by gcc.
    4246   Of course a user can also manually enable them by setting the "global"
    4347   CFLAGS to e.g. '-march=native' on x86[_64] systems, or '-mcpu=...' and
    4448   '-mtune=...' on other architectures where "native" isn't supported.
     
    5054   "-mcpu=...", and perhaps pass a more generic "--host=..." to
    5155   'configure'. (MPIR honors '--enable-fat' to some extent, but this
    5256   option isn't used on anything other than x86 / x86_64.)
     57 * Check whether the work-around for GCC 4.7 on ia64 is still appropriate, i.e.
     58   adapt it in case the issue has been fixed in later GCC versions of the 4.7
     59   release series.  (Although the bug currently affects only GCC 4.7.0, it
     60   seems unlikely that it will be fixed soon, hence we apply the work-around
     61   for any GCC 4.7.x version on ia64.)
     62   See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48496 for details and the
     63   current status of that bug.
     64 * We could save some space by removing the `src/build.vc9/` directory which
     65   isn't used in Sage.  (It gets probably more worth in case also directories /
     66   files for later versions of Microsoft Visual C get added.)
     67
     68=== Patches ===
     69 * configure.patch:
     70   - Disable "asm-redc" on 32-bit Darwin PPCs (upstream revision 1516 / bug
     71     #10646).
     72     (Note that this upstream patch is likely to slow down GMP-ECM on 64-bit
     73     PPC CPUs running (32-bit) MacOS X, since the extended instruction set of
     74     the CPU is no longer exploitet.  A proper fix would just pass an option
     75     to Apple's assembler to allow the use of the extended instruction set.) 
     76   - Fix compilation error on x86 CPUs supporting SSE2. (Sage trac #10252,
     77     upstream revision 1546).
     78   Note that we don't patch `configure.in`, since it is only needed to generate
     79   automatically-generated files in the source tree.  Patching `configure.in`
     80   would force `automake` to be run, which could cause build failures on
     81   systems where autotools aren't installed.
     82
    5383
    5484== Changelog ==
    5585
     86=== ecm-6.3.p6 (Leif Leonhardy, April 16th 2012) ===
     87 * #12830: Add a work-around for GCC 4.7.x on ia64 (Itanium), since GMP-ECM
     88   currently won't build with that and anything but `-O0` on that platform.
     89 * Use `\{1,\}` instead of `\+` in `sed` patterns, which is more portable.
     90 * Also support newer system-wide MPIR installations for printing their
     91   settings.
     92 * Use `patch` to apply patches.  Since the pre-patched `configure` in
     93   `patches/` was created with a newer version of autotools (or, rather, the
     94   original `configure` was created with an outdated version), the patch would
     95   have been almost as large as the patched `configure` file itself.  Hence
     96   I `autoreconf`ed the source tree with a patched `configure.in` (and almost
     97   the latest versions of autotools), then created a patch to `configure`
     98   from the resulting file(s).  Note that therefore `src/` isn't really vanilla
     99   any more, although just the auto-generated files differ (which are still
     100   made from vanilla upstream sources, including `configure.in`).
     101   Add a "Patches" subsection and update "Special Update/Build Instructions".
     102   Remove files in `patches/` from `.hgignore` (and also remove pre-patched
     103   files from that directory); the patch to `configure` and the diff of
     104   `configure.in` are [now] under revision control, which IMHO makes sense.
     105 * Beautify (and simplify) the output with respect to options passed to
     106   `configure`; print the settings of a few more environment variables that
     107   GMP-ECM uses (in case they're set); add some messages, also mention
     108   `--enable-assert` etc. if `SAGE_DEBUG=yes`.
     109 * Remove unused test for GCC.
     110
     111=== ecm-6.3.p5 (Leif Leonhardy, April 11th 2012) ===
     112 * #12830: Don't add `-march=native` if the assembler doesn't understand the
     113   instructions the compiler emits with that.  (E.g. the Apple/XCode assembler
     114   on Darwin doesn't yet support AVX.)
     115 * Fix extraction of `__GMP_CC` and `__GMP_CFLAGS` (from `gmp.h`) for newer
     116   versions of MPIR, which define these to preprocessor macros rather than
     117   strings.
     118 * Redirect warnings and error messages to `stderr`; add some messages.
     119 * Correct `SPKG.txt` w.r.t. applied patches.
     120
    56121=== ecm-6.3.p4 (Jeroen Demeyer, 13 February 2012) ===
    57122 * #12501: Do not patch configure.in in spkg-install (to prevent
    58123   automake from running).
  • new file patches/configure.patch

    diff --git a/patches/configure.patch b/patches/configure.patch
    new file mode 100644
    - +  
     1--- src/configure       2012-04-16 21:51:42.586783117 +0200
     2+++ src-patched/configure       2012-04-16 22:13:59.096783235 +0200
     3@@ -12343,7 +12343,7 @@
     4 # asm_redc enabled by default for x86_64 and 64 bit PowerPC
     5 if test "x$enable_asm_redc" = x; then
     6   case $host in
     7-    x86_64* | powerpc-apple-darwin* | powerpc64-*-linux*) enable_asm_redc=yes;;
     8+    x86_64*-*-* | powerpc-apple-darwin* | powerpc64-*-linux*) enable_asm_redc=yes;;
     9     *) enable_asm_redc=no;;
     10   esac
     11 fi
     12@@ -12351,8 +12351,35 @@
     13 if test "x$enable_asm_redc" = xyes; then
     14   case $host in
     15     pentium4-*-* | pentium3-*-* | viac7-*-* | i786-*-*) ASMPATH=pentium4;;
     16-    x86_64-*-*)  ASMPATH=x86_64;;
     17-    powerpc-apple-darwin*) ASMPATH=powerpc64;;
     18+    x86_64*-*-*)  ASMPATH=x86_64;;
     19+# warning: with powerpc-apple-darwin* we can have ABI=32
     20+# see bug #10646 on the bug tracker, where config.guess says
     21+# powerpc-apple-darwin8.11.0 (this a 64-bit machine, but most applications
     22+# are compiled in 32 bits). It works with --disable-asm-redc.
     23+    powerpc-apple-darwin*)
     24+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
     25+/* end confdefs.h.  */
     26+
     27+#if defined(__ppc__)
     28+#error
     29+#endif
     30+int
     31+main ()
     32+{
     33+
     34+  ;
     35+  return 0;
     36+}
     37+_ACEOF
     38+if ac_fn_c_try_cpp "$LINENO"; then :
     39+
     40+else
     41+  { $as_echo "$as_me:${as_lineno-$LINENO}: 32-bit PowerPC, disabling asm-redc" >&5
     42+$as_echo "$as_me: 32-bit PowerPC, disabling asm-redc" >&6;}
     43+                enable_asm_redc=no
     44+fi
     45+rm -f conftest.err conftest.i conftest.$ac_ext
     46+                          ASMPATH=powerpc64;;
     47     powerpc64-*-linux*)
     48 
     49 echo "include(<"$srcdir"/powerpc64/powerpc-defs.m4>)" >> $gmp_tmpconfigm4
     50@@ -12363,7 +12390,9 @@
     51                          ASMPATH=athlon;;
     52     *) as_fn_error $? "asm redc not available on this machine $host" "$LINENO" 5;;
     53   esac
     54+fi
     55 
     56+if test "x$enable_asm_redc" = xyes; then
     57 # do the necessary definitions and includes
     58 
     59 $as_echo "#define NATIVE_REDC 1" >>confdefs.h
     60@@ -12684,9 +12713,9 @@
     61 main ()
     62 {
     63 #if (defined(__GNUC__) || defined(__ICL)) && defined(__i386__)
     64-/* When there are no constraints, registers are referred to by
     65-   single % sign, not double. Argh */
     66-asm volatile ("pmuludq %xmm2, %xmm0");
     67+/* On some machines, a program without constraints may pass without -msse2 but
     68+   those with constraints in spv.c fail, thus we test with constraints here. */
     69+asm volatile ("pmuludq %%xmm2, %%xmm0" : : :"%xmm0");
     70 #else
     71 #error
     72 #IRIXdoesnotexitaterrordirective
     73@@ -12708,9 +12737,9 @@
     74 main ()
     75 {
     76 #if (defined(__GNUC__) || defined(__ICL)) && defined(__i386__)
     77-/* When there are no constraints, registers are referred to by
     78-   single % sign, not double. Argh */
     79-asm volatile ("pmuludq %xmm2, %xmm0");
     80+/* On some machines, a program without constraints may pass without -msse2 but
     81+   those with constraints in spv.c fail, thus we test with constraints here. */
     82+asm volatile ("pmuludq %%xmm2, %%xmm0" : : :"%xmm0");
     83 #else
     84 #error
     85 #IRIXdoesnotexitaterrordirective
  • spkg-check

    diff --git a/spkg-check b/spkg-check
    a b  
    11#!/usr/bin/env bash
    22
    33if [ -z "$SAGE_LOCAL" ]; then
    4     echo "Error: SAGE_LOCAL undefined - exiting..."
     4    echo >&2 "Error: SAGE_LOCAL undefined - exiting..."
    55    exit 1
    66fi
    77
    88# Note: Running the test suite should not involve (re)compilation,
    9 #       so we don't set CFLAGS et al. here.
     9#       so we don't set CFLAGS et al. here.  (Their settings are
     10#       stored in the Makefiles created by 'configure' anyway.)
    1011
    1112cd src
    1213
    13 echo "Running the GMP-ECM test suite..."
     14echo
     15echo "Now running GMP-ECM's test suite..."
    1416
    1517$MAKE check
    1618
    1719if [ $? -ne 0 ]; then
    18     echo "Error: The GMP-ECM test suite failed."
     20    echo >&2 "Error: GMP-ECM's test suite failed."
    1921    exit 1
    2022fi
    2123
    22 echo "The GMP-ECM test suite passed."
     24echo "GMP-ECM's test suite passed."
  • spkg-install

    diff --git a/spkg-install b/spkg-install
    a b  
    11#!/usr/bin/env bash
    22
    33if [ -z "$SAGE_LOCAL" ]; then
    4     echo "Error: SAGE_LOCAL undefined - exiting..."
     4    echo >&2 "Error: SAGE_LOCAL undefined - exiting..."
    55    exit 1
    66fi
    77
     8cd src/
     9
    810###############################################################################
    911# Apply patches (if any):
    1012###############################################################################
    1113
    12 # Patch configure (and configure.in):
    13 # - Disable asm-redc on 32-bit Darwin PPCs (upstream revision 1516 / bug #10646)
    14 # - Fix compilation error on x86 CPUs supporting SSE2. (Sage trac #10252,
    15 #   upstream revision 1546)
    16 echo "Copying patched files..."
    17 # Note that we don't patch configure.in here, since it is only needed
    18 # to generate automatically-generated files in the source tree.
    19 # Patching configure.in forces automake to be run, which may cause
    20 # build failures on systems where autotools aren't installed.
    21 cp -p patches/configure src/
    22 if [ $? -ne 0 ]; then
    23     echo "Error copying patched configure."
    24     exit 1
    25 fi
     14ls ../patches/*.patch &>/dev/null &&
     15echo "Applying patches to upstream sources..." &&
     16for patch in ../patches/*.patch; do
     17    basename "$patch"
     18    patch -p1 <"$patch"
     19    if [ $? -ne 0 ]; then
     20        echo >&2 "Error: '$patch' failed to apply."
     21        exit 1
     22    fi
     23done &&
     24echo
    2625
    2726###############################################################################
    2827# Set up environment variables, depending on SAGE_* settings:
     
    3433# processor-specific code, since ECM doesn't use them if we set our own:
    3534# (But currently MPIR doesn't provide optimized settings either if we pass
    3635# non-empty CFLAGS; of course the user could set such manually though.)
    37 gmp_cc_pat='/^[         ]*#[    ]*define[       ]\+__GMP_CC[    ]\+/s/.*"\([^"]*\)"/\1/p'
    38 gmp_cflags_pat='/^[     ]*#[    ]*define[       ]\+__GMP_CFLAGS[        ]\+/s/.*"\([^"]*\)"/\1/p'
     36gmp_cc_pat='/^[         ]*#[    ]*define[       ]\{1,\}__GMP_CC[        ]\{1,\}/s/.*"\([^"]*\)"/\1/p'
     37gmp_cflags_pat='/^[     ]*#[    ]*define[       ]\{1,\}__GMP_CFLAGS[    ]\{1,\}/s/.*"\([^"]*\)"/\1/p'
     38gmp_header_file="$SAGE_LOCAL"/include/gmp.h
    3939
    40 gmp_cc=`sed -n -e "$gmp_cc_pat" "$SAGE_LOCAL"/include/gmp.h`
    41 gmp_cflags=`sed -n -e "$gmp_cflags_pat" "$SAGE_LOCAL"/include/gmp.h`
     40gmp_cc=`sed -n -e "$gmp_cc_pat" "$gmp_header_file"`
     41gmp_cflags=`sed -n -e "$gmp_cflags_pat" "$gmp_header_file"`
     42# At least /some/ newer versions of MPIR define __GMP_CC and __GMP_CFLAGS
     43# (also in gmp.h! -- how compatible is that?) to (literally) __MPIR_CC and
     44# __MPIR_CFLAGS, respectively, i.e., to preprocessor variables, so we might
     45# have to get the real strings from their definitions:
     46# (Since we currently only match string literals above, both variables would
     47# be empty in that case, and not contain the names of preprocessor variables.
     48# We could change the patterns to actually match any definition / "value".)
     49case "$gmp_cc" in __MPIR_CC|"")
     50    gmp_cc=`sed -n -e "${gmp_cc_pat/GMP/MPIR}" "$gmp_header_file"`
     51esac
     52case "$gmp_cflags" in __MPIR_CFLAGS|"")
     53    gmp_cflags=`sed -n -e "${gmp_cflags_pat/GMP/MPIR}" "$gmp_header_file"`
     54esac
    4255
     56# Extract GMP's/MPIR's settings of CC and CFLAGS from a system-wide installation
     57# (if present); these are only printed, for informational purposes.
    4358system_gmp_h=""
    4459for incdir in /usr/include /usr/local/include; do
    4560    if [ -f $incdir/gmp.h ]; then
     
    4964if [ -n "$system_gmp_h" ]; then
    5065    system_gmp_cc=`sed -n -e "$gmp_cc_pat" $system_gmp_h`
    5166    system_gmp_cflags=`sed -n -e "$gmp_cflags_pat" $system_gmp_h`
     67    case "$system_gmp_cc" in __MPIR_CC|"")
     68        system_gmp_cc=`sed -n -e "${gmp_cc_pat/GMP/MPIR}" $system_gmp_h`
     69    esac
     70    case "$system_gmp_cflags" in __MPIR_CFLAGS|"")
     71        system_gmp_cflags=`sed -n -e "${gmp_cflags_pat/GMP/MPIR}" $system_gmp_h`
     72    esac
    5273fi
    5374
    54 cc_is_gcc=false
    55 if $CC -v 2>&1 | grep -i gcc &>/dev/null; then
    56     cc_is_gcc=true;
    57 fi
    58 
    5975
    6076if [ "$SAGE64" = yes ]; then
    61     echo "Building a 64-bit version of GMP-ECM"
     77    echo "Building a 64-bit version of GMP-ECM."
    6278    if [ -z "$CFLAG64" ]; then
    6379        CFLAG64=-m64
    6480    fi
    6581    CFLAGS="$CFLAGS $CFLAG64"
    6682    LDFLAGS="$LDFLAGS $CFLAG64"; export LDFLAGS
    67 else
    68     :;
    6983fi
    7084
    7185
     
    89103
    90104if [ "$SAGE_DEBUG" = yes ]; then
    91105    # Add debug symbols and disable optimization:
     106    echo >&2 "Warning: Setting SAGE_DEBUG=yes completely disables optimization."
    92107    CFLAGS="$CFLAGS -g -O0"
     108    echo "You may in addition (or instead) pass '--enable-assert' and/or"
     109    echo "'--enable-memory-debug' to GMP-ECM's 'configure' by setting (and"
     110    echo "of course exporting) ECM_EXTRA_OPTS accordingly."
    93111else
    94112    # Enable optimization, may be overridden by user settings:
    95113    case "`uname -srm | tr ' ' '-'`" in
     
    98116            # fails due to a bus error in Apple's 'ld' when trying
    99117            # to determine if global symbols are prefixed with an
    100118            # underscore (cf. http://trac.sagemath.org/sage_trac/ticket/5847#comment:35 ff.):
    101             echo "Warning: Disabling debug symbols on MacOS X 10.5" \
     119            echo >&2 "Warning: Disabling debug symbols on MacOS X 10.5" \
    102120                "PowerPC because of a linker (?) bug."
    103             echo "See http://trac.sagemath.org/sage_trac/ticket/5847#comment:35" \
     121            echo >&2 "See http://trac.sagemath.org/sage_trac/ticket/5847#comment:35" \
    104122                "ff. for details."
    105             echo ""
     123            echo >&2
    106124            CFLAGS="-O3 $CFLAGS"
    107125            ;;
    108126        *)
     
    111129fi
    112130
    113131
     132# Work around a bug in GCC 4.7.0 which breaks the build on Itanium CPUs with
     133# '-O3', '-O2' and '-O1' (cf. #12765, #12751, and the bug URL below.)
     134if [ "`uname -m`" = ia64 ] && [ "`testcc.sh $CC`" = GCC ]; then
     135    gcc_version=`$CC -dumpversion`
     136    case "$gcc_version" in
     137      4.7.*)
     138        CFLAGS="$CFLAGS -O0 -finline-functions -fschedule-insns"
     139        echo >&2 "Warning: Disabling almost all optimization due to a bug in (at least)"
     140        echo >&2 "         GCC 4.7.0 on Itanium, which otherwise would break the build."
     141        echo >&2 "         See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48496"
     142        echo >&2 "         for current status and further details."
     143        echo >&2 "         (And please report to e.g. sage-devel in case you feel this bug"
     144        echo >&2 "          should already be fixed in GCC $gcc_version.)"
     145    esac
     146fi
     147
     148
    114149if [ "$SAGE_FAT_BINARY" = yes ]; then
    115150    # XXX Disable SSE2 on x86? (by passing '--enable-sse2=no' to 'configure')
    116151    # XXX Disable asm-redc? Or pass some "generic" '--host=...' to 'configure'?
    117     echo "Warning: SAGE_FAT_BINARY is currently not really supported by this package."
    118     echo "         Add e.g. '--disable-asm-redc' and/or '--enable-sse2=no'"
    119     echo "         to ECM_EXTRA_OPTS if you run into problems."
     152    echo >&2 "Warning: SAGE_FAT_BINARY is currently not really supported by this package."
     153    echo >&2 "         Add e.g. '--disable-asm-redc' and/or '--enable-sse2=no'"
     154    echo >&2 "         to ECM_EXTRA_OPTS if you run into problems."
    120155else
    121156    # Tune the code generation to the machine we build on:
    122157    cpu_params=""; other_gmp_cflags=""
     
    124159    # Some gcc 4.0.x versions don't support '-march=native', and it's currently
    125160    # not supported on all platforms supported by Sage:
    126161    if touch foo.c && $CC -march=native -c foo.c &>/dev/null; then
    127         cpu_params="-march=native"
    128     else
     162        # The compiler supports '-march=native', but the assembler might not
     163        # support (some of) the instructions emitted with this (e.g. the
     164        # Apple assembler doesn't know AVX yet).
     165        cat >foo.c <<-"EOF"
     166                double d;
     167                unsigned long fancy_insns() { return (unsigned long) d; }
     168                int main () { return 0; }
     169        EOF
     170        if $CC -march=native -o foo foo.c &>/dev/null && ./foo >/dev/null; then
     171            cpu_params="-march=native"
     172        else
     173            echo >&2 "Warning: Your assembler apparently doesn't understand the instructions"
     174            echo >&2 "         your compiler ($CC) generates with '-march=native'."
     175            echo >&2 "         You might also try to compile GMP-ECM with (e.g.)"
     176            echo >&2 "             CFLAGS=\"-march=native -mno-avx\""
     177            echo >&2 "         to disable specific instruction set extension (in this case, AVX)."
     178        fi
     179    fi
     180    if [ -z "$cpu_params" ]; then
    129181        # 'native' not supported, see if GMP / MPIR provides us some CPU type:
    130182        for opt in $gmp_cflags; do
    131183            case $opt in
     
    138190            esac
    139191        done
    140192    fi
    141     rm -f foo.*
     193    rm -f foo.* foo
    142194    # Only add them if CFLAGS do not already contain similar:
    143195    if [ -n "$cpu_params" ] &&
    144196        ! (echo "$CFLAGS" | egrep -- '-march=|-mcpu=|-mtune=' >/dev/null);
     
    152204fi
    153205
    154206
    155 echo ""
     207echo
    156208echo "Settings from SAGE_LOCAL/include/gmp.h:"
    157 echo "    CC=$gmp_cc"
    158 echo "    CFLAGS=$gmp_cflags"
     209echo "  CC=$gmp_cc"
     210echo "  CFLAGS=$gmp_cflags"
    159211if [ -n "$system_gmp_h" ]; then
    160212    echo "Settings found in $system_gmp_h (currently not used):"
    161     echo "    CC=$system_gmp_cc"
    162     echo "    CFLAGS=$system_gmp_cflags"
     213    echo "  CC=$system_gmp_cc"
     214    echo "  CFLAGS=$system_gmp_cflags"
    163215fi
    164216
    165 echo "Using CC=$CC"
    166 echo "Using CFLAGS=$CFLAGS"
    167 echo "Using CPPFLAGS=$CPPFLAGS"
    168 echo "Using LDFLAGS=$LDFLAGS"
    169 echo "Using ABI=$ABI"
    170 echo "(These settings may get overridden by 'configure' or Makefiles.)"
    171 echo ""
     217echo "Finally using:"
     218echo "  CC=$CC"
     219echo "  CFLAGS=$CFLAGS"
     220echo "  CPP=$CPP"
     221echo "  CPPFLAGS=$CPPFLAGS"
     222test -n "$CCAS" && echo "  CCAS=$CCAS"
     223test -n "$CCASFLAGS" && echo "  CCASFLAGS=$CCASFLAGS"
     224echo "  LDFLAGS=$LDFLAGS"
     225test -n "$LIBS" && echo "  LIBS=$LIBS"
     226echo "  ABI=$ABI"
     227echo "  M4=$M4"
     228echo "(These settings may still get overridden by 'configure' or Makefiles.)"
    172229
    173 export CFLAGS # usually redundant, but safe(r)
     230export CFLAGS # Not exported by 'sage-env'.  LDFLAGS are exported above if
     231              # necessary.  We currently don't set (or modify) any other
     232              # environment variables, so don't have to export them here.
    174233
    175234unset RM
    176235
    177 cd src
    178 
    179236###############################################################################
    180237# Now configure ECM:
    181238# (Note: Building (also) a *shared* library is disabled by default.
     
    185242#        adapt the logic regarding '-fPIC' above.
    186243###############################################################################
    187244
    188 SAGE_CONF_OPTS=""
     245SAGE_CONF_OPTS="" # XXX Move this up in case you add options above!
    189246
    190 echo ""
     247echo
    191248if [ -z "$ECM_EXTRA_OPTS" ]; then
    192     echo "Configuring GMP-ECM with the following options:"
    193     echo "    --prefix=\"$SAGE_LOCAL\" --libdir=\"$SAGE_LOCAL/lib\" --with-gmp=\"$SAGE_LOCAL\"" \
    194         "$SAGE_CONF_OPTS"
     249    echo "Now configuring GMP-ECM with the following options:"
     250else
     251    echo "Now configuring GMP-ECM with additional options as specified by" \
     252        "ECM_EXTRA_OPTS:"
     253    echo "  $ECM_EXTRA_OPTS"
     254    echo "Finally configuring GMP-ECM with the following options:"
     255fi
     256echo "  --prefix=\"$SAGE_LOCAL\""
     257echo "  --libdir=\"$SAGE_LOCAL/lib\""
     258echo "  --with-gmp=\"$SAGE_LOCAL\""
     259for opt in $SAGE_CONF_OPTS $ECM_EXTRA_OPTS; do
     260    echo "  $opt"
     261done
     262if [ -z "$ECM_EXTRA_OPTS" ]; then
    195263    echo "You can set ECM_EXTRA_OPTS to pass additional parameters,"
    196264    echo "e.g. \"--enable-shared\" to also build a *shared* library,"
    197265    echo "or \"--disable-sse2\" if you encounter problems on a Pentium III system."
    198 else
    199     echo "Using additional 'configure' options as specified with" \
    200         "ECM_EXTRA_OPTS:"
    201     echo "    $ECM_EXTRA_OPTS"
    202     echo "Configuring ECM with the following options:"
    203     echo "    --prefix=\"$SAGE_LOCAL\" --libdir=\"$SAGE_LOCAL/lib\" --with-gmp=\"$SAGE_LOCAL\"" \
    204         "$SAGE_CONF_OPTS $ECM_EXTRA_OPTS"
    205266fi
    206 echo ""
     267echo
    207268
    208 ./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" --with-gmp="$SAGE_LOCAL" \
    209     $SAGE_CONF_OPTS $ECM_EXTRA_OPTS
     269./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" \
     270            --with-gmp="$SAGE_LOCAL" \
     271            $SAGE_CONF_OPTS $ECM_EXTRA_OPTS
    210272if [ $? -ne 0 ]; then
    211     echo "Error configuring GMP-ECM."
     273    echo >&2 "Error configuring GMP-ECM."
     274    echo >&2 "(See above for the options passed to its 'configure'.)"
    212275    exit 1
    213276fi
    214277
     
    216279# Now build ECM:
    217280###############################################################################
    218281
     282echo
     283echo "Now building GMP-ECM..."
    219284$MAKE
    220285if [ $? -ne 0 ]; then
    221     echo "Error building GMP-ECM."
     286    echo >&2 "Error building GMP-ECM."
    222287    exit 1
    223288fi
    224289
    225290###############################################################################
    226291# Remove old executable/header/libraries/manpage:
    227292###############################################################################
    228 echo "Build succeeded, removing old binary, header file, manual page and libraries..."
     293
     294echo
     295echo "Build succeeded.  Now removing old binary, header file, manual page and libraries..."
    229296rm -f "$SAGE_LOCAL"/bin/ecm
    230297rm -f "$SAGE_LOCAL"/lib/libecm.*
    231298rm -f "$SAGE_LOCAL"/include/ecm.h
     
    235302# Now install ECM:
    236303###############################################################################
    237304
     305echo "Now installing GMP-ECM..."
    238306$MAKE install
    239307if [ $? -ne 0 ]; then
    240     echo "Error installing GMP-ECM (though it appears to have built fine)."
     308    echo >&2 "Error installing GMP-ECM (though it appears to have built fine)."
    241309    exit 1
    242310fi