diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -1,3 +1,1 @@
 src
-patches/configure
-patches/configure.in
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -1,3 +1,5 @@
 4fb2b9ca03a2973d035fad8c9cfe6062c79cc6f2 ecm-6.3.p2
 4d6646f19caecfa0810d3341a8a1361cb529a7b4 ecm-6.3.p3
 62e5a142f7157c6dfa8ab59fc9228208326507ad ecm-6.3.p4
+14c0237361c1ffefdcece11d745f3381ec009a46 ecm-6.3.p5
+7ac46fc5997fb25668f35b8571f48af69f5859f4 ecm-6.3.p6
diff --git a/SPKG.txt b/SPKG.txt
--- a/SPKG.txt
+++ b/SPKG.txt
@@ -21,13 +21,18 @@
 == Dependencies ==
 
  * GMP/MPIR (Note: Python is *not* required for ordinary builds.)
+ * GNU patch
 
 == Special Update/Build Instructions ==
 
- * src/ contains "stable" upstream code, to which we currently apply
-   two upstream patches (both to 'configure.in'). These (i.e. the
-   files 'patches/configure.in' and 'patches/configure') should be
-   removed on the next upgrade to a stable release.
+ * src/ contains "stable" upstream code, to which we currently apply a single
+   upstream patch (to 'configure'). The patch should be removed on the next
+   upgrade to a stable release.
+   Note that all autotools-generated files (and their support files) in src/
+   have been regenerated with newer versions of autotools (autoconf 2.68,
+   automake 1.11.3 and libtool 2.4.2), to make the size of the patch to the
+   also generated `configure` acceptable.  (See "Patches" section below for
+   why we don't patch `configure.in`, from which `configure` is created.)
  * GMP-ECM comes with a self-tuning feature; we could support
    that as an option ($SAGE_TUNE_*=yes) in the future.
  * We currently work around a linker bug on MacOS X 10.5 PPC (with
@@ -35,10 +40,9 @@
    This *might* get fixed in later upstream releases.
  * ECM currently does not (by itself) use the CC and CFLAGS settings
    from 'gmp.h' since we pass (other) options in CFLAGS, and CC is set
-   by Sage and might got set by the user (though MPIR currently doesn't
-   use its own CFLAGS for the same reason, which is fixed in an MPIR
-   2.1.3.p2 spkg). We now at least partially fix that s.t. "optimized"
-   code generation options ('-mcpu=...', '-mtune=...') are used by gcc.
+   by Sage and might got set by the user.  We now at least partially fix that
+   such that "optimized" code generation options ('-mcpu=...', '-mtune=...')
+   are used by gcc.
    Of course a user can also manually enable them by setting the "global"
    CFLAGS to e.g. '-march=native' on x86[_64] systems, or '-mcpu=...' and
    '-mtune=...' on other architectures where "native" isn't supported.
@@ -50,9 +54,70 @@
    "-mcpu=...", and perhaps pass a more generic "--host=..." to 
    'configure'. (MPIR honors '--enable-fat' to some extent, but this
    option isn't used on anything other than x86 / x86_64.)
+ * Check whether the work-around for GCC 4.7 on ia64 is still appropriate, i.e.
+   adapt it in case the issue has been fixed in later GCC versions of the 4.7
+   release series.  (Although the bug currently affects only GCC 4.7.0, it
+   seems unlikely that it will be fixed soon, hence we apply the work-around
+   for any GCC 4.7.x version on ia64.)
+   See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48496 for details and the
+   current status of that bug.
+ * We could save some space by removing the `src/build.vc9/` directory which
+   isn't used in Sage.  (It gets probably more worth in case also directories /
+   files for later versions of Microsoft Visual C get added.) 
+
+=== Patches ===
+ * configure.patch:
+   - Disable "asm-redc" on 32-bit Darwin PPCs (upstream revision 1516 / bug
+     #10646).
+     (Note that this upstream patch is likely to slow down GMP-ECM on 64-bit
+     PPC CPUs running (32-bit) MacOS X, since the extended instruction set of
+     the CPU is no longer exploitet.  A proper fix would just pass an option
+     to Apple's assembler to allow the use of the extended instruction set.)  
+   - Fix compilation error on x86 CPUs supporting SSE2. (Sage trac #10252,
+     upstream revision 1546).
+   Note that we don't patch `configure.in`, since it is only needed to generate
+   automatically-generated files in the source tree.  Patching `configure.in`
+   would force `automake` to be run, which could cause build failures on
+   systems where autotools aren't installed.
+
 
 == Changelog ==
 
+=== ecm-6.3.p6 (Leif Leonhardy, April 16th 2012) ===
+ * #12830: Add a work-around for GCC 4.7.x on ia64 (Itanium), since GMP-ECM
+   currently won't build with that and anything but `-O0` on that platform.
+ * Use `\{1,\}` instead of `\+` in `sed` patterns, which is more portable.
+ * Also support newer system-wide MPIR installations for printing their
+   settings.
+ * Use `patch` to apply patches.  Since the pre-patched `configure` in
+   `patches/` was created with a newer version of autotools (or, rather, the
+   original `configure` was created with an outdated version), the patch would
+   have been almost as large as the patched `configure` file itself.  Hence
+   I `autoreconf`ed the source tree with a patched `configure.in` (and almost
+   the latest versions of autotools), then created a patch to `configure`
+   from the resulting file(s).  Note that therefore `src/` isn't really vanilla
+   any more, although just the auto-generated files differ (which are still
+   made from vanilla upstream sources, including `configure.in`).
+   Add a "Patches" subsection and update "Special Update/Build Instructions".
+   Remove files in `patches/` from `.hgignore` (and also remove pre-patched
+   files from that directory); the patch to `configure` and the diff of
+   `configure.in` are [now] under revision control, which IMHO makes sense.
+ * Beautify (and simplify) the output with respect to options passed to
+   `configure`; print the settings of a few more environment variables that
+   GMP-ECM uses (in case they're set); add some messages, also mention
+   `--enable-assert` etc. if `SAGE_DEBUG=yes`.
+ * Remove unused test for GCC.
+
+=== ecm-6.3.p5 (Leif Leonhardy, April 11th 2012) ===
+ * #12830: Don't add `-march=native` if the assembler doesn't understand the
+   instructions the compiler emits with that.  (E.g. the Apple/XCode assembler
+   on Darwin doesn't yet support AVX.)
+ * Fix extraction of `__GMP_CC` and `__GMP_CFLAGS` (from `gmp.h`) for newer
+   versions of MPIR, which define these to preprocessor macros rather than
+   strings.
+ * Redirect warnings and error messages to `stderr`; add some messages.
+ * Correct `SPKG.txt` w.r.t. applied patches.
+
 === ecm-6.3.p4 (Jeroen Demeyer, 13 February 2012) ===
  * #12501: Do not patch configure.in in spkg-install (to prevent
    automake from running).
diff --git a/patches/configure.patch b/patches/configure.patch
new file mode 100644
--- /dev/null
+++ b/patches/configure.patch
@@ -0,0 +1,85 @@
+--- src/configure	2012-04-16 21:51:42.586783117 +0200
++++ src-patched/configure	2012-04-16 22:13:59.096783235 +0200
+@@ -12343,7 +12343,7 @@
+ # asm_redc enabled by default for x86_64 and 64 bit PowerPC
+ if test "x$enable_asm_redc" = x; then
+   case $host in
+-    x86_64* | powerpc-apple-darwin* | powerpc64-*-linux*) enable_asm_redc=yes;;
++    x86_64*-*-* | powerpc-apple-darwin* | powerpc64-*-linux*) enable_asm_redc=yes;;
+     *) enable_asm_redc=no;;
+   esac
+ fi
+@@ -12351,8 +12351,35 @@
+ if test "x$enable_asm_redc" = xyes; then
+   case $host in
+     pentium4-*-* | pentium3-*-* | viac7-*-* | i786-*-*) ASMPATH=pentium4;;
+-    x86_64-*-*)  ASMPATH=x86_64;;
+-    powerpc-apple-darwin*) ASMPATH=powerpc64;;
++    x86_64*-*-*)  ASMPATH=x86_64;;
++# warning: with powerpc-apple-darwin* we can have ABI=32
++# see bug #10646 on the bug tracker, where config.guess says
++# powerpc-apple-darwin8.11.0 (this a 64-bit machine, but most applications
++# are compiled in 32 bits). It works with --disable-asm-redc.
++    powerpc-apple-darwin*)
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h.  */
++
++#if defined(__ppc__)
++#error
++#endif
++int
++main ()
++{
++
++  ;
++  return 0;
++}
++_ACEOF
++if ac_fn_c_try_cpp "$LINENO"; then :
++
++else
++  { $as_echo "$as_me:${as_lineno-$LINENO}: 32-bit PowerPC, disabling asm-redc" >&5
++$as_echo "$as_me: 32-bit PowerPC, disabling asm-redc" >&6;}
++                enable_asm_redc=no
++fi
++rm -f conftest.err conftest.i conftest.$ac_ext
++                          ASMPATH=powerpc64;;
+     powerpc64-*-linux*)
+ 
+ echo "include(<"$srcdir"/powerpc64/powerpc-defs.m4>)" >> $gmp_tmpconfigm4
+@@ -12363,7 +12390,9 @@
+     		   	  ASMPATH=athlon;;
+     *) as_fn_error $? "asm redc not available on this machine $host" "$LINENO" 5;;
+   esac
++fi
+ 
++if test "x$enable_asm_redc" = xyes; then
+ # do the necessary definitions and includes
+ 
+ $as_echo "#define NATIVE_REDC 1" >>confdefs.h
+@@ -12684,9 +12713,9 @@
+ main ()
+ {
+ #if (defined(__GNUC__) || defined(__ICL)) && defined(__i386__)
+-/* When there are no constraints, registers are referred to by
+-   single % sign, not double. Argh */
+-asm volatile ("pmuludq %xmm2, %xmm0");
++/* On some machines, a program without constraints may pass without -msse2 but
++   those with constraints in spv.c fail, thus we test with constraints here. */
++asm volatile ("pmuludq %%xmm2, %%xmm0" : : :"%xmm0");
+ #else
+ #error
+ #IRIXdoesnotexitaterrordirective
+@@ -12708,9 +12737,9 @@
+ main ()
+ {
+ #if (defined(__GNUC__) || defined(__ICL)) && defined(__i386__)
+-/* When there are no constraints, registers are referred to by
+-   single % sign, not double. Argh */
+-asm volatile ("pmuludq %xmm2, %xmm0");
++/* On some machines, a program without constraints may pass without -msse2 but
++   those with constraints in spv.c fail, thus we test with constraints here. */
++asm volatile ("pmuludq %%xmm2, %%xmm0" : : :"%xmm0");
+ #else
+ #error
+ #IRIXdoesnotexitaterrordirective
diff --git a/spkg-check b/spkg-check
--- a/spkg-check
+++ b/spkg-check
@@ -1,22 +1,24 @@
 #!/usr/bin/env bash
 
 if [ -z "$SAGE_LOCAL" ]; then
-    echo "Error: SAGE_LOCAL undefined - exiting..."
+    echo >&2 "Error: SAGE_LOCAL undefined - exiting..."
     exit 1
 fi
 
 # Note: Running the test suite should not involve (re)compilation,
-#       so we don't set CFLAGS et al. here.
+#       so we don't set CFLAGS et al. here.  (Their settings are
+#       stored in the Makefiles created by 'configure' anyway.)
 
 cd src
 
-echo "Running the GMP-ECM test suite..."
+echo
+echo "Now running GMP-ECM's test suite..."
 
 $MAKE check
 
 if [ $? -ne 0 ]; then
-    echo "Error: The GMP-ECM test suite failed."
+    echo >&2 "Error: GMP-ECM's test suite failed."
     exit 1
 fi
 
-echo "The GMP-ECM test suite passed."
+echo "GMP-ECM's test suite passed."
diff --git a/spkg-install b/spkg-install
--- a/spkg-install
+++ b/spkg-install
@@ -1,28 +1,27 @@
 #!/usr/bin/env bash
 
 if [ -z "$SAGE_LOCAL" ]; then
-    echo "Error: SAGE_LOCAL undefined - exiting..."
+    echo >&2 "Error: SAGE_LOCAL undefined - exiting..."
     exit 1
 fi
 
+cd src/
+
 ###############################################################################
 # Apply patches (if any):
 ###############################################################################
 
-# Patch configure (and configure.in):
-# - Disable asm-redc on 32-bit Darwin PPCs (upstream revision 1516 / bug #10646)
-# - Fix compilation error on x86 CPUs supporting SSE2. (Sage trac #10252,
-#   upstream revision 1546)
-echo "Copying patched files..."
-# Note that we don't patch configure.in here, since it is only needed
-# to generate automatically-generated files in the source tree.
-# Patching configure.in forces automake to be run, which may cause
-# build failures on systems where autotools aren't installed.
-cp -p patches/configure src/
-if [ $? -ne 0 ]; then
-    echo "Error copying patched configure."
-    exit 1
-fi
+ls ../patches/*.patch &>/dev/null &&
+echo "Applying patches to upstream sources..." &&
+for patch in ../patches/*.patch; do
+    basename "$patch"
+    patch -p1 <"$patch"
+    if [ $? -ne 0 ]; then
+        echo >&2 "Error: '$patch' failed to apply."
+        exit 1
+    fi
+done &&
+echo
 
 ###############################################################################
 # Set up environment variables, depending on SAGE_* settings:
@@ -34,12 +33,28 @@
 # processor-specific code, since ECM doesn't use them if we set our own:
 # (But currently MPIR doesn't provide optimized settings either if we pass
 # non-empty CFLAGS; of course the user could set such manually though.)
-gmp_cc_pat='/^[ 	]*#[ 	]*define[ 	]\+__GMP_CC[ 	]\+/s/.*"\([^"]*\)"/\1/p'
-gmp_cflags_pat='/^[ 	]*#[ 	]*define[ 	]\+__GMP_CFLAGS[ 	]\+/s/.*"\([^"]*\)"/\1/p'
+gmp_cc_pat='/^[ 	]*#[ 	]*define[ 	]\{1,\}__GMP_CC[ 	]\{1,\}/s/.*"\([^"]*\)"/\1/p'
+gmp_cflags_pat='/^[ 	]*#[ 	]*define[ 	]\{1,\}__GMP_CFLAGS[ 	]\{1,\}/s/.*"\([^"]*\)"/\1/p'
+gmp_header_file="$SAGE_LOCAL"/include/gmp.h
 
-gmp_cc=`sed -n -e "$gmp_cc_pat" "$SAGE_LOCAL"/include/gmp.h`
-gmp_cflags=`sed -n -e "$gmp_cflags_pat" "$SAGE_LOCAL"/include/gmp.h`
+gmp_cc=`sed -n -e "$gmp_cc_pat" "$gmp_header_file"`
+gmp_cflags=`sed -n -e "$gmp_cflags_pat" "$gmp_header_file"`
+# At least /some/ newer versions of MPIR define __GMP_CC and __GMP_CFLAGS
+# (also in gmp.h! -- how compatible is that?) to (literally) __MPIR_CC and
+# __MPIR_CFLAGS, respectively, i.e., to preprocessor variables, so we might
+# have to get the real strings from their definitions:
+# (Since we currently only match string literals above, both variables would
+# be empty in that case, and not contain the names of preprocessor variables.
+# We could change the patterns to actually match any definition / "value".) 
+case "$gmp_cc" in __MPIR_CC|"")
+    gmp_cc=`sed -n -e "${gmp_cc_pat/GMP/MPIR}" "$gmp_header_file"`
+esac
+case "$gmp_cflags" in __MPIR_CFLAGS|"")
+    gmp_cflags=`sed -n -e "${gmp_cflags_pat/GMP/MPIR}" "$gmp_header_file"`
+esac
 
+# Extract GMP's/MPIR's settings of CC and CFLAGS from a system-wide installation
+# (if present); these are only printed, for informational purposes.
 system_gmp_h=""
 for incdir in /usr/include /usr/local/include; do
     if [ -f $incdir/gmp.h ]; then
@@ -49,23 +64,22 @@
 if [ -n "$system_gmp_h" ]; then
     system_gmp_cc=`sed -n -e "$gmp_cc_pat" $system_gmp_h`
     system_gmp_cflags=`sed -n -e "$gmp_cflags_pat" $system_gmp_h`
+    case "$system_gmp_cc" in __MPIR_CC|"")
+        system_gmp_cc=`sed -n -e "${gmp_cc_pat/GMP/MPIR}" $system_gmp_h`
+    esac
+    case "$system_gmp_cflags" in __MPIR_CFLAGS|"")
+        system_gmp_cflags=`sed -n -e "${gmp_cflags_pat/GMP/MPIR}" $system_gmp_h`
+    esac
 fi
 
-cc_is_gcc=false
-if $CC -v 2>&1 | grep -i gcc &>/dev/null; then
-    cc_is_gcc=true;
-fi
-
 
 if [ "$SAGE64" = yes ]; then
-    echo "Building a 64-bit version of GMP-ECM"
+    echo "Building a 64-bit version of GMP-ECM."
     if [ -z "$CFLAG64" ]; then
         CFLAG64=-m64
     fi
     CFLAGS="$CFLAGS $CFLAG64"
     LDFLAGS="$LDFLAGS $CFLAG64"; export LDFLAGS
-else
-    :;
 fi
 
 
@@ -89,7 +103,11 @@
 
 if [ "$SAGE_DEBUG" = yes ]; then
     # Add debug symbols and disable optimization:
+    echo >&2 "Warning: Setting SAGE_DEBUG=yes completely disables optimization."
     CFLAGS="$CFLAGS -g -O0"
+    echo "You may in addition (or instead) pass '--enable-assert' and/or"
+    echo "'--enable-memory-debug' to GMP-ECM's 'configure' by setting (and"
+    echo "of course exporting) ECM_EXTRA_OPTS accordingly."
 else
     # Enable optimization, may be overridden by user settings:
     case "`uname -srm | tr ' ' '-'`" in
@@ -98,11 +116,11 @@
             # fails due to a bus error in Apple's 'ld' when trying
             # to determine if global symbols are prefixed with an
             # underscore (cf. http://trac.sagemath.org/sage_trac/ticket/5847#comment:35 ff.):
-            echo "Warning: Disabling debug symbols on MacOS X 10.5" \
+            echo >&2 "Warning: Disabling debug symbols on MacOS X 10.5" \
                 "PowerPC because of a linker (?) bug."
-            echo "See http://trac.sagemath.org/sage_trac/ticket/5847#comment:35" \
+            echo >&2 "See http://trac.sagemath.org/sage_trac/ticket/5847#comment:35" \
                 "ff. for details."
-            echo ""
+            echo >&2
             CFLAGS="-O3 $CFLAGS"
             ;;
         *)
@@ -111,12 +129,29 @@
 fi
 
 
+# Work around a bug in GCC 4.7.0 which breaks the build on Itanium CPUs with
+# '-O3', '-O2' and '-O1' (cf. #12765, #12751, and the bug URL below.)
+if [ "`uname -m`" = ia64 ] && [ "`testcc.sh $CC`" = GCC ]; then
+    gcc_version=`$CC -dumpversion`
+    case "$gcc_version" in
+      4.7.*)
+        CFLAGS="$CFLAGS -O0 -finline-functions -fschedule-insns"
+        echo >&2 "Warning: Disabling almost all optimization due to a bug in (at least)"
+        echo >&2 "         GCC 4.7.0 on Itanium, which otherwise would break the build."
+        echo >&2 "         See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48496"
+        echo >&2 "         for current status and further details."
+        echo >&2 "         (And please report to e.g. sage-devel in case you feel this bug"
+        echo >&2 "          should already be fixed in GCC $gcc_version.)"
+    esac
+fi
+
+
 if [ "$SAGE_FAT_BINARY" = yes ]; then
     # XXX Disable SSE2 on x86? (by passing '--enable-sse2=no' to 'configure')
     # XXX Disable asm-redc? Or pass some "generic" '--host=...' to 'configure'?
-    echo "Warning: SAGE_FAT_BINARY is currently not really supported by this package."
-    echo "         Add e.g. '--disable-asm-redc' and/or '--enable-sse2=no'"
-    echo "         to ECM_EXTRA_OPTS if you run into problems."
+    echo >&2 "Warning: SAGE_FAT_BINARY is currently not really supported by this package."
+    echo >&2 "         Add e.g. '--disable-asm-redc' and/or '--enable-sse2=no'"
+    echo >&2 "         to ECM_EXTRA_OPTS if you run into problems."
 else
     # Tune the code generation to the machine we build on:
     cpu_params=""; other_gmp_cflags=""
@@ -124,8 +159,25 @@
     # Some gcc 4.0.x versions don't support '-march=native', and it's currently
     # not supported on all platforms supported by Sage:
     if touch foo.c && $CC -march=native -c foo.c &>/dev/null; then
-        cpu_params="-march=native"
-    else
+        # The compiler supports '-march=native', but the assembler might not
+        # support (some of) the instructions emitted with this (e.g. the
+        # Apple assembler doesn't know AVX yet).
+        cat >foo.c <<-"EOF"
+		double d;
+		unsigned long fancy_insns() { return (unsigned long) d; }
+		int main () { return 0; }
+	EOF
+        if $CC -march=native -o foo foo.c &>/dev/null && ./foo >/dev/null; then
+            cpu_params="-march=native"
+        else
+            echo >&2 "Warning: Your assembler apparently doesn't understand the instructions"
+            echo >&2 "         your compiler ($CC) generates with '-march=native'."
+            echo >&2 "         You might also try to compile GMP-ECM with (e.g.)"
+            echo >&2 "             CFLAGS=\"-march=native -mno-avx\""
+            echo >&2 "         to disable specific instruction set extension (in this case, AVX)."
+        fi
+    fi
+    if [ -z "$cpu_params" ]; then
         # 'native' not supported, see if GMP / MPIR provides us some CPU type:
         for opt in $gmp_cflags; do
             case $opt in
@@ -138,7 +190,7 @@
             esac
         done
     fi
-    rm -f foo.*
+    rm -f foo.* foo
     # Only add them if CFLAGS do not already contain similar:
     if [ -n "$cpu_params" ] &&
         ! (echo "$CFLAGS" | egrep -- '-march=|-mcpu=|-mtune=' >/dev/null);
@@ -152,30 +204,35 @@
 fi
 
 
-echo ""
+echo
 echo "Settings from SAGE_LOCAL/include/gmp.h:"
-echo "    CC=$gmp_cc"
-echo "    CFLAGS=$gmp_cflags"
+echo "  CC=$gmp_cc"
+echo "  CFLAGS=$gmp_cflags"
 if [ -n "$system_gmp_h" ]; then
     echo "Settings found in $system_gmp_h (currently not used):"
-    echo "    CC=$system_gmp_cc"
-    echo "    CFLAGS=$system_gmp_cflags"
+    echo "  CC=$system_gmp_cc"
+    echo "  CFLAGS=$system_gmp_cflags"
 fi
 
-echo "Using CC=$CC"
-echo "Using CFLAGS=$CFLAGS"
-echo "Using CPPFLAGS=$CPPFLAGS"
-echo "Using LDFLAGS=$LDFLAGS"
-echo "Using ABI=$ABI"
-echo "(These settings may get overridden by 'configure' or Makefiles.)"
-echo ""
+echo "Finally using:"
+echo "  CC=$CC"
+echo "  CFLAGS=$CFLAGS"
+echo "  CPP=$CPP"
+echo "  CPPFLAGS=$CPPFLAGS"
+test -n "$CCAS" && echo "  CCAS=$CCAS"
+test -n "$CCASFLAGS" && echo "  CCASFLAGS=$CCASFLAGS"
+echo "  LDFLAGS=$LDFLAGS"
+test -n "$LIBS" && echo "  LIBS=$LIBS"
+echo "  ABI=$ABI"
+echo "  M4=$M4"
+echo "(These settings may still get overridden by 'configure' or Makefiles.)"
 
-export CFLAGS # usually redundant, but safe(r)
+export CFLAGS # Not exported by 'sage-env'.  LDFLAGS are exported above if
+              # necessary.  We currently don't set (or modify) any other
+              # environment variables, so don't have to export them here.
 
 unset RM
 
-cd src
-
 ###############################################################################
 # Now configure ECM:
 # (Note: Building (also) a *shared* library is disabled by default.
@@ -185,30 +242,36 @@
 #        adapt the logic regarding '-fPIC' above.
 ###############################################################################
 
-SAGE_CONF_OPTS=""
+SAGE_CONF_OPTS="" # XXX Move this up in case you add options above!
 
-echo ""
+echo
 if [ -z "$ECM_EXTRA_OPTS" ]; then
-    echo "Configuring GMP-ECM with the following options:"
-    echo "    --prefix=\"$SAGE_LOCAL\" --libdir=\"$SAGE_LOCAL/lib\" --with-gmp=\"$SAGE_LOCAL\"" \
-        "$SAGE_CONF_OPTS"
+    echo "Now configuring GMP-ECM with the following options:"
+else
+    echo "Now configuring GMP-ECM with additional options as specified by" \
+        "ECM_EXTRA_OPTS:"
+    echo "  $ECM_EXTRA_OPTS"
+    echo "Finally configuring GMP-ECM with the following options:"
+fi
+echo "  --prefix=\"$SAGE_LOCAL\""
+echo "  --libdir=\"$SAGE_LOCAL/lib\""
+echo "  --with-gmp=\"$SAGE_LOCAL\""
+for opt in $SAGE_CONF_OPTS $ECM_EXTRA_OPTS; do
+    echo "  $opt"
+done
+if [ -z "$ECM_EXTRA_OPTS" ]; then
     echo "You can set ECM_EXTRA_OPTS to pass additional parameters,"
     echo "e.g. \"--enable-shared\" to also build a *shared* library,"
     echo "or \"--disable-sse2\" if you encounter problems on a Pentium III system."
-else
-    echo "Using additional 'configure' options as specified with" \
-        "ECM_EXTRA_OPTS:"
-    echo "    $ECM_EXTRA_OPTS"
-    echo "Configuring ECM with the following options:"
-    echo "    --prefix=\"$SAGE_LOCAL\" --libdir=\"$SAGE_LOCAL/lib\" --with-gmp=\"$SAGE_LOCAL\"" \
-        "$SAGE_CONF_OPTS $ECM_EXTRA_OPTS"
 fi
-echo ""
+echo
 
-./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" --with-gmp="$SAGE_LOCAL" \
-    $SAGE_CONF_OPTS $ECM_EXTRA_OPTS
+./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" \
+            --with-gmp="$SAGE_LOCAL" \
+            $SAGE_CONF_OPTS $ECM_EXTRA_OPTS
 if [ $? -ne 0 ]; then
-    echo "Error configuring GMP-ECM."
+    echo >&2 "Error configuring GMP-ECM."
+    echo >&2 "(See above for the options passed to its 'configure'.)"
     exit 1
 fi
 
@@ -216,16 +279,20 @@
 # Now build ECM:
 ###############################################################################
 
+echo
+echo "Now building GMP-ECM..."
 $MAKE
 if [ $? -ne 0 ]; then
-    echo "Error building GMP-ECM."
+    echo >&2 "Error building GMP-ECM."
     exit 1
 fi
 
 ###############################################################################
 # Remove old executable/header/libraries/manpage:
 ###############################################################################
-echo "Build succeeded, removing old binary, header file, manual page and libraries..."
+
+echo
+echo "Build succeeded.  Now removing old binary, header file, manual page and libraries..."
 rm -f "$SAGE_LOCAL"/bin/ecm
 rm -f "$SAGE_LOCAL"/lib/libecm.*
 rm -f "$SAGE_LOCAL"/include/ecm.h
@@ -235,8 +302,9 @@
 # Now install ECM:
 ###############################################################################
 
+echo "Now installing GMP-ECM..."
 $MAKE install
 if [ $? -ne 0 ]; then
-    echo "Error installing GMP-ECM (though it appears to have built fine)."
+    echo >&2 "Error installing GMP-ECM (though it appears to have built fine)."
     exit 1
 fi
