aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--math/sage/Makefile292
-rw-r--r--math/sage/distinfo4
-rw-r--r--math/sage/files/gcc.in13
-rw-r--r--math/sage/files/spkg-patch-flintqs-20070817.p6_-_patches_TonelliShanks.h.patch13
-rw-r--r--math/sage/files/spkg-patch-flintqs-20070817.p6_-_spkg-install10
-rw-r--r--math/sage/files/spkg-patch-flintqs-20070817.p6_-_src_TonelliShanks.h10
-rw-r--r--math/sage/files/spkg-patch-gfan-0.4plus.p1_-_patches_Makefile11
-rw-r--r--math/sage/files/spkg-patch-linbox-1.1.6.p6_-_spkg-install12
-rw-r--r--math/sage/files/spkg-patch-linbox-1.1.6.p6_-_src_linbox_util_commentator.h11
-rw-r--r--math/sage/files/spkg-patch-polybori-0.8.1.p1_-_custom.py11
-rw-r--r--math/sage/files/spkg-patch-polybori-0.8.1.p1_-_patches_Cudd.cudd.cudd.h18
-rw-r--r--math/sage/files/spkg-patch-pycrypto-2.1.0_-_patches_src.libtom.tomcrypt_pk.h14
-rw-r--r--math/sage/files/spkg-patch-pycrypto-2.1.0_-_spkg-install11
-rw-r--r--math/sage/files/spkg-patch-pycrypto-2.1.0_-_src_libtom_tomcrypt_pk.h11
-rw-r--r--math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Doc_library_fcntl.rst11
-rw-r--r--math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Modules__ctypes_libffi_configure21
-rw-r--r--math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Modules_fcntlmodule.c53
-rw-r--r--math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Python_thread_pthread.h55
-rw-r--r--math/sage/files/spkg-patch-python-2.7.2.p4_-_src_setup.py (renamed from math/sage/files/spkg-patch-python-2.6.4.p13_-_src_setup.py)32
-rw-r--r--math/sage/files/spkg-patch-sage-5.0_-_sage_combinat_partitions_c.cc11
-rw-r--r--math/sage/files/spkg-patch-sage-5.0_-_sage_misc_getusage.py40
-rw-r--r--math/sage/files/spkg-patch-singular-3-1-3-3.p3_-_src_omalloc_configure12
-rw-r--r--math/sage/files/spkg-patch-singular-3-1-3-3.p6_-_patches_omalloc.configure.patch16
-rw-r--r--math/sage/files/spkg-patch-singular-3-1-3-3.p6_-_spkg-install11
-rw-r--r--math/sage/files/spkg-patch-sympow-1.018.1.p11_-_src_disk.c11
-rw-r--r--math/sage/files/spkg-patch-sympow-1.018.1.p9_-_src_fpu.c11
-rw-r--r--math/sage/pkg-descr4
27 files changed, 605 insertions, 124 deletions
diff --git a/math/sage/Makefile b/math/sage/Makefile
index 5e9515889276..de2cf56f8852 100644
--- a/math/sage/Makefile
+++ b/math/sage/Makefile
@@ -6,11 +6,10 @@
#
PORTNAME= sage
-PORTVERSION= 4.8
-PORTREVISION= 2
+PORTVERSION= 5.0
CATEGORIES= math
MASTER_SITES= http://modular.math.jmu.edu/src/ \
- http://boxen.math.washington.edu/sage/src/ \
+ http://boxen.math.washington.edu/home/sagemath/sage-mirror/src/ \
http://mirrors.xmission.com/sage/src/ \
http://www.sagemath.org/src-old/
EXTRACT_SUFX= .tar
@@ -26,44 +25,148 @@ LIB_DEPENDS= atlas:${PORTSDIR}/math/atlas \
jpeg:${PORTSDIR}/graphics/jpeg
RUN_DEPENDS= bash:${PORTSDIR}/shells/bash
-PLIST_FILES= bin/sage
+# 387 option: this only makes a difference for the amd64 architecture. Causes
+# the internal floating point calculations to be performed with extended
+# precision.
+# Optional packages: see http://www.sagemath.org/packages/optional/
+OPTIONS= \
+ 387 "Use 387 instead of SSE FPU" Off \
+ 4TI2 4ti2 Off \
+ TOPCOM TOPCOM Off \
+ BIOPYTHON biopython Off \
+ CBC cbc Off \
+ CUNNINGHAM_TABLES cunningham_tables Off \
+ DB_CREMONA_ELLCURVE db_cremona_ellcurve Off \
+ DB_GAP db_gap Off \
+ DB_JONES_NUMFIELD db_jones_numfield Off \
+ DB_KOHEL db_kohel Off \
+ DB_ODLYZKO_ZETA db_odlyzko_zeta Off \
+ DB_SLOANE_OEIS db_sloane_oeis Off \
+ DB_STEIN_WATKINS_MINI db_stein_watkins_mini Off \
+ DB_SYMBOLIC_DATA db_symbolic_data Off \
+ DOT2TEX dot2tex Off \
+ EXTRA_DOCS extra_docs Off \
+ GAP_PACKAGES gap_packages Off \
+ GDBM gdbm Off \
+ GINV ginv Off \
+ GIT git Off \
+ GMPY gmpy Off \
+ GNUPLOTPY gnuplotpy Off \
+ GUPPY guppy Off \
+ JAVA3D java3d Off \
+ JSMATH_IMAGE_FONTS jsmath_image_fonts Off \
+ KASH3 kash3 Off \
+ KNOBOO knoboo Off \
+ LIE lie Off \
+ LRCALC lrcalc Off \
+ LRS lrs Off \
+ MPC mpc Off \
+ MPI4PY mpi4py Off \
+ NAUTY nauty Off \
+ NZMATH nzmath Off \
+ P_GROUP_COHOMOLOGY p_group_cohomology Off \
+ PYCRYPTOPLUS pycryptoplus Off \
+ PYOPENSSL pyopenssl Off \
+ PYX pyx Off \
+ QHULL qhull Off \
+ SAGE_MODE sage-mode Off \
+ TRAC trac Off
+PLIST_FILES= bin/sage
USE_FORTRAN= yes
USE_TK= yes
USE_GMAKE= yes
USE_ICONV= yes
MAKE_JOBS_SAFE= yes
LDFLAGS:= -Wl,-rpath=${WRKSRC}/local/lib ${LDFLAGS}
-FFLAGS+= -Wl,-rpath=${WRKSRC}/local/lib
-CFLAGS+= -Wl,-rpath=${WRKSRC}/local/lib
-CXXFLAGS+= -Wl,-rpath=${WRKSRC}/local/lib
+FFLAGS+= -Wl,-rpath=${WRKSRC}/local/lib ${FPM_FLAG}
+CFLAGS+= -Wl,-rpath=${WRKSRC}/local/lib ${FPM_FLAG}
+CXXFLAGS+= -Wl,-rpath=${WRKSRC}/local/lib ${FPM_FLAG}
# Note that the above addition to LDFLAGS, as a side effect, provides a
# work-around for the make(1) idiosyncracy mentioned in PR 164361 (which
# otherwise breaks the build of the maxima sub-package).
+.include <bsd.port.pre.mk>
+
+.if defined(WITH_4TI2) || defined(WITH_TOPCOM) || defined(WITH_BIOPYTHON) || \
+ defined(WITH_CBC) || defined(WITH_CUNNINGHAM_TABLES) || \
+ defined(WITH_DB_CREMONA_ELLCURVE) || defined(WITH_DB_GAP) || \
+ defined(WITH_DB_JONES_NUMFIELD) || defined(WITH_DB_KOHEL) || \
+ defined(WITH_DB_ODLYZKO_ZETA) || defined(WITH_DB_SLOANE_OEIS) || \
+ defined(WITH_DB_STEIN_WATKINS_MINI) || defined(WITH_DB_SYMBOLIC_DATA) || \
+ defined(WITH_DOT2TEX) || defined(WITH_EXTRA_DOCS) || \
+ defined(WITH_GAP_PACKAGES) || defined(WITH_GDBM) || defined(WITH_GINV) || \
+ defined(WITH_GIT) || defined(WITH_GMPY) || defined(WITH_GNUPLOTPY) || \
+ defined(WITH_GUPPY) || defined(WITH_JAVA3D) || \
+ defined(WITH_JSMATH_IMAGE_FONTS) || defined(WITH_KASH3) || \
+ defined(WITH_KNOBOO) || defined(WITH_LIE) || defined(WITH_LRCALC) || \
+ defined(WITH_LRS) || defined(WITH_MPC) || defined(WITH_MPI4PY) || \
+ defined(WITH_NAUTY) || defined(WITH_NZMATH) || \
+ defined(WITH_P_GROUP_COHOMOLOGY) || defined(WITH_PYCRYPTOPLUS) || \
+ defined(WITH_PYOPENSSL) || defined(WITH_PYX) || defined(WITH_QHULL) || \
+ defined(WITH_SAGE_MODE) || defined(WITH_TRAC)
+WITH_OPTIONAL_PKGS= yes
+.endif
+
+.ifdef WITH_OPTIONAL_PKGS
+USE_PERL5_BUILD= yes
+.endif
+
+# Optimization flags will be defined by the source
+CFLAGS:= ${CFLAGS:C/^-O.*$//}
+FFLAGS:= ${CFLAGS:C/^-O.*$//}
+
MAKE_ENV+= SAGE_PORT=yes \
SAGE_FORTRAN=${LOCALBASE}/bin/${FC} \
SAGE_FORTRAN_LIB=${LOCALBASE}/lib/gcc${GCC_DEFAULT_V}/libgfortran.so \
- SAGE_ATLAS_LIB=${LOCALBASE}/lib
+ SAGE_ATLAS_LIB=${LOCALBASE}/lib \
+ DOT_SAGE=${WRKSRC}/tmp/.sage
-NO_LATEST_LINK= yes # Conflicts with graphics/sage.
+LATEST_LINK= sage-math # Conflicts with graphics/sage.
# The following is needed for the lapack subpackage.
MAKE_ARGS+= ARCH="${AR}"
+.if ${OSVERSION} < 701106
+BROKEN= POSIX semaphores are required, and the support only works in FreeBSD 7-STABLE and later
+.endif
+
+.if defined(WITH_387) && ${ARCH} == amd64
+FPM_FLAG= -mfpmath=387
+.else
+FPM_FLAG=
+.endif
+
+.if !defined(DISABLE_MAKE_JOBS)
+MAKE_ENV+= MAKE="make -j${MAKE_JOBS_NUMBER}"
+.endif
+
post-patch:
+# Create the wrappers for the compiler invokations.
@${MKDIR} ${WRKSRC}/local/bin
@${LN} -s -f ${LOCALBASE}/bin/gmake ${WRKSRC}/local/bin/make
@${LN} -s -f ${LOCALBASE}/bin/bash ${WRKSRC}/local/bin/sh
- @${SED} -e 's#%%CC%%#${LOCALBASE}/bin/${CC}#' -e 's#%%CFLAGS%%#${CFLAGS}#' ${FILESDIR}/gcc.in > ${WRKSRC}/local/bin/cc
+ @${SED} -e 's#%%CC%%#${LOCALBASE}/bin/${CC}#' \
+ -e 's#%%LDFLAGS%%#${LDFLAGS} ${FPM_FLAG}#' \
+ ${FILESDIR}/gcc.in > ${WRKSRC}/local/bin/cc
@${CHMOD} +x ${WRKSRC}/local/bin/cc
@${LN} -s -f cc ${WRKSRC}/local/bin/gcc
- @${SED} -e 's#%%CC%%#${LOCALBASE}/bin/${CXX}#' -e 's#%%CFLAGS%%#${CXXFLAGS}#' ${FILESDIR}/gcc.in > ${WRKSRC}/local/bin/c++
+ @${SED} -e 's#%%CC%%#${LOCALBASE}/bin/${CXX}#' \
+ -e 's#%%LDFLAGS%%#${LDFLAGS} ${FPM_FLAG}#' \
+ ${FILESDIR}/gcc.in > ${WRKSRC}/local/bin/c++
@${CHMOD} +x ${WRKSRC}/local/bin/c++
@${LN} -s -f c++ ${WRKSRC}/local/bin/g++
- @${SED} -e 's#%%CC%%#${LOCALBASE}/bin/${FC}#' -e 's#%%CFLAGS%%#${FFLAGS}#' ${FILESDIR}/gcc.in > ${WRKSRC}/local/bin/gfortran
+ @${SED} -e 's#%%CC%%#${LOCALBASE}/bin/${FC}#' \
+ -e 's#%%LDFLAGS%%#${LDFLAGS} ${FPM_FLAG}#' \
+ ${FILESDIR}/gcc.in > ${WRKSRC}/local/bin/gfortran
@${CHMOD} +x ${WRKSRC}/local/bin/gfortran
+
+# Apply the patches to the appropriate xz'ed tarballs contained in
+# ${WRKSRC}/spkg/standard. The names of the patches are
+# spkg-${NAME_OF_TARBALL}_-_${NAME_OF_PATCH}.
+
@${MKDIR} ${WRKSRC}/tmp
+ @${RM} -rf ${WRKSRC}/tmp/*
@for p in ${FILESDIR}/spkg-patch-*; do \
q=$${p#*/spkg-patch-}; t=$${q%_-_*}; \
if ! [ -e ${WRKSRC}/spkg/standard/$$t.spkg ]; then \
@@ -80,36 +183,179 @@ post-patch:
if [ -e $$f-orig ]; then \
${MV} $$f-orig $$f; \
fi; \
- ${BZIP2_CMD} -dc $$f | ${TAR} -xf -; \
+ ${TAR} -xf $$f; \
${ECHO_MSG} "Patching $$t:"; \
for p in ${FILESDIR}/spkg-patch-$${t}_-_*; do \
${ECHO_MSG} " applying $${p#*_-_}" ; \
${PATCH} < $$p 2>/dev/null || exit 1; \
done; \
${MV} $$f $$f-orig; \
- ${TAR} -cf - $$t | ${BZIP2_CMD} -c > $$f; \
+ ${TAR} -cyf $$f $$t; \
${RM} -rf $$t; \
done
-.include <bsd.port.pre.mk>
+# Here we check dependencies of the optional packages on ports, and on other
+# optional packages. If you find any dependencies not listed here, please
+# contact the maintainer.
-.if ${OSVERSION} < 701106
-IGNORE= POSIX semaphores are required, and the support only works in FreeBSD 7-STABLE and later
+.ifdef WITH_4TI2
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|4ti2-
+.endif
+.ifdef WITH_TOPCOM
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|topcom-
+.endif
+.ifdef WITH_BIOPYTHON
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|biopython-
+.endif
+.ifdef WITH_CBC
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|cbc-
+.endif
+.ifdef WITH_CUNNINGHAM_TABLES
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|cunningham_tables-
+.endif
+.ifdef WITH_DB_CREMONA_ELLCURVE
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|database_cremona_ellcurve-
+.endif
+.ifdef WITH_DB_GAP
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|database_gap-
+.endif
+.ifdef WITH_DB_JONES_NUMFIELD
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|database_jones_numfield-
+.endif
+.ifdef WITH_DB_KOHEL
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|database_kohel-
+.endif
+.ifdef WITH_DB_ODLYZKO_ZETA
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|database_odlyzko_zeta-
+.endif
+.ifdef WITH_DB_SLOANE_OEIS
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|database_sloane_oeis-
.endif
+.ifdef WITH_DB_STEIN_WATKINS_MINI
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|database_stein_watkins_mini
+.endif
+.ifdef WITH_DB_SYMBOLIC_DATA
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|database_symbolic_data-
+.endif
+.ifdef WITH_DOT2TEX
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|dot2tex-
+.endif
+.ifdef WITH_EXTRA_DOCS
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|extra_docs-
+.endif
+.ifdef WITH_GAP_PACKAGES
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|gap_packages-
+.endif
+.ifdef WITH_GDBM
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|gdbm-
+.endif
+.ifdef WITH_GINV
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|ginv-
+.endif
+.ifdef WITH_GIT
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|git-
+.endif
+.ifdef WITH_GMPY
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|gmpy-
+.endif
+.ifdef WITH_GNUPLOTPY
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|gnuplotpy-
+RUN_DEPENDS+= gnuplot:${PORTSDIR}/math/gnuplot
+.endif
+.ifdef WITH_GUPPY
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|guppy-
+.endif
+.ifdef WITH_JAVA3D
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|java3d-
+USE_JAVA= yes
+.endif
+.ifdef WITH_JSMATH_IMAGE_FONTS
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|jsmath_image_fonts-
+.endif
+.ifdef WITH_KASH3
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|kash3-
+.endif
+.ifdef WITH_KNOBOO
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|knoboo-
+.endif
+.ifdef WITH_LIE
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|lie-
+.endif
+.ifdef WITH_LRCALC
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|lrcalc-
+.endif
+.ifdef WITH_LRS
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|lrs-
+.endif
+.ifdef WITH_MPC
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|mpc-
+.endif
+.ifdef WITH_MPI4PY
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|mpi4py-
+LIB_DEPENDS+= mpi:${PORTSDIR}/net/openmpi
+MAKE_ENV+= PATH=$${PATH}:${LOCALBASE}/`${MAKE} -C ${PORTSDIR}/net/openmpi -V MPIDIR`/bin
+.endif
+.ifdef WITH_NAUTY
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|nauty-
+.endif
+.ifdef WITH_NZMATH
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|nzmath-
+.endif
+.ifdef WITH_P_GROUP_COHOMOLOGY
+.if !defined(WITH_DB_GAP)
+IGNORE= DB_GAP must be set if P_GROUP_COHOMOLOGY is set
+.endif
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|p_group_cohomology-
+.endif
+.ifdef WITH_PYCRYPTOPLUS
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|pycryptoplus-
+.endif
+.ifdef WITH_PYOPENSSL
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|pyopenssl-
+.endif
+.ifdef WITH_PYX
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|pyx-
+.endif
+.ifdef WITH_QHULL
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|qhull-
+.endif
+.ifdef WITH_SAGE_MODE
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|sage_mode-
+.endif
+.ifdef WITH_TRAC
+OPT_PKG_LIST:= ${OPT_PKG_LIST}|trac-
+.endif
+OPT_PKG_LIST:= ${OPT_PKG_LIST:C/\|//} # Remove the leading '|'
-.if !defined(DISABLE_MAKE_JOBS)
-MAKE_ENV+= MAKE="make -j${MAKE_JOBS_NUMBER}"
+post-build:
+.ifdef WITH_OPTIONAL_PKGS
+ ${SETENV} ${MAKE_ENV} ${WRKSRC}/sage -optional | \
+ ${PERL} -lne 'print if $$p && /^\S+$$/; $$p=1 if /NOT INSTALLED:/' | \
+ ${GREP} -E '^(${OPT_PKG_LIST})' | \
+ ${XARGS} -n1 ${SETENV} ${MAKE_ENV} \
+ ${WRKSRC}/sage -i
+# ${MAKE} -C ${.CURDIR} do-build # Not sure if this is necessary.
.endif
+ ${RM} -rf ${WRKSRC}/tmp/.sage
+ ${CHMOD} -R a+rX ${WRKSRC}
check regression-test test: build
- @${ECHO_MSG} This test can also be performed after installation by typing \"sage --testall\".
+ @${ECHO_MSG} This test can also be performed after installation by typing \"sage -testall\".
@${ECHO_MSG}
- cd ${WRKSRC}; local/bin/sage-starts; \
- ${LOCALBASE}/bin/bash -c ". local/bin/sage-env && sage-maketest"
+ cd ${WRKSRC} && ${SETENV} DOT_SAGE=${WRKSRC}/tmp/.sage ./sage -testall
+ ${RM} -f ${WRKSRC}/python.core
INSTALL_SAGE_DIR= ${PREFIX}/${PORTNAME}-${PORTVERSION}
do-install:
- cd ${WRKDIR} && ${FIND} -s ${WRKSRC} | ${SED} -e 's#${WRKDIR}/##' | \
+ cd ${WRKDIR} && ${FIND} -s ${WRKSRC} | \
+ ${GREP} -v '^${WRKSRC}/spkg/standard/' | \
+ ${GREP} -v '^${WRKSRC}/spkg/optional/' | \
+ ${GREP} -v '^${WRKSRC}/spkg/logs/' | \
+ ${GREP} -v '^${WRKSRC}/spkg/build/' | \
+ ${GREP} -v '^${WRKSRC}/tmp' | \
+ ${GREP} -v -E '^${WRKSRC}/[^\/]+\.log$$' | \
+ ${GREP} -v '^${WRKSRC}/Makefile' | \
+ ${SED} -e 's#${WRKDIR}/##' | \
${CPIO} -pmud -R ${BINOWN}:${BINGRP} ${PREFIX}
${ECHO_CMD} | ${SETENV} DOT_SAGE=${INSTALL_SAGE_DIR}/tmp/.sage ${INSTALL_SAGE_DIR}/sage
${RM} -rf ${INSTALL_SAGE_DIR}/tmp/.sage
diff --git a/math/sage/distinfo b/math/sage/distinfo
index 76d6d0d3b35a..92875b031dec 100644
--- a/math/sage/distinfo
+++ b/math/sage/distinfo
@@ -1,2 +1,2 @@
-SHA256 (sage-4.8.tar) = 7fcda2b5f86fb5669a871e4d69fcaca0a3c3624255e5836666c4180a175e7d6d
-SIZE (sage-4.8.tar) = 339159040
+SHA256 (sage-5.0.tar) = 883eab2a42df3751d2de777f6f5e9337c54c3fa286fe3d30997ef585f83d1f39
+SIZE (sage-5.0.tar) = 307988480
diff --git a/math/sage/files/gcc.in b/math/sage/files/gcc.in
index 49bd6e419463..5bc7c71bb3da 100644
--- a/math/sage/files/gcc.in
+++ b/math/sage/files/gcc.in
@@ -1,3 +1,14 @@
#!/bin/sh
-%%CC%% %%CFLAGS%% $*
+# This is a wrapper to redirect compiler invokations to the port of gcc that
+# contains fortran. LDFLAGS needs to be added so that the linker knows where
+# to find the dynamic libraries.
+
+# If the compiler is invoked with the argument "-v", adding LDFLAGS to the
+# arguments results in an error which stops some packages being built.
+
+if [ "x$*" = "x-v" ]; then
+ exec %%CC%% "$@"
+else
+ exec %%CC%% %%LDFLAGS%% "$@"
+fi
diff --git a/math/sage/files/spkg-patch-flintqs-20070817.p6_-_patches_TonelliShanks.h.patch b/math/sage/files/spkg-patch-flintqs-20070817.p6_-_patches_TonelliShanks.h.patch
new file mode 100644
index 000000000000..5455cbda087e
--- /dev/null
+++ b/math/sage/files/spkg-patch-flintqs-20070817.p6_-_patches_TonelliShanks.h.patch
@@ -0,0 +1,13 @@
+--- /dev/null 2012-04-08 00:45:00.000000000 +0000
++++ flintqs-20070817.p6/patches/TonelliShanks.h.patch 2012-04-08 00:45:31.000000000 +0000
+@@ -0,0 +1,10 @@
++--- src/TonelliShanks.h.orig 2007-05-05 22:52:39.000000000 +0000
+++++ src/TonelliShanks.h 2012-04-08 00:44:38.000000000 +0000
++@@ -19,6 +19,7 @@
++
++ ============================================================================*/
++
+++#include <stdint.h>
++ #include <stdlib.h>
++
++ // =====================================================================
diff --git a/math/sage/files/spkg-patch-flintqs-20070817.p6_-_spkg-install b/math/sage/files/spkg-patch-flintqs-20070817.p6_-_spkg-install
new file mode 100644
index 000000000000..91978d6f41a0
--- /dev/null
+++ b/math/sage/files/spkg-patch-flintqs-20070817.p6_-_spkg-install
@@ -0,0 +1,10 @@
+--- flintqs-20070817.p6/spkg-install-orig 2012-04-08 00:46:21.000000000 +0000
++++ flintqs-20070817.p6/spkg-install 2012-04-08 00:55:33.000000000 +0000
+@@ -7,6 +7,7 @@
+ fi
+
+ cp patches/lanczos.h src/
++patch -p0 < patches/TonelliShanks.h.patch
+
+ cd src
+
diff --git a/math/sage/files/spkg-patch-flintqs-20070817.p6_-_src_TonelliShanks.h b/math/sage/files/spkg-patch-flintqs-20070817.p6_-_src_TonelliShanks.h
deleted file mode 100644
index db8b6ed7e1c9..000000000000
--- a/math/sage/files/spkg-patch-flintqs-20070817.p6_-_src_TonelliShanks.h
+++ /dev/null
@@ -1,10 +0,0 @@
---- flintqs-20070817.p6/src/TonelliShanks.h-orig 2012-01-30 19:52:40.000000000 +0000
-+++ flintqs-20070817.p6/src/TonelliShanks.h 2012-01-30 19:53:04.000000000 +0000
-@@ -19,6 +19,7 @@
-
- ============================================================================*/
-
-+#include <stdint.h>
- #include <stdlib.h>
-
- // =====================================================================
diff --git a/math/sage/files/spkg-patch-gfan-0.4plus.p1_-_patches_Makefile b/math/sage/files/spkg-patch-gfan-0.4plus.p1_-_patches_Makefile
deleted file mode 100644
index 1c35d7f07226..000000000000
--- a/math/sage/files/spkg-patch-gfan-0.4plus.p1_-_patches_Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
---- gfan-0.4plus.p1/patches/Makefile-orig 2012-02-01 18:41:42.000000000 +0000
-+++ gfan-0.4plus.p1/patches/Makefile 2012-02-01 18:42:10.000000000 +0000
-@@ -270,7 +270,7 @@
- default: $(OBJECTS) $(ADDITIONALOBJECTS) $(EXECS)
-
- $(MAIN): $(OBJECTS)
-- $(CXX) $(CXXFLAG64) $(OBJECTS) $(ADDITIONALLINKOPTIONS) $(GPROFFLAG) -o $(MAIN)
-+ $(CXX) ${LDFLAGS} $(CXXFLAG64) $(OBJECTS) $(ADDITIONALLINKOPTIONS) $(GPROFFLAG) -o $(MAIN)
-
- release:
- rm -f -r $(RELEASEDIR)/*
diff --git a/math/sage/files/spkg-patch-linbox-1.1.6.p6_-_spkg-install b/math/sage/files/spkg-patch-linbox-1.1.6.p6_-_spkg-install
deleted file mode 100644
index 16ebc8e53d73..000000000000
--- a/math/sage/files/spkg-patch-linbox-1.1.6.p6_-_spkg-install
+++ /dev/null
@@ -1,12 +0,0 @@
---- linbox-1.1.6.p6/spkg-install-orig 2012-01-23 04:02:57.000000000 +0000
-+++ linbox-1.1.6.p6/spkg-install 2012-01-23 04:03:12.000000000 +0000
-@@ -8,9 +8,6 @@
-
- CUR=`pwd`
-
--echo "Copying commentator patch"
--cp patches/commentator.C src/linbox/util/
--
- if [ $? -ne 0 ]; then
- echo "Error copying commentator OSX 10.4 fix"
- exit 1
diff --git a/math/sage/files/spkg-patch-linbox-1.1.6.p6_-_src_linbox_util_commentator.h b/math/sage/files/spkg-patch-linbox-1.1.6.p6_-_src_linbox_util_commentator.h
deleted file mode 100644
index 02aa3255667c..000000000000
--- a/math/sage/files/spkg-patch-linbox-1.1.6.p6_-_src_linbox_util_commentator.h
+++ /dev/null
@@ -1,11 +0,0 @@
---- linbox-1.1.6.p6/src/linbox/util/commentator.h-orig 2012-01-23 03:20:53.000000000 +0000
-+++ linbox-1.1.6.p6/src/linbox/util/commentator.h 2012-01-23 03:21:22.000000000 +0000
-@@ -76,7 +76,7 @@
- #define LVL_BLABLA = 10,
- #define LVL_NEVER = (2*PRINT_EVERYTHING)
-
--#ifndef DISABLE_COMMENTATOR
-+#ifndef XXDISABLE_COMMENTATOR
- namespace LinBox
- {
- // Forward declaration
diff --git a/math/sage/files/spkg-patch-polybori-0.8.1.p1_-_custom.py b/math/sage/files/spkg-patch-polybori-0.8.1.p1_-_custom.py
new file mode 100644
index 000000000000..54d8c0617697
--- /dev/null
+++ b/math/sage/files/spkg-patch-polybori-0.8.1.p1_-_custom.py
@@ -0,0 +1,11 @@
+--- polybori-0.8.1.p1/custom.py-orig 2012-04-10 03:58:28.000000000 +0000
++++ polybori-0.8.1.p1/custom.py 2012-04-10 04:01:48.000000000 +0000
+@@ -60,6 +60,8 @@
+ HAVE_TEX4HT=False
+ HAVE_PYTHON_EXTENSION=False
+ EXTERNAL_PYTHON_EXTENSION=True
++BOOST_TEST=False
++BOOST_PYTHON=False
+
+ # (CC and CXX should have been set by sage-env, but never mind...:)
+ try:
diff --git a/math/sage/files/spkg-patch-polybori-0.8.1.p1_-_patches_Cudd.cudd.cudd.h b/math/sage/files/spkg-patch-polybori-0.8.1.p1_-_patches_Cudd.cudd.cudd.h
new file mode 100644
index 000000000000..97ebd6a393e4
--- /dev/null
+++ b/math/sage/files/spkg-patch-polybori-0.8.1.p1_-_patches_Cudd.cudd.cudd.h
@@ -0,0 +1,18 @@
+--- polybori-0.8.1.p1/patches/Cudd.cudd.cudd.h.patch.orig 2012-04-13 01:19:43.000000000 +0000
++++ polybori-0.8.1.p1/patches/Cudd.cudd.cudd.h.patch 2012-04-13 01:22:34.000000000 +0000
+@@ -0,0 +1,15 @@
++--- polybori-0.8.1/Cudd/cudd/cudd.h.orig 2012-03-15 22:47:56.000000000 +0000
+++++ polybori-0.8.1/Cudd/cudd/cudd.h 2012-04-13 01:21:09.000000000 +0000
++@@ -87,6 +87,12 @@
++ #endif
++
++ #ifdef __cplusplus
+++#include <cstdio>
+++#else
+++#include <stdio.h>
+++#endif
+++
+++#ifdef __cplusplus
++ extern "C" {
++ #endif
++
diff --git a/math/sage/files/spkg-patch-pycrypto-2.1.0_-_patches_src.libtom.tomcrypt_pk.h b/math/sage/files/spkg-patch-pycrypto-2.1.0_-_patches_src.libtom.tomcrypt_pk.h
new file mode 100644
index 000000000000..908f078cb7ce
--- /dev/null
+++ b/math/sage/files/spkg-patch-pycrypto-2.1.0_-_patches_src.libtom.tomcrypt_pk.h
@@ -0,0 +1,14 @@
+--- /dev/null 2012-04-08 01:30:00.000000000 +0000
++++ pycrypto-2.1.0/patches_src.libtom.tomcrypt_pk.h 2012-04-08 01:30:26.000000000 +0000
+@@ -0,0 +1,11 @@
++--- src/src/libtom/tomcrypt_pk.h-orig 2012-01-21 19:43:56.000000000 +0000
+++++ src/src/libtom/tomcrypt_pk.h 2012-01-21 19:45:01.000000000 +0000
++@@ -496,7 +496,7 @@
++ int der_printable_value_decode(int v);
++
++ /* UTF-8 */
++-#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED)) && !defined(LTC_NO_WCHAR)
+++#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED) || defined(_GCC_WCHAR_T)) && !defined(LTC_NO_WCHAR)
++ #include <wchar.h>
++ #else
++ typedef ulong32 wchar_t;
diff --git a/math/sage/files/spkg-patch-pycrypto-2.1.0_-_spkg-install b/math/sage/files/spkg-patch-pycrypto-2.1.0_-_spkg-install
new file mode 100644
index 000000000000..902149044e28
--- /dev/null
+++ b/math/sage/files/spkg-patch-pycrypto-2.1.0_-_spkg-install
@@ -0,0 +1,11 @@
+--- pycrypto-2.1.0/spkg-install-orig 2012-04-08 01:30:47.000000000 +0000
++++ pycrypto-2.1.0/spkg-install 2012-04-08 01:31:41.000000000 +0000
+@@ -12,6 +12,8 @@
+ LDFLAGS="-m64 "; export LDFLAGS
+ fi
+
++patch -p0 < patches_src.libtom.tomcrypt_pk.h
++
+ CFLAGS="-I$SAGE_LOCAL/include -L$SAGE_LOCAL/lib $CFLAGS"
+ export CFLAGS
+
diff --git a/math/sage/files/spkg-patch-pycrypto-2.1.0_-_src_libtom_tomcrypt_pk.h b/math/sage/files/spkg-patch-pycrypto-2.1.0_-_src_libtom_tomcrypt_pk.h
deleted file mode 100644
index e4916df23ee1..000000000000
--- a/math/sage/files/spkg-patch-pycrypto-2.1.0_-_src_libtom_tomcrypt_pk.h
+++ /dev/null
@@ -1,11 +0,0 @@
---- pycrypto-2.1.0/src/src/libtom/tomcrypt_pk.h-orig 2012-01-21 19:43:56.000000000 +0000
-+++ pycrypto-2.1.0/src/src/libtom/tomcrypt_pk.h 2012-01-21 19:45:01.000000000 +0000
-@@ -496,7 +496,7 @@
- int der_printable_value_decode(int v);
-
- /* UTF-8 */
--#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED)) && !defined(LTC_NO_WCHAR)
-+#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED) || defined(_GCC_WCHAR_T)) && !defined(LTC_NO_WCHAR)
- #include <wchar.h>
- #else
- typedef ulong32 wchar_t;
diff --git a/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Doc_library_fcntl.rst b/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Doc_library_fcntl.rst
new file mode 100644
index 000000000000..550fd75eefca
--- /dev/null
+++ b/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Doc_library_fcntl.rst
@@ -0,0 +1,11 @@
+--- python-2.7.2.p4/src/Doc/library/fcntl.rst.orig 2011-06-11 15:46:23.000000000 +0000
++++ python-2.7.2.p4/src/Doc/library/fcntl.rst 2012-04-22 00:31:48.000000000 +0000
+@@ -50,8 +50,6 @@
+ operations are typically defined in the library module :mod:`termios` and the
+ argument handling is even more complicated.
+
+- The op parameter is limited to values that can fit in 32-bits.
+-
+ The parameter *arg* can be one of an integer, absent (treated identically to the
+ integer ``0``), an object supporting the read-only buffer interface (most likely
+ a plain Python string) or an object supporting the read-write buffer interface.
diff --git a/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Modules__ctypes_libffi_configure b/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Modules__ctypes_libffi_configure
new file mode 100644
index 000000000000..e320f86715ed
--- /dev/null
+++ b/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Modules__ctypes_libffi_configure
@@ -0,0 +1,21 @@
+--- python-2.7.2.p4/src/Modules/_ctypes/libffi/configure.orig 2011-06-11 15:46:26.000000000 +0000
++++ python-2.7.2.p4/src/Modules/_ctypes/libffi/configure 2012-04-22 00:23:14.000000000 +0000
+@@ -6289,7 +6289,7 @@
+ rm -rf conftest*
+ ;;
+
+-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
++amd64-*-freebsd*|x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+@@ -11275,6 +11275,9 @@
+ powerpc-*-freebsd*)
+ TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
+ ;;
++ powerpc64-*-freebsd*)
++ TARGET=POWERPC; TARGETDIR=powerpc
++ ;;
+ powerpc*-*-rtems*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+ ;;
diff --git a/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Modules_fcntlmodule.c b/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Modules_fcntlmodule.c
new file mode 100644
index 000000000000..bebebb089967
--- /dev/null
+++ b/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Modules_fcntlmodule.c
@@ -0,0 +1,53 @@
+--- python-2.7.2.p4/src/Modules/fcntlmodule.c.orig 2011-06-11 15:46:27.000000000 +0000
++++ python-2.7.2.p4/src/Modules/fcntlmodule.c 2012-04-22 00:23:34.000000000 +0000
+@@ -97,20 +97,15 @@
+ {
+ #define IOCTL_BUFSZ 1024
+ int fd;
+- /* In PyArg_ParseTuple below, we use the unsigned non-checked 'I'
++ /* In PyArg_ParseTuple below, we use the unsigned non-checked 'k'
+ format for the 'code' parameter because Python turns 0x8000000
+ into either a large positive number (PyLong or PyInt on 64-bit
+ platforms) or a negative number on others (32-bit PyInt)
+ whereas the system expects it to be a 32bit bit field value
+ regardless of it being passed as an int or unsigned long on
+- various platforms. See the termios.TIOCSWINSZ constant across
+- platforms for an example of thise.
+-
+- If any of the 64bit platforms ever decide to use more than 32bits
+- in their unsigned long ioctl codes this will break and need
+- special casing based on the platform being built on.
++ various platforms.
+ */
+- unsigned int code;
++ unsigned long code;
+ int arg;
+ int ret;
+ char *str;
+@@ -118,7 +113,7 @@
+ int mutate_arg = 1;
+ char buf[IOCTL_BUFSZ+1]; /* argument plus NUL byte */
+
+- if (PyArg_ParseTuple(args, "O&Iw#|i:ioctl",
++ if (PyArg_ParseTuple(args, "O&kw#|i:ioctl",
+ conv_descriptor, &fd, &code,
+ &str, &len, &mutate_arg)) {
+ char *arg;
+@@ -169,7 +164,7 @@
+ }
+
+ PyErr_Clear();
+- if (PyArg_ParseTuple(args, "O&Is#:ioctl",
++ if (PyArg_ParseTuple(args, "O&ks#:ioctl",
+ conv_descriptor, &fd, &code, &str, &len)) {
+ if (len > IOCTL_BUFSZ) {
+ PyErr_SetString(PyExc_ValueError,
+@@ -191,7 +186,7 @@
+ PyErr_Clear();
+ arg = 0;
+ if (!PyArg_ParseTuple(args,
+- "O&I|i;ioctl requires a file or file descriptor,"
++ "O&k|i;ioctl requires a file or file descriptor,"
+ " an integer and optionally an integer or buffer argument",
+ conv_descriptor, &fd, &code, &arg)) {
+ return NULL;
diff --git a/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Python_thread_pthread.h b/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Python_thread_pthread.h
new file mode 100644
index 000000000000..68ccb349c2c4
--- /dev/null
+++ b/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_Python_thread_pthread.h
@@ -0,0 +1,55 @@
+--- python-2.7.2.p4/src/Python/thread_pthread.h.orig 2011-06-11 15:46:28.000000000 +0000
++++ python-2.7.2.p4/src/Python/thread_pthread.h 2012-04-22 00:23:46.000000000 +0000
+@@ -38,13 +38,18 @@
+ #endif
+ #endif
+
++#ifdef __FreeBSD__
++#include <osreldate.h>
++#endif
++
+ /* The POSIX spec says that implementations supporting the sem_*
+ family of functions must indicate this by defining
+ _POSIX_SEMAPHORES. */
+ #ifdef _POSIX_SEMAPHORES
+ /* On FreeBSD 4.x, _POSIX_SEMAPHORES is defined empty, so
+ we need to add 0 to make it work there as well. */
+-#if (_POSIX_SEMAPHORES+0) == -1
++#if defined(__FreeBSD__) && __FreeBSD_version < 701104 && \
++ (_POSIX_SEMAPHORES+0) == -1
+ #define HAVE_BROKEN_POSIX_SEMAPHORES
+ #else
+ #include <semaphore.h>
+@@ -56,7 +61,6 @@
+ in default setting. So the process scope is preferred to get
+ enough number of threads to work. */
+ #ifdef __FreeBSD__
+-#include <osreldate.h>
+ #if __FreeBSD_version >= 500000 && __FreeBSD_version < 504101
+ #undef PTHREAD_SYSTEM_SCHED_SUPPORTED
+ #endif
+@@ -161,6 +165,7 @@
+ {
+ pthread_t th;
+ int status;
++ sigset_t set, oset;
+ #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
+ pthread_attr_t attrs;
+ #endif
+@@ -189,6 +194,8 @@
+ #if defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
+ pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
+ #endif
++ sigfillset(&set);
++ SET_THREAD_SIGMASK(SIG_BLOCK, &set, &oset);
+
+ status = pthread_create(&th,
+ #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
+@@ -200,6 +207,7 @@
+ (void *)arg
+ );
+
++ SET_THREAD_SIGMASK(SIG_SETMASK, &oset, NULL);
+ #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
+ pthread_attr_destroy(&attrs);
+ #endif
diff --git a/math/sage/files/spkg-patch-python-2.6.4.p13_-_src_setup.py b/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_setup.py
index 815551cdcb18..395e96dd9245 100644
--- a/math/sage/files/spkg-patch-python-2.6.4.p13_-_src_setup.py
+++ b/math/sage/files/spkg-patch-python-2.7.2.p4_-_src_setup.py
@@ -1,29 +1,29 @@
---- python-2.6.4.p13/src/setup.py-orig 2012-01-21 21:42:43.000000000 +0000
-+++ python-2.6.4.p13/src/setup.py 2012-01-21 21:45:11.000000000 +0000
-@@ -1273,16 +1273,24 @@
- )
+--- python-2.7.2.p4/src/setup.py-orig 2012-04-22 00:04:08.000000000 +0000
++++ python-2.7.2.p4/src/setup.py 2012-04-22 00:10:25.000000000 +0000
+@@ -1432,10 +1432,24 @@
+ macros = dict()
libraries = []
- elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'):
+ elif platform in ('freebsd4', 'freebsd5', 'freebsd6'):
# FreeBSD's P1003.1b semaphore support is very experimental
# and has many known problems. (as of June 2008)
-- macros = dict( # FreeBSD
+- macros = dict()
+ macros = dict( # FreeBSD 4-6
- HAVE_SEM_OPEN=0,
- HAVE_SEM_TIMEDWAIT=0,
- HAVE_FD_TRANSFER=1,
- )
- libraries = []
-
++ HAVE_SEM_OPEN=0,
++ HAVE_SEM_TIMEDWAIT=0,
++ HAVE_FD_TRANSFER=1,
++ )
++ libraries = []
++
+ elif platform in ('freebsd7', 'freebsd8', 'freebsd9', 'freebsd10'):
++ # FreeBSD's P1003.1b semaphore support is very experimental
++ # and has many known problems. (as of June 2008)
+ macros = dict( # FreeBSD 7+
+ HAVE_SEM_OPEN=1,
+ HAVE_SEM_TIMEDWAIT=1,
+ HAVE_FD_TRANSFER=1,
-+ )
-+ libraries = []
-+
++ )
+ libraries = []
+
elif platform.startswith('openbsd'):
- macros = dict( # OpenBSD
- HAVE_SEM_OPEN=0, # Not implemented
diff --git a/math/sage/files/spkg-patch-sage-5.0_-_sage_combinat_partitions_c.cc b/math/sage/files/spkg-patch-sage-5.0_-_sage_combinat_partitions_c.cc
new file mode 100644
index 000000000000..8fa517504fd7
--- /dev/null
+++ b/math/sage/files/spkg-patch-sage-5.0_-_sage_combinat_partitions_c.cc
@@ -0,0 +1,11 @@
+--- sage-5.0.beta13/sage/combinat/partitions_c.cc-orig 2012-04-20 01:01:41.000000000 +0000
++++ sage-5.0/sage/combinat/partitions_c.cc 2012-04-20 01:02:47.000000000 +0000
+@@ -152,7 +152,7 @@
+ const unsigned int double_precision = DBL_MANT_DIG; // The assumed precision of a double.
+
+
+-#if defined(__sparc) || defined(__CYGWIN__)
++#if defined(__sparc) || defined(__CYGWIN__) || defined(__FreeBSD__)
+ // On sparc solaris long double is bad/broken/different, etc. E.g.,
+ // LDBL_MANT_DIG is 113 rather than 106, which causes all kinds of trouble.
+ // So we only use double_precision.
diff --git a/math/sage/files/spkg-patch-sage-5.0_-_sage_misc_getusage.py b/math/sage/files/spkg-patch-sage-5.0_-_sage_misc_getusage.py
new file mode 100644
index 000000000000..a44ca946f567
--- /dev/null
+++ b/math/sage/files/spkg-patch-sage-5.0_-_sage_misc_getusage.py
@@ -0,0 +1,40 @@
+--- sage-5.0.beta13/sage/misc/getusage.py-orig 2012-04-11 00:14:47.000000000 +0000
++++ sage-5.0/sage/misc/getusage.py 2012-04-11 00:47:03.000000000 +0000
+@@ -20,6 +20,8 @@
+ """
+ Return the 'top' or 'prstat' line that contains this running Sage
+ process.
++ For FreeBSD, return the line containing this running Sage process from
++ 'ps -axwww -o pid,user,vsz,rss,state,pri,nice,time,cpu,comm'.
+
+ OUTPUT:
+
+@@ -53,6 +55,8 @@
+ cmd = 'top -l 1 |grep "^ *%s "' % pid
+ elif U == 'sunos':
+ cmd = '/usr/bin/prstat -n 100000 1 1 | grep "^ *%s "' % pid
++ elif U == 'freebsd':
++ cmd = 'ps -axwww -o pid,user,vsz,rss,state,pri,nice,time,cpu,comm | grep "^ *%s "' % pid
+ else:
+ raise NotImplementedError("top not implemented on platform %s" % U)
+
+@@ -83,6 +87,9 @@
+ usage, ``prstat`` will output the data in KB, MB or GB. In each
+ case, the value returned by this function will always be in MB.
+
++ - ``FreeBSD`` - Returns float number (in megabytes) that matches
++ RSS column of ``ps -auxwww``
++
+ - ``other`` - not implemented for any other operating systems
+
+ EXAMPLES::
+@@ -129,6 +136,9 @@
+ m = float(memory_in_KB_MB_or_GB.strip("M"))
+ elif memory_in_KB_MB_or_GB.endswith("G"):
+ m = float(memory_in_KB_MB_or_GB.strip("G")) * 1024
++ elif U == 'freebsd':
++ memory_in_KB = top().split()[3]
++ m = float(memory_in_KB) / 1024
+ else:
+ raise NotImplementedError("memory usage not implemented on platform %s" % U)
+
diff --git a/math/sage/files/spkg-patch-singular-3-1-3-3.p3_-_src_omalloc_configure b/math/sage/files/spkg-patch-singular-3-1-3-3.p3_-_src_omalloc_configure
deleted file mode 100644
index 3d574426ca52..000000000000
--- a/math/sage/files/spkg-patch-singular-3-1-3-3.p3_-_src_omalloc_configure
+++ /dev/null
@@ -1,12 +0,0 @@
---- singular-3-1-3-3.p3/src/omalloc/configure-orig 2012-01-21 19:51:08.000000000 +0000
-+++ singular-3-1-3-3.p3/src/omalloc/configure 2012-01-21 19:51:32.000000000 +0000
-@@ -1293,9 +1293,6 @@
- echo "$ac_t""no" 1>&6
- fi
-
--if test "$ac_cv_prog_AR" != ar; then
-- { echo "configure: error: *** ar program not found" 1>&2; exit 1; }
--fi
- for ac_prog in perl
- do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
diff --git a/math/sage/files/spkg-patch-singular-3-1-3-3.p6_-_patches_omalloc.configure.patch b/math/sage/files/spkg-patch-singular-3-1-3-3.p6_-_patches_omalloc.configure.patch
new file mode 100644
index 000000000000..381934fd7947
--- /dev/null
+++ b/math/sage/files/spkg-patch-singular-3-1-3-3.p6_-_patches_omalloc.configure.patch
@@ -0,0 +1,16 @@
+--- /dev/null 2012-04-08 00:25:00.000000000 +0000
++++ singular-3-1-3-3.p6/patches/omalloc.configure.patch 2012-04-08 00:25:39.000000000 +0000
+@@ -0,0 +1,13 @@
++diff -ur src/omalloc/configure patches/omalloc/configure
++--- src/omalloc/configure 2011-05-12 08:32:11.000000000 +0000
+++++ patches/omalloc/configure 2012-04-08 00:22:37.000000000 +0000
++@@ -1293,9 +1293,6 @@
++ echo "$ac_t""no" 1>&6
++ fi
++
++-if test "$ac_cv_prog_AR" != ar; then
++- { echo "configure: error: *** ar program not found" 1>&2; exit 1; }
++-fi
++ for ac_prog in perl
++ do
++ # Extract the first word of "$ac_prog", so it can be a program name with args.
diff --git a/math/sage/files/spkg-patch-singular-3-1-3-3.p6_-_spkg-install b/math/sage/files/spkg-patch-singular-3-1-3-3.p6_-_spkg-install
new file mode 100644
index 000000000000..f64c6337ed6d
--- /dev/null
+++ b/math/sage/files/spkg-patch-singular-3-1-3-3.p6_-_spkg-install
@@ -0,0 +1,11 @@
+--- singular-3-1-3-3.p6/spkg-install-orig 2012-04-08 01:57:01.000000000 +0000
++++ singular-3-1-3-3.p6/spkg-install 2012-04-08 01:58:19.000000000 +0000
+@@ -108,7 +108,7 @@
+
+ patches="assert.h.diff sing_win.cc.diff Minor.h.patch os_x_ppc.patch \
+ Singular.configure.patch make_parallel.patch Singular.Makefile.in.shared.patch \
+- factory.GNUmakefile.in.patch"
++ factory.GNUmakefile.in.patch omalloc.configure.patch"
+
+ if [ "$UNAME" = "CYGWIN" ]; then
+ patches="$patches IntegerProgramming-Makefile.in.diff"
diff --git a/math/sage/files/spkg-patch-sympow-1.018.1.p11_-_src_disk.c b/math/sage/files/spkg-patch-sympow-1.018.1.p11_-_src_disk.c
new file mode 100644
index 000000000000..6efde5563398
--- /dev/null
+++ b/math/sage/files/spkg-patch-sympow-1.018.1.p11_-_src_disk.c
@@ -0,0 +1,11 @@
+--- sympow-1.018.1.p11/src/disk.c-orig 2012-04-19 02:33:51.000000000 +0000
++++ sympow-1.018.1.p11/src/disk.c 2012-04-19 02:34:22.000000000 +0000
+@@ -39,7 +39,7 @@
+ else if (((sp&3)==0) && CM_CASE) {if (2*ep==sp) S[3]='l'; else S[3]='h';}
+ else {if (2*ep==sp) S[3]='L'; else S[3]='H';}
+ if (HECKE && dv) {TACKS[which]=malloc(dv*sizeof(QD)); TACKON[which]=dv;}
+- else if (dv<=sp/2) TACKON[which]=0;
++ else if (dv<=sp/2) {TACKS[which]=NULL; TACKON[which]=0;}
+ else {TACKS[which]=malloc((dv-sp/2)*sizeof(QD)); TACKON[which]=dv-sp/2;}
+ S[4]=0; F=fopen("datafiles/param_data","r"); strcpy(U,S);
+ if (ANAL_RANK) {if (dv>0) U[0]='A'; else U[0]='m';}
diff --git a/math/sage/files/spkg-patch-sympow-1.018.1.p9_-_src_fpu.c b/math/sage/files/spkg-patch-sympow-1.018.1.p9_-_src_fpu.c
deleted file mode 100644
index 50223f543631..000000000000
--- a/math/sage/files/spkg-patch-sympow-1.018.1.p9_-_src_fpu.c
+++ /dev/null
@@ -1,11 +0,0 @@
---- sympow-1.018.1.p9/src/fpu.c-orig 2012-02-01 01:01:04.000000000 +0000
-+++ sympow-1.018.1.p9/src/fpu.c 2012-02-01 01:01:18.000000000 +0000
-@@ -1,8 +1,4 @@
-
- void fpu_53bits()
- {
--#ifdef x86
--#include <fpu_control.h>
--fpu_control_t fpu_control=0x027f; _FPU_SETCW(fpu_control);
--#endif
- }
diff --git a/math/sage/pkg-descr b/math/sage/pkg-descr
index fefc0f5361df..b7fea2d7b67a 100644
--- a/math/sage/pkg-descr
+++ b/math/sage/pkg-descr
@@ -5,8 +5,4 @@ Python-based interface.
Mission: Creating a viable free open source alternative to Magma, Maple,
Mathematica and Matlab.
-This port is a work in progress. It creates a sage that is mostly functional,
-but it does fail a few tests. Suggestions for improvement to the maintainer
-are welcome.
-
WWW: http://www.sagemath.org/