Ticket #9860: trac_9860-pari-2.4.3.svn-12577.p4-p5.spkg.patch

File trac_9860-pari-2.4.3.svn-12577.p4-p5.spkg.patch, 35.0 KB (added by leif, 10 years ago)

Apply to pari-2.4.3.svn-12577.p4.spkg. Note that added/changed files in patches/files are not included here!

  • SPKG.txt

    # HG changeset patch
    # User Leif Leonhardy <not.really@online.de>
    # Date 1283773823 -7200
    # Node ID d4c104308548c136e069b35759820ce527f41ca6
    # Parent  2d46a19aa9f4a949327cc743c4658c675d078352
    #9860: Ported changes from PARI 2.3.5.p4 (#9722) to 2.4.3; some further improvements.
    
    === pari-2.4.3.svn-12577.p5 (Leif Leonhardy, September 5th, 2010) ===
     * Added patches to:
       - config/get_config_options:
         * Make invalid arguments to "--graphic" a "Configure" error
           (rather than potentially running into *compilation* errors
           later).
       - config/get_fltk: (see also/ported from #9722)
         * Add libstdc++ to the libraries (to support Fedora 13 et al.).
         * Also check the presence of the FLTK include directory to
           prevent compilation errors on broken installations.
       - config/get_X11: (see also/ported from #9722)
         * Also search */lib64/* directories when doing a 64-bit build.
         * Give more specific messages.
     * Slightly extended existing patch to src/kernel/gmp/mp.c:
       - Allow disabling PARI's use of "GMP internals" by preprocessor
         directive (i.e. by adding "-DPARI_DONT_USE_GMP_INTERNALS" to
         CFLAGS). Brief explanation added.
     * spkg-install:
       - Don't override user-specified CFLAGS (w.r.t. optimization, unless
         SAGE_DEBUG=yes).
       - Handle PARI_EXTRA_OPTS properly, and print informative messages
         (regarding graphics support for plotting).
       - Recognize SAGE_TUNE_PARI in addition to SAGE_TUNE_pari, and
         add "--tune" to PARI_EXTRA_OPTS if self-tuning was requested.
       - Clear/unset lots of (environment) variables used by PARI that might
         unintentionally get their values from user settings.
       - Quote *all* occurrences of SAGE_LOCAL (and some other expressions).
       - Use $UNAME instead of `uname` everywhere, use "elif ...".
       - *Always* use $MAKE (changed for "install-data").
       - Begin all error messages with "Error".
       - Removed useless tests of $? at end.
       - Some clean-up (typos, formatting); some comments, some messages added.
     * spkg-check:
       - Use $MAKE instead of "make".
       - Don't override user-specified CFLAGS (w.r.t. optimization, unless
         SAGE_DEBUG=yes).
       - Begin error message with "Error".
       - Some clean-up.
     * Slight corrections to SPKG.txt.
     * Updated patches/README.txt, some cosmetic changes.
    
    diff -r 2d46a19aa9f4 -r d4c104308548 SPKG.txt
    a b  
    1818
    1919== License ==
    2020
    21 GPL
     21GPL version 2+
    2222
    2323== SPKG Maintainers ==
    2424 * Robert Bradshaw
     
    3636 * Readline
    3737 * Termcap
    3838
    39 == Build Notes ==
     39== Special Update/Build Instructions ==
    4040
    4141Most of the building of a new version of the PARI spkg is automated
    4242in the script spkg-make.  Normally, the following should work.  In case
     
    7171
    7272Note from David Kirkby that could be relevant to building on Solaris:
    7373
    74 Since pari is using -xarch=native, which implies -xarch=v8plusa on my
     74Since PARI is using -xarch=native, which implies -xarch=v8plusa on my
    7575box, but I set -xarch=v8plus (without the last a), this probably means
    7676there will be different types of object files and so they may not link
    7777together.  Ick.  Feel free to tell me how to modify the configure
    7878script.
    7979
    8080I got around it by setting CFLAGS -xarch=v8plus myself, so they were
    81 all the same. But it is not right. I have not looked at pari to see
     81all the same. But it is not right. I have not looked at PARI to see
    8282exactly where it says native, but I would expect a grep to find it.
    8383
    8484== Changelog ==
    8585
     86=== pari-2.4.3.svn-12577.p5 (Leif Leonhardy, September 5th, 2010) ===
     87 * Added patches to:
     88   - config/get_config_options:
     89     * Make invalid arguments to "--graphic" a "Configure" error
     90       (rather than potentially running into *compilation* errors
     91       later).
     92   - config/get_fltk: (see also/ported from #9722)
     93     * Add libstdc++ to the libraries (to support Fedora 13 et al.).
     94     * Also check the presence of the FLTK include directory to
     95       prevent compilation errors on broken installations.
     96   - config/get_X11: (see also/ported from #9722)
     97     * Also search */lib64/* directories when doing a 64-bit build.
     98     * Give more specific messages.
     99 * Slightly extended existing patch to src/kernel/gmp/mp.c:
     100   - Allow disabling PARI's use of "GMP internals" by preprocessor
     101     directive (i.e. by adding "-DPARI_DONT_USE_GMP_INTERNALS" to
     102     CFLAGS). Brief explanation added.
     103 * spkg-install:
     104   - Don't override user-specified CFLAGS (w.r.t. optimization, unless
     105     SAGE_DEBUG=yes).
     106   - Handle PARI_EXTRA_OPTS properly, and print informative messages
     107     (regarding graphics support for plotting).
     108   - Recognize SAGE_TUNE_PARI in addition to SAGE_TUNE_pari, and
     109     add "--tune" to PARI_EXTRA_OPTS if self-tuning was requested.
     110   - Clear/unset lots of (environment) variables used by PARI that might
     111     unintentionally get their values from user settings.
     112   - Quote *all* occurrences of SAGE_LOCAL (and some other expressions).
     113   - Use $UNAME instead of `uname` everywhere, use "elif ...".
     114   - *Always* use $MAKE (changed for "install-data").
     115   - Begin all error messages with "Error".
     116   - Removed useless tests of $? at end.
     117   - Some clean-up (typos, formatting); some comments, some messages added.
     118 * spkg-check:
     119   - Use $MAKE instead of "make".
     120   - Don't override user-specified CFLAGS (w.r.t. optimization, unless
     121     SAGE_DEBUG=yes).
     122   - Begin error message with "Error".
     123   - Some clean-up.
     124 * Slight corrections to SPKG.txt.
     125 * Updated patches/README.txt, some cosmetic changes.
     126
    86127=== pari-2.4.3.svn-12577.p4 (Jeroen Demeyer, August 22, 2010) ===
    87128 * Change "test -e" to "test -f" for Solaris.
    88129 * Configure using "#!/usr/bin/env bash" instead of "#!/bin/sh"
  • patches/README.txt

    diff -r 2d46a19aa9f4 -r d4c104308548 patches/README.txt
    a b  
    11Details of which source files are patched in spkg-install, and why.
    22See below for information on files which used to be patched but are no
    3 longer (do not delete that!)
     3longer, or are still but now for a different reason. (Do not delete that!)
    44
    55======================================================================
    6 Files patched as of pari-2.4.3.svn-12577.p4:
     6Files patched as of pari-2.4.3.svn-12577.p5:
    77======================================================================
    88
    99Configuration files:
    10 * Configure: use "#!/usr/bin/env bash" instead of "#!/bin/sh"
    11 * config/get_ld: cwitty: disable -rpath
    12 * config/get_tests: John Cremona: disable testing of ellglobalred in
     10* Configure: Use "#!/usr/bin/env bash" instead of "#!/bin/sh".
     11* config/get_ld: cwitty: Disable -rpath.
     12* config/get_tests: John Cremona: Disable testing of ellglobalred in
    1313                    "make test-all" in spkg-check, since it requires
    1414                    the elldata database which we do not include.
    1515* config/get_dlcflags: Add -fno-common to DLCFLAGS on Darwin.
    1616* config/Makefile.SH: Change "test -e" to "test -f" for Solaris.
     17* config/get_config_options: Catch invalid arguments tp "--graphic".
     18* config/get_fltk; Add libstdc++; check presence of FLTK headers, too.
     19* config/get_X11: Search X11 library in */lib64/*, too (not just */lib/*).
    1720
    1821Documentation:
    19 * doc/gphelp.in: cwitty: disable TeX; allow bz2 compression
     22* doc/gphelp.in: cwitty: Disable TeX; allow bz2 compression.
    2023
    2124Header files:
    22 * src/headers/paripriv.h: *after* building, on {OS X, SunOS, SYGWIN},
    23                           rename "ECHO"
     25* src/headers/paripriv.h: *After* building, on {OS X, SunOS, CYGWIN},
     26                          rename "ECHO".
    2427
    2528C files:
    26 * src/kernel/gmp/mp.c: needed so that Sage can catch pari's error signals. 
    27 * src/language/init.c: needed so that Sage can catch pari's error signals. 
    28 * src/basemath/base2.c and src/basemath/polarit3.c: fix PARI bug 1079.
     29* src/kernel/gmp/mp.c: Needed so that Sage can catch PARI's error signals.
     30                       Also allow disabling use of "GMP internals".
     31* src/language/init.c: Needed so that Sage can catch PARI's error signals.
     32* src/basemath/base2.c and src/basemath/polarit3.c: Fix PARI bug 1079.
    2933
    3034======================================================================
    3135Files previously patched:
    3236======================================================================
    3337
    34 * config/get_cc: on SunOS only, add "-fPIC" to compiler flags (David Kirkby)
     38* config/get_cc: On SunOS only, add "-fPIC" to compiler flags (David Kirkby)
    3539  This happens not with a patch file, but with a sed command in
    3640  spkg-install.  Now fixed upstream (-fPIC added on all platforms).
    3741
    38 *config/get_dlcflags: mabshoff: To get around problem in PPC 32-bit
     42* config/get_dlcflags: mabshoff: To get around problem in PPC 32-bit
    3943  Linux build.  Now fixed upstream (-fPIC added on all platforms).
     44  NB: We still patch this file, but for a slightly different reason.
    4045
    41 * config/get_kernel: pjeremy: fix for FreeBSD: #7825.  Supposedly fixed
     46* config/get_kernel: pjeremy: Fix for FreeBSD: #7825.  Supposedly fixed
    4247  upstream.
    4348
    4449* config/get_dlld: Undocumented patch for Darwin.  Removed to see what
    4550  happens...
    4651 
     52* config/get_cc: Changed OPTFLAG from "-O3" to "-O1" on Linux because of
     53  problems on Fedora 11 (32-bit) with one gcc version (ticket #7092).
    4754
    48 * config/get_cc: changed OPTFLAG from "-O3" to "-O1" on Linux because of
    49 problems on Fedora 11 (32-bit) with one gcc version (ticket #7092).
     55  # Minh Van Nguyen: copy over patched get_cc (see ticket #7092). It's
     56  # reported that 32-bit Fedora 11 would fail to build otherwise.
     57  if [ `uname` = "Linux" ]; then
     58      cp "$TOP"/patches/get_cc config/get_cc
     59  fi
    5060
    51 # Minh Van Nguyen: copy over patched get_cc (see ticket #7092). It's
    52 # reported that 32-bit Fedora 11 would fail to build otherwise.
    53 if [ `uname` = "Linux" ]; then
    54     cp "$TOP"/patches/get_cc config/get_cc
    55 fi
    56 
    57 * src/headers/paridecl.h: used to need a dummy variable changed from B0
     61* src/headers/paridecl.h: Used to need a dummy variable changed from B0
    5862  to N; now fixed upstream.
    59 * src/headers/paripriv.h: used to need a dummy variable changed from B0
    60   to N; now fixed upstream.  NB There's another patch on this file still
     63* src/headers/paripriv.h: Used to need a dummy variable changed from B0
     64  to N; now fixed upstream.  NB: There's another patch on this file still
    6165  in place!
    6266
  • new file patches/get_X11.patch

    diff -r 2d46a19aa9f4 -r d4c104308548 patches/get_X11.patch
    - +  
     1--- config/get_X11      2010-08-22 21:25:54.000000000 +0200
     2+++ config/get_X11      2010-09-06 11:05:14.000000000 +0200
     3@@ -28,20 +28,44 @@
     4   pth=`echo $x11pth | sed 's,/lib,/include,g'`
     5   x=`./locate X11/Xos.h '' $pth`
     6   case $x in
     7-   /*) Xincroot=`echo $x | sed 's,/X11/Xos.h,,'`;;
     8-   *)  Xincroot=;;
     9+   /*) Xincroot=`echo $x | sed 's,/X11/Xos.h,,'`
     10+       # echo "...Found X11 header files in \"$Xincroot/X11\"."
     11+       ;;
     12+   *)  Xincroot=""
     13+       echo "### Could not find X11 header files."
     14+       ;;
     15   esac
     16 fi
     17+
     18 # X11 -- Lib
     19-pth=$x11pth
     20-lib=X11; . ./locatelib
     21+# leif: ALSO search */lib64/* directories if we're doing a 64-bit build,
     22+#       and do this FIRST (since we might find a 32-bit library in */lib/*).
     23+#       E.g. on 64-bit Fedora 13, libX11.so is located in /usr/lib64, and
     24+#       /usr/lib is NOT a symbolic link to /usr/lib64.
     25+#       This still fails if ONLY a 32-bit X11 library is installed on a
     26+#       64-bit system, and the */lib/* directories aren't the 64-bit ones.
     27+if test "$sizeof_long" -eq 8; then
     28+  # 64-bit build
     29+  pth=`echo $x11pth | sed 's,/lib,/lib64,g'`
     30+  lib=X11; . ./locatelib
     31+fi
     32+if test -z "$X11"; then
     33+  # X11 library not yet found, search */lib/* directories
     34+  pth=$x11pth
     35+  lib=X11; . ./locatelib
     36+fi
     37+if test -z "$X11"; then
     38+  echo "### Could not find X11 library."
     39+fi
     40+
     41 if test -f $Xincroot/X11/Xos.h -a -n "$X11"; then
     42   echo ..."Found X11 header files in $Xincroot/X11"
     43+  echo ..."Found X11 library in $X11"
     44   test -n "$extralib" && echo ..."Extra Libraries are $extralib"
     45   X11_LIBS="-L$X11 -lX11 $extralib"
     46   X11_INC="-I$Xincroot"
     47 else
     48-  echo "### X11 not found"
     49+  echo "### Not all necessary parts of X11 found."
     50   X11=
     51 fi
     52 
  • new file patches/get_config_options.patch

    diff -r 2d46a19aa9f4 -r d4c104308548 patches/get_config_options.patch
    - +  
     1--- config/get_config_options   2010-08-22 21:25:54.000000000 +0200
     2+++ config/get_config_options   2010-08-31 05:18:55.000000000 +0200
     3@@ -58,9 +58,20 @@
     4   -h|-help|--help|-\?)error=true;;
     5   -v|-verbhelp|--verbhelp)error=verb;;
     6   -s|--static) static=y;;
     7-  -graphic|--graphic) shift; which_graphic_lib=$1;;
     8+  -graphic|--graphic)
     9+      shift; which_graphic_lib="$1"
     10+      case "$which_graphic_lib" in
     11+        auto|none|X11|qt|Qt|fltk|win32) ;;
     12+        *) echo "*** Unrecognized graphic lib \"$which_graphic_lib.\"" >&2
     13+           error=true;;
     14+      esac;;
     15   --graphic=*|--graphi=*|--graph=*|--grap=*|--gra=*|--gr=*|--g=*)
     16-              which_graphic_lib=`echo "$1" | sed -e 's/[-a-z]*=//'`;;
     17+      which_graphic_lib=`echo "$1" | sed -e 's/[-a-z]*=//'`
     18+      case "$which_graphic_lib" in
     19+        auto|none|X11|qt|Qt|fltk|win32) ;;
     20+        *) echo "*** Unrecognized graphic lib \"$which_graphic_lib.\"" >&2
     21+           error=true;;
     22+      esac;;
     23 
     24   --without-readline|--with-readline=no) without_readline=yes ;;
     25   --with-readline) with_readline=yes ;;
     26@@ -126,7 +137,7 @@
     27 Build Options:
     28   --host=<arch-osname>  target achitecture
     29   --kernel=<kern>       kernel used
     30-  --graphic=<gr>        graphic library used (none X11 Qt fltk win32)
     31+  --graphic=<gr>        graphic library used (none X11 qt Qt fltk win32 auto)
     32   --time=<fun>          timing function to use (getrusage times ftime)
     33   --builddir=<dir>      directory where the object files will be created
     34   --tune                tune the binary for compiling host (slow)
  • new file patches/get_fltk.patch

    diff -r 2d46a19aa9f4 -r d4c104308548 patches/get_fltk.patch
    - +  
     1--- config/get_fltk     2010-08-22 21:26:01.000000000 +0200
     2+++ config/get_fltk     2010-09-06 10:23:09.000000000 +0200
     3@@ -10,19 +10,25 @@
     4    fi
     5    ;;
     6 *) if test ! -d "$with_fltk"; then
     7-    echo "### FLTK directory '$with_fltk' not found"
     8+    echo "### Specified FLTK directory '$with_fltk' not found"
     9   else
     10     FLTKDIR=$with_fltk
     11   fi;;
     12 esac
     13 if test -n "$FLTKDIR"; then
     14   case "$FLTKDIR" in /) FLTKDIR=;; esac
     15-  echo "Using FLTK library, FLTKDIR = $FLTKDIR"
     16+  if test -d "$FLTKDIR/include/FL"; then
     17+    echo "Using FLTK library, FLTKDIR = \"$FLTKDIR\""
     18+  else
     19+    echo "### Found the FLTK library, but not the necessary headers."
     20+    echo "### Building without FLTK support."
     21+    FLTKDIR=""
     22+  fi
     23 else
     24   echo "### FLTK not found. Building without FLTK support"
     25 fi
     26 case "$osname" in
     27   cygwin) FLTK_LIBS="-lgdi32 -lole32 -luuid -lwsock32 -lsupc++" ;;
     28   darwin) FLTK_LIBS="-framework Carbon -lsupc++" ;;
     29-  *)      FLTK_LIBS="$X11_LIBS" ;;
     30+  *)      FLTK_LIBS="$X11_LIBS -lstdc++" ;;
     31 esac
  • patches/mp.c.patch

    diff -r 2d46a19aa9f4 -r d4c104308548 patches/mp.c.patch
    a b  
    1 --- src/kernel/gmp/mp.c (revision 12541)
    2 +++ src/kernel/gmp/mp.c (working copy)
     1--- src/kernel/gmp/mp.c 2010-08-22 21:25:46.000000000 +0200
     2+++ src/kernel/gmp/mp.c 2010-09-06 00:34:54.000000000 +0200
    33@@ -56,7 +56,9 @@
    44 int pari_kernel_init(void)
    55 {
     
    1010   return 0;
    1111 }
    1212 
     13@@ -949,7 +951,16 @@
     14 
     15 /* EXACT INTEGER DIVISION */
     16 
     17-#if 1 /* use undocumented GMP interface */
     18+#ifndef PARI_DONT_USE_GMP_INTERNALS /* use "undocumented" GMP interface: */
     19+/*
     20+ * Note: "Undocumented" refers to directly accessing ("private") members
     21+ *       of GMP's mpz_t / __mpz_struct types, which are defined in gmp.h.
     22+ *       This is in fact (at least) compatible with both
     23+ *        - GMP (<= 5.0.1) *and*
     24+ *        - MPIR (<= 2.1.2),
     25+ *       so we *don't* disable the use by default.
     26+ */
     27+
     28 static void
     29 GEN2mpz(mpz_t X, GEN x)
     30 {
     31@@ -1008,7 +1019,7 @@
     32     mpz2GEN(z, Z); return z;
     33   }
     34 }
     35-#else
     36+#else /* don't use "undocumented" GMP interface: */
     37 /* assume y != 0 and the division is exact */
     38 GEN
     39 diviuexact(GEN x, ulong y)
  • spkg-check

    diff -r 2d46a19aa9f4 -r d4c104308548 spkg-check
    a b  
    11#!/usr/bin/env bash
     2###########################################
     3## PARI
     4###########################################
     5
    26if [ -z "$SAGE_LOCAL" ]; then
    3    echo "SAGE_LOCAL undefined ... exiting";
    4    echo "Maybe run 'sage -sh'?"
    5    exit 1
     7    echo "SAGE_LOCAL undefined ... exiting"
     8    echo "Maybe run 'sage -sh'?"
     9    exit 1
    610fi
    711
    8 # Let the user chose a flag other than -m64 for 64-bit builds
    9 # if needed.
    10 if [ -z "$CFLAG64" ] ; then
    11    CFLAG64=-m64
     12# Let the user choose a flag other than -m64 for 64-bit builds
     13# if needed:
     14if [ -z "$CFLAG64" ]; then
     15    CFLAG64=-m64
    1216fi
    1317
    1418if [ "x$SAGE64" = xyes ]; then
    15     CFLAGS="$CFLAGS $CFLAG64" 
     19    CFLAGS="$CFLAGS $CFLAG64"
    1620    CC="$CC $CFLAG64" && export CC
    1721fi
    1822
    1923if [ "x$SAGE_DEBUG" = xyes ] ; then
    20    CFLAGS="$CFLAGS -O0 -g" # No optimisation. Good for debugging or working around compiler bugs.
     24    CFLAGS="$CFLAGS -O0 -g" # Disable optimisation, add debug symbols. Good
     25                            # for debugging or working around compiler bugs.
    2126else
    22    CFLAGS="$CFLAGS -O3 -g" # Default optimisation.
     27    CFLAGS="-O3 -g $CFLAGS" # Default optimisation, with debug symbols.
     28                            # Prepend to not override user's setting.
    2329fi
    2430
    2531export CFLAGS
    2632
    27 cd src 
     33cd src
    2834
    29 make test-all
     35$MAKE test-all
    3036
    31 if [ $? -ne 0 ] ; then
    32    echo "Pari failed the self-tests when running 'make test-all'"
    33    exit 1
     37if [ $? -ne 0 ]; then
     38    echo "Error: PARI failed the self-tests when running '$MAKE test-all'"
     39    exit 1
    3440fi
    3541
    36 if [ -d ../parisvn ] ; then
    37         echo "WARNING: you should delete the parisvn directory before submitting this spkg."
     42if [ -d ../parisvn ]; then
     43    echo "WARNING: You should delete the parisvn directory before submitting this spkg."
    3844fi
    3945
    40 echo "The Pari self-tests all passed"
    41 exit 0 
     46echo "The PARI self-tests all passed"
     47exit 0
    4248
  • spkg-install

    diff -r 2d46a19aa9f4 -r d4c104308548 spkg-install
    a b  
    44###########################################
    55
    66if [ -z "$SAGE_LOCAL" ]; then
    7    echo "SAGE_LOCAL undefined ... exiting";
    8    echo "Maybe run 'sage -sh'?"
    9    exit 1
     7    echo "SAGE_LOCAL undefined ... exiting"
     8    echo "Maybe run 'sage -sh'?"
     9    exit 1
    1010fi
    1111
    1212TOP=`pwd`
    1313PATCHED="$TOP/patches/files"
    1414
    1515###########################################################
    16 ## patching src files.  See patches/README.txt for details
     16## Patching src files.  See patches/README.txt for details.
    1717###########################################################
    1818
    1919cd src
    2020
    21 # These two are needed so that Sage can catch PARI's error signals.
     21# These two are needed so that Sage can catch PARI's error signals.
     22# In addition, let PARI use "GMP internals" (access members of GMP
     23# structures directly) *conditionally*. (We *don't* disable that by
     24# default, since at least currently this is compatible with both GMP
     25# *and* MPIR. To disable the use, add "-DPARI_DONT_USE_GMP_INTERNALS"
     26# to CFLAGS. This is a trivial patch to mp.c only; see also the comment
     27# there.):
    2228cp "$PATCHED/init.c"  src/language/init.c
    23 cp "$PATCHED/mp.c"    src/kernel/gmp/mp.c 
     29cp "$PATCHED/mp.c"    src/kernel/gmp/mp.c
    2430
    25 # Fix for PARI bug 1079 (jdemeyer: temporary until this is fixed upstream)
     31# Fix for PARI bug 1079 (jdemeyer: temporary until this is fixed upstream):
    2632cp "$PATCHED/base2.c" "$PATCHED/polarit3.c" src/basemath/
    2733
    28 
    29 # cwitty: disable -rpath
     34# cwitty: Disable -rpath:
    3035cp "$PATCHED/get_ld" config/
    3136
    32 # cwitty: disable TeX; allow bz2 compression
     37# cwitty: Disable TeX; allow bz2 compression:
    3338cp "$PATCHED/gphelp.in" doc/
    3439
    35 # John Cremona: copy over a lightly patched get_tests, so that make
    36 # test-all does not test ellglobalred (which requires the elldata
    37 # package Sage does not install).
     40# John Cremona: Copy over a lightly patched get_tests, so that "make
     41# test-all" does not test ellglobalred (which requires the elldata
     42# package Sage does not install, nor ship, since it is about 14 MB):
    3843cp "$PATCHED/get_tests" config/
    3944
    40 # Add -fno-common to DLCFLAGS on Darwin
     45# Add -fno-common to DLCFLAGS on Darwin (for Mac OS X 10.4, "Tiger"):
    4146cp "$PATCHED/get_dlcflags" config/
    4247
    43 # Two configure patches for Solaris
     48# Two configure patches for Solaris:
    4449cp "$PATCHED/Configure" .
    4550cp "$PATCHED/Makefile.SH" config/
    4651
     52# leif: Catch invalid arguments to "--graphic" (and treat such as an error)
     53# since otherwise strange compilation errors might occur (cf. #9722, too).
     54cp "$PATCHED/get_config_options" config/
     55
     56# leif: Explicitly link against libstdc++ when using FLTK (for plotting) to
     57# support Fedora 13, and do an extra check for the FLTK include dir (cf. #9722):
     58cp "$PATCHED/get_fltk" config/
     59
     60# leif: Also search */lib64/* for X11 libraries (since on some systems this
     61# is really a separate directory, i.e. neither a symbolic link to */lib/* nor
     62# the target of a symbolic link */lib/*; cf. #9722, too):
     63cp "$PATCHED/get_X11" config/
     64
    4765
    4866# This is needed or there are weird locale problems involving rpath
    49 # with building Sage.
     67# with building Sage:
    5068LC_ALL=C
    5169export LC_ALL
    5270LANG=C
    5371export LANG
    5472
     73
    5574build()
    5675{
    57     #  add the proper flags for 64-bit build mode on OS X and Open Solaris x64
    58     # Setting CFLAGS is not sufficient on Solaris since PARI 2.4.3, as this 
    59     # flag is not being used when the check for GMP and Readline are made
    60     # so the checks for them fail.  One must redefine CC and export that. 
     76    # Add the proper flags for 64-bit build mode on OS X and OpenSolaris x64.
     77    # Setting CFLAGS is not sufficient on Solaris since PARI 2.4.3, as this
     78    # flag is not being used when the checks for GMP and Readline are made,
     79    # so the checks for them fail.  One must redefine CC and export that.
    6180   
    62     # Let the user chose a flag other than -m64 for 64-bit builds
    63     # if needed.
    64     if [ -z "$CFLAG64" ] ; then
    65        CFLAG64=-m64
     81    # Let the user choose a flag other than "-m64" for 64-bit builds
     82    # if needed:
     83    if [ -z "$CFLAG64" ]; then
     84        CFLAG64=-m64
    6685    fi
    6786
    6887    if [ "x$SAGE64" = xyes ]; then
    69         CFLAGS="$CFLAGS $CFLAG64"
     88        echo "Building a 64-bit version of PARI/GP"
     89        CFLAGS="$CFLAGS $CFLAG64"
    7090        CC="$CC $CFLAG64" && export CC
    7191    fi
    7292
    73     if [ "x$SAGE_DEBUG" = xyes ] ; then
    74        CFLAGS="$CFLAGS -O0 -g" # No optimisation. Good for debugging or working around compiler bugs.
     93    if [ "x$SAGE_DEBUG" = xyes ]; then
     94       # Disable optimisation, add debug symbols. Good for debugging or
     95       # working around compiler bugs:
     96       CFLAGS="$CFLAGS -O0 -g"
    7597    else
    76        CFLAGS="$CFLAGS -O3 -g" # Default optimisation.
    77     fi
     98       CFLAGS="-O3 -g $CFLAGS" # Default optimisation, with debug symbols.
     99                               # Prepend to not override user's setting.
     100    fi
    78101    export CFLAGS
    79102
    80103    CUR=`pwd`
     
    86109    unset AR
    87110    unset AS
    88111
    89     if [ "$PARI_EXTRA_OPTS" = "" ]; then
    90         PARI_EXTRA_OPTS=" --graphic=none "
     112    # Let the user pass extra parameters to PARI's "Configure", e.g.
     113    # to specify desired graphics support (which is disabled by default):
     114    if [ -z "$PARI_EXTRA_OPTS" ]; then
     115        echo "============================================================"
     116        echo "Configuring PARI/GP without graphics support (for plotting)."
     117        echo "If you need it, pass the appropriate option(s) to PARI by"
     118        echo "setting and exporting \$PARI_EXTRA_OPTS prior to building"
     119        echo "Sage (or at least before you build/install the PARI spkg),"
     120        echo "e.g. by typing at the shell prompt:"
     121        echo "    export PARI_EXTRA_OPTS=\"--graphic=auto\""
     122        echo "or"
     123        echo "    export PARI_EXTRA_OPTS=\"--with-fltk\""
     124        echo "Note that PARI doesn't treat it as an error if the requested"
     125        echo "graphics library or the corresponding header files are not"
     126        echo "found; it will then simply disable graphics support."
     127        echo "Please consult the PARI documentation for further details."
     128        echo "============================================================"
     129
     130        PARI_EXTRA_OPTS="--graphic=none"
     131    else
     132        echo "============================================================"
     133        echo "Configuring PARI/GP with additional user-specified options:"
     134        echo "    PARI_EXTRA_OPTS=\"$PARI_EXTRA_OPTS\""
     135
     136        # Do NOT add "--graphic=none" if the user provided one of these:
     137        #     "--with-fltk[=...]", "--with-qt[=...]"
     138        # Comment by leif: This misbehavoir seems to have been fixed in
     139        #                  PARI 2.4.3; the following doesn't hurt though:
     140        if ! (echo "$PARI_EXTRA_OPTS" | egrep -- "--with-fltk|--with-qt") \
     141              >/dev/null;
     142        then
     143            echo "To avoid unexpected behavior, we prepend \"--graphic=none\":"
     144            PARI_EXTRA_OPTS="--graphic=none $PARI_EXTRA_OPTS"
     145            echo "    \"$PARI_EXTRA_OPTS\""
     146            echo "(Disabling graphics can be overridden by user settings.)"
     147        fi
     148        echo "============================================================"
    91149    fi
    92150
    93     # Allow the user to tune PARI - this is time-consuming, but some may want to do it.
    94     # It is also very unreliable
    95     if [ "x$SAGE_TUNE_pari" = xyes ] ; then
    96        echo ""
    97        echo "PARI will be tuned for your system since you set SAGE_TUNE_pari=\"yes\"."
    98        echo "This can take a long time."
    99        echo "WARNING: Tuning PARI is VERY unreliable. You may find your build"
    100        echo "of PARI fails, or PARI does not work properly once built."
    101        echo ""
    102        ./Configure $PARI_EXTRA_OPTS --prefix=$SAGE_LOCAL --with-readline=$SAGE_LOCAL --with-gmp=$SAGE_LOCAL --kernel=gmp --graphic=none --tune
     151    # Allow the user to enable PARI self-tuning.
     152    # This is time-consuming, but some may want to do it.
     153    # It is also very unreliable, and currently (svn 12577) completely
     154    # broken on *many* systems.
     155    # Comment by leif: Also, PARI's Configure calls "make" (instead of $MAKE)
     156    #                  if we do tuning, so:
     157    #            TODO: Replace that in our patched version of Configure!
     158    if [ "$SAGE_TUNE_pari" = yes -o "$SAGE_TUNE_PARI" = yes ]; then
     159        echo ""
     160        echo "PARI will be tuned for your system since you set SAGE_TUNE_pari=\"yes\"."
     161        echo "This can take a long time."
     162        echo "WARNING: Tuning PARI is currently VERY unreliable. You may find your"
     163        echo "build of PARI fails, or PARI does not work properly once built."
     164        echo ""
     165        PARI_EXTRA_OPTS="$PARI_EXTRA_OPTS --tune"
    103166    else
    104        echo "To minimize Sage build time and to ensure the best relieability, PARI"
    105        echo "will not be tuned for your system. Experience shows tuning is"
    106        echo "unreliable: see http://trac.sagemath.org/sage_trac/ticket/9343"
    107        echo "If you wish to test the tuning code, set the environment variable"
    108        echo "SAGE_TUNE_pari=yes by typing the following before building Sage (or at"
    109        echo "least before building PARI):"
    110        echo "SAGE_TUNE_pari=yes"
    111        echo "export SAGE_TUNE_pari"
    112        echo ""
    113        ./Configure $PARI_EXTRA_OPTS --prefix=$SAGE_LOCAL --with-readline=$SAGE_LOCAL --with-gmp=$SAGE_LOCAL --kernel=gmp --graphic=none
     167        echo ""
     168        echo "To minimize Sage build time and to ensure the best reliability, PARI"
     169        echo "will not be tuned for your system. Experience shows tuning is"
     170        echo "unreliable: see http://trac.sagemath.org/sage_trac/ticket/9343"
     171        echo "If you wish to test the tuning code, set the environment variable"
     172        echo "SAGE_TUNE_pari=yes by typing the following before building Sage (or at"
     173        echo "least before building/installing PARI):"
     174        echo "    SAGE_TUNE_pari=yes"
     175        echo "    export SAGE_TUNE_pari"
     176        echo ""
    114177    fi
    115178
     179    unset GP_INSTALL_PREFIX # we do not want this to be set by the user
     180
     181    # In addition, a lot of variables used (internally) by PARI might un-
     182    # intentionally get their values from the "global" environment, so it's
     183    # safer to clear them here (not further messing up PARI's scripts):
     184    unset static tune timing_fun error
     185    unset enable_tls
     186    unset with_fltk with_qt
     187    unset with_ncurses_lib
     188    unset with_readline_include with_readline_lib without_readline
     189    unset with_gmp_include with_gmp_lib without_gmp
     190    unset dfltbindir dfltdatadir dfltemacsdir dfltincludedir
     191    unset dfltlibdir dfltmandir dfltsysdatadir dfltobjdir
     192    # The following get set because we pass the respective parameters:
     193    # prefix kernel with_gmp with_readline
     194
     195
     196    # Note that "--graphic=none" is (usually) added to PARI_EXTRA_OPTS:
     197    ./Configure $PARI_EXTRA_OPTS --prefix="$SAGE_LOCAL" \
     198        --with-readline="$SAGE_LOCAL" --with-gmp="$SAGE_LOCAL" \
     199        --kernel=gmp
     200
    116201    if [ $? -ne 0 ]; then
    117         echo "ERROR - configure PARI with readline and gmp failed."
     202        echo "Error: Configuring PARI with readline and GMP kernel failed."
    118203        exit 1
    119204    fi
    120205
    121206    if [ ! -f Makefile ]; then
    122         echo "Unable to configure PARI."
     207        echo "Error: Unable to configure PARI: No Makefile generated!"
    123208        exit 1
    124209    fi
    125210
    126     echo "Building and install PARI"
     211    echo "Building and installing PARI/GP..."
    127212    if [ "$UNAME" = "CYGWIN" ]; then
    128213        # There are weird bugs in PARI's build process on Windows XP
    129214        # under Cygwin.
    130215        # Passing in this extra flag gets around the bug.
    131         $MAKE GMPINCLUDE=-I$SAGE_LOCAL/include EXTRADLLDFLAGS=-lgmp gp
     216        $MAKE GMPINCLUDE="-I$SAGE_LOCAL/include" EXTRADLLDFLAGS=-lgmp gp
    132217    else
    133218        $MAKE gp
    134219    fi
     
    140225
    141226    cp -f gp "$SAGE_LOCAL/bin/"    # avoid "make install"
    142227
    143     # Install documentation source (compressed), for use by gphelp.
     228    # Install documentation source (compressed), for use by gphelp:
    144229    mkdir -p "$SAGE_LOCAL/share/pari/doc/"
    145230    cp -f doc/usersch*.tex "$SAGE_LOCAL/share/pari/doc/"
    146231    bzip2 -9 -f "$SAGE_LOCAL/share/pari/doc/"usersch*.tex
    147232    cp -f doc/translations "$SAGE_LOCAL/share/pari/doc/"
    148233
    149     # And install gphelp.
     234    # And install gphelp:
    150235    cp -f doc/gphelp "$SAGE_LOCAL/bin/"
    151236
    152237    $MAKE install-lib-sta
    153238
    154239    if [ $? -ne 0 ]; then
    155         echo "Error installing PARI static library"
     240        echo "Error installing PARI's static library"
    156241        exit 1
    157242    fi
    158243
    159244    # Instead of "make install" we do the following, to avoid building
    160245    # the PARI documentation (which requires latex; or more precisely,
    161     # *hangs* under a default cygwin with latex, since some fonts are missing).
    162     cd `config/objdir`
     246    # *hangs* under a default Cygwin with latex, since some fonts are missing):
     247    cd "`config/objdir`"
    163248    $MAKE install-include
    164249
    165250    if [ $? -ne 0 ]; then
    166         echo "Error installing PARI include files"
     251        echo "Error installing PARI's include files"
    167252        exit 1
    168253    fi
    169254
    170     cp -f libpari* $SAGE_LOCAL/lib/
     255    cp -f libpari* "$SAGE_LOCAL/lib/"
    171256    cd "$CUR"
    172257
    173     # On CYGWIN, need the dll for PARI to be in the same
     258    # On Cygwin, we need the dll for PARI to be in the same
    174259    # directory as the gp binary, or it doesn't find it.
    175260    # Note that just using a symlink doesn't work.
    176     if [ $UNAME = "CYGWIN" ]; then
    177         CUR="`pwd`"
     261    if [ "$UNAME" = "CYGWIN" ]; then
     262        CUR=`pwd`
    178263        cd "$SAGE_LOCAL"/bin/
    179264        cp -f "$SAGE_LOCAL"/lib/*pari*.dll .
    180265        cd "$CUR"
    181266    fi
    182267
    183     # The following is a hack to get the library installed correctly
    184     # on OS X.
    185     if [ $UNAME = "Darwin" ]; then
    186         echo "MAC OS X hack -- delete and reinstall libpari.a"
     268    if [ "$UNAME" = "Darwin" ]; then
     269        # The following is a hack to get the library installed correctly
     270        # on Mac OS X:
     271        echo "Applying Mac OS X hack -- deleting and reinstalling libpari.a ..."
    187272        rm -f Odarwin-ppc/*lib*
    188273        $MAKE install-lib-sta
    189274
    190275        if [ $? -ne 0 ]; then
    191             echo "Error Re-installing PARI static libraries (OS X trick)"
     276            echo "Error reinstalling PARI's static libraries (OS X trick)"
    192277            exit 1
    193278        fi
    194279
    195         cd `config/objdir`
     280        cd "`config/objdir`"
    196281        cp -f libpari* "$SAGE_LOCAL"/lib
    197282        cd "$CUR"
    198283
    199284        # Also another patch since paripriv.h won't compile right on OS X
    200285        # when used by client Sage code.  So we replace it by a slightly
    201         # modified version.
     286        # modified version:
     287        echo "Patching include/pari/paripriv.h so it works on Mac OS X..."
    202288        cp -pf "$PATCHED/paripriv.h" "$SAGE_LOCAL/include/pari/paripriv.h"
    203     fi
    204     # Like on OS X (see above), the Sage library would not build
    205     # without some changes. Though on Solaris the changes are much simpler than
    206     # on OS X.
    207     if [ `uname` = "SunOS" ]; then
    208        set -e
    209        echo "Patching include/pari/paripriv.h so it works on Solaris"
    210        echo "The changes are much smaller than needed on OS X"
    211        cp  "$PATCHED/paripriv.h" $SAGE_LOCAL/include/pari/paripriv.h
    212        set +e
     289
     290    elif [ "$UNAME" = "SunOS" ]; then
     291        # Like on Mac OS X (see above), the Sage library would not build
     292        # without some changes on Solaris, though the changes are much simpler:
     293        echo "Patching include/pari/paripriv.h so it works on Solaris..."
     294        cp -f "$PATCHED/paripriv.h" "$SAGE_LOCAL/include/pari/paripriv.h"
     295
    213296    elif [ "$UNAME" = "CYGWIN" ]; then
    214        # We need to the same thing on Cygwin that we have to do on Solaris
    215        cp  "$PATCHED/paripriv.h" $SAGE_LOCAL/include/pari/paripriv.h
     297        # We need to the same thing on Cygwin that we have to do on Solaris
     298        echo "Patching include/pari/paripriv.h so it works on Cygwin..."
     299        cp -f "$PATCHED/paripriv.h" "$SAGE_LOCAL/include/pari/paripriv.h"
    216300    fi
    217301
    218     echo "Installing extra Galois groups data."
    219     make install-data
     302    echo "Installing extra Galois groups data..."
     303    $MAKE install-data
    220304    if [ $? -ne 0 ]; then
    221         echo "Error installing extra galois groups data."
     305        echo "Error installing extra Galois groups data."
    222306        exit 1
    223307    fi
    224308}
    225309
    226310build
    227311
    228 if [ $? -ne 0 ]; then
    229     echo "Error building PARI."
     312# All (previous) errors are catched in build(), so we don't test $? here.
     313# Although we perhaps should also check success of the numerous copy commands
     314# inside build().
     315
     316if [ "$UNAME" = "Darwin" ]; then
     317    pari_shlib="libpari.dylib"
     318else
     319    pari_shlib="libpari.so"
     320fi
     321if [ ! -f "$SAGE_LOCAL/lib/$pari_shlib" ]; then
     322    echo "Error: PARI's shared library $pari_shlib has not been installed!"
    230323    exit 1
    231324fi
    232325
    233 if [ $UNAME="Darwin" -a -f $SAGE_LOCAL/lib/libpari.dylib ]; then
    234     exit 0
    235 fi
    236 
    237 if [ -f $SAGE_LOCAL/lib/libpari.so ]; then
    238     exit 0
    239 fi
    240 
    241 if [ $? -ne 0 ]; then
    242     echo "Error building PARI."
    243     exit 1
    244 fi
    245