Differences between revisions 10 and 16 (spanning 6 versions)
Revision 10 as of 2009-08-07 11:16:50
Size: 28128
Editor: PeterJeremy
Comment: Continue documenting the necessary patches.
Revision 16 as of 2022-04-05 01:20:25
Size: 0
Editor: mkoeppe
Comment: outdated
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Sage FreeBSD 7.x and 8.x build notes for Sage 4.1 =

Note that this page is under construction and currently incomplete. In particular, it still includes references to sage-3.4 in areas that have not been converted to sage-4.1.

'''Contents'''
<<TableOfContents(2)>>

== Overall build environment differences ==
 * `sh` and `/bin/sh` are a POSIX shell, rather than `bash`.
 * `make` is the BSD make, not GNU make

== Preparatory work ==
 * Install ports/shells/bash or ports/shells/bash3 (I used 4.0.24)
 * Install ports/devel/gmake
 * Install ports/lang/gcc43 - FreeBSD no longer ships with a Fortran compiler by default.
 * Install ports/devel/autoconf262
 * Install ports/converters/libiconv

It's likely there are other dependencies, I haven't tried building sage in a clean (tinderbox) environment.

== Building Sage ==

The Sage build chain automatically unpacks and builds each spkg, however in order to build on FreeBSD, a number of spkgs need patching. Rather than manually unpack, patch and repack each spkg, I have instead modified base/sage-spkg to automatically apply a local patch if it exists.

=== On FreeBSD 7.x ===
 * Unpack sage-4.1.tar
 * `cd sage-4.1`
 * `mkdir -p local/bin spkg/patches`
 * Create symlinks to mask name differences.
  . `ln -s /usr/local/bin/gmake local/bin/make`
  . `ln -s /usr/local/bin/bash local/bin/sh`
  . `ln -s /usr/local/bin/gcc43 local/bin/gcc`
  . `ln -s /usr/local/bin/g++43 local/bin/g++`
  . `ln -s /usr/local/bin/gfortran43 local/bin/gfortran`
 * Copy the patches listed below into `spkg/patches`
 * Build Sage
  . `SAGE_FORTRAN=/usr/local/bin/gfortran43 SAGE_FORTRAN_LIB=/usr/local/lib/gcc43/libgfortran.so gmake`

{{{#!wiki comment
=== On FreeBSD 8.x ===
 * Unpack sage-3.4.tar
 * `cd sage-3.4`
 * `mkdir -p local/bin spkg/patches`
 * Create symlinks to mask name differences.
  . `ln -s /usr/local/bin/gmake local/bin/make`
  . `ln -s /usr/local/bin/bash local/bin/sh`
  . `ln -s /usr/local/bin/gcc43 local/bin/gcc`
  . `ln -s /usr/local/bin/g++43 local/bin/g++`
  . `ln -s /usr/local/bin/gfortran43 local/bin/gfortran` # specifying SAGE_FORTRAN isn't sufficient
 * Unpack the attached shar archive: [[attachment:sage-3.4.shar]]
 * Apply patches to base build system
  . `patch < spkg/patches/base.patch`
 * Build Sage
  . `CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib gmake`
}}}
== Current Status ==
{{{#!wiki comment
Currently, the following tests fail on FreeBSD 7.x/amd64. One test runs out of swap (process exceeds 4GB) and there are a number of core dumps. Full details [[freebsd/sage-3.4/7.xErrs|here]].
{{{
        sage -t "devel/sage/doc/en/bordeaux_2008/modular_forms_and_hecke_operators.rst"
        sage -t "devel/sage/sage/misc/getusage.py"
        sage -t "devel/sage/sage/modules/free_module_element.pyx"
        sage -t "devel/sage/sage/libs/pari/gen.pyx"
        sage -t "devel/sage/sage/parallel/multiprocessing.py"
        sage -t "devel/sage/sage/parallel/decorate.py"
        sage -t "devel/sage/sage/rings/polynomial/polynomial_quotient_ring_element.py"
        sage -t "devel/sage/sage/rings/polynomial/pbori.pyx"
        sage -t "devel/sage/sage/rings/polynomial/polynomial_ring_constructor.py"
        sage -t "devel/sage/sage/rings/polynomial/polynomial_singular_interface.py"
        sage -t "devel/sage/sage/rings/polynomial/polynomial_integer_dense_flint.pyx"
        sage -t "devel/sage/sage/rings/integer.pyx"
        sage -t "devel/sage/sage/rings/tests.py"
        sage -t "devel/sage/sage/rings/real_double.pyx"
        sage -t "devel/sage/sage/lfunctions/sympow.py"
        sage -t "devel/sage/sage/combinat/partition.py"
        sage -t "devel/sage/sage/calculus/calculus.py"
        sage -t "devel/sage/sage/plot/plot3d/shapes2.py"
        sage -t "devel/sage/sage/plot/plot3d/shapes.pyx"
        sage -t "devel/sage/sage/plot/plot3d/plot3d.py"
        sage -t "devel/sage/sage/plot/plot3d/index_face_set.pyx"
        sage -t "devel/sage/sage/plot/plot3d/parametric_surface.pyx"
        sage -t "devel/sage/sage/schemes/elliptic_curves/ell_rational_field.py"
        sage -t "devel/sage/sage/server/misc.py"
        sage -t "devel/sage/sage/ext/fast_eval.pyx"
}#}}
}}}

{{{#!wiki comment
Currently, the following tests fail on FreeBSD 8-current/amd64. Two run out of swap (process exceeds 9GB) and 5 are numeric noise. There are also a number of core dumps. Full details [[freebsd/sage-3.4/8.xErrs|here]].
{{{
        sage -t "devel/sage/sage/schemes/elliptic_curves/lseries_ell.py"
        sage -t "devel/sage/sage/schemes/elliptic_curves/ell_rational_field.py"
        sage -t "devel/sage/sage/modules/free_module_element.pyx"
        sage -t "devel/sage/sage/libs/pari/gen.pyx"
        sage -t "devel/sage/sage/misc/getusage.py"
        sage -t "devel/sage/sage/calculus/calculus.py"
        sage -t "devel/sage/sage/combinat/partition.py"
        sage -t "devel/sage/sage/lfunctions/sympow.py"
        sage -t "devel/sage/sage/ext/fast_eval.pyx"
        sage -t "devel/sage/sage/parallel/multiprocessing.py"
        sage -t "devel/sage/sage/parallel/decorate.py"
        sage -t "devel/sage/sage/rings/real_double.pyx"
        sage -t "devel/sage/sage/rings/polynomial/polynomial_integer_dense_flint.pyx"
        sage -t "devel/sage/sage/rings/polynomial/polynomial_quotient_ring_element.py"
        sage -t "devel/sage/sage/rings/polynomial/pbori.pyx"
        sage -t "devel/sage/sage/rings/tests.py"
        sage -t "devel/sage/sage/rings/integer.pyx"
}#}}
}}}

== Notes on spkgs and attached patches ==

A number of the following patches change `make` to `${MAKE}`. This the recommended way to recursively invoke make to ensure that the subordinate make is the same as the parent make (and also ensures that the two make instances will communicate on things like '-jX').

=== base.patch ===

[[attachment:base.txt]]
 * The patch to base/sage-spkg enables the local patching that the rest of the patches rely on. Note that this patch is not intended to be merged into sage but provides a convenient mechanism to apply local patches without requiring that the spkg files are locally re-rolled.
/* * The patch to standard/deps ensures that bash is used. */

=== atlas-3.8.3.p5 ===
Various fixes to make it compile on FreeBSD
{{{#!wiki comment
 * `sysctl` is not in the default user path so use an explicit pathname (optional)
 * The newer AMD CPUs all identify as 'Athlon' so use the existence of multiple cores to distinguish between K7 (i386) and later (Hammer) CPUs. (optional)
 * Correct various sysctl OIDs to match the names FreeBSD uses. (optional) This and previous two reported upstream as https://sourceforge.net/tracker/?func=detail&atid=379483&aid=2728927&group_id=23725
}}}
 * FreeBSD uses an '_fbsd' suffix on the ELF format supported by `ld` - prevents `ld: unrecognised emulation mode: elf_x86_64` error during atlas build. Reported upstream as https://sourceforge.net/tracker/?func=detail&atid=379483&aid=2728930&group_id=23725
 * Building the `libclapack.so` should result in a `libclapack.so` being created. This appears to be a copy-and-paste error in atlas and has been reported as https://sourceforge.net/tracker/?func=detail&atid=379483&aid=2728935&group_id=23725 (Note that this is not relevant to sage as libclapack is not built or used).
 * numpy on FreeBSD expects atlas to build different and (according to the FreeBSD numpy port, static) threaded libraries: libatlas_r instead of libatlas and libalapack_r instead of liblapack. libatlas_r is built as part of the threaded version of atlas. libalapack_r is a FreeBSD special which explicitly combines all of liblapack from the atlas lapack build with the threaded atlas version of liblapack.

numpy error from last point above:
{{{
atlas_blas_info:
  libraries f77blas,cblas,atlas_r not found in /usr/home/peter/sage-4.1/local/lib
  NOT AVAILABLE

/usr/home/peter/sage-4.1/spkg/build/numpy-1.3.0.p0/src/numpy/distutils/system_info.py:1383: UserWarning:
    Atlas (http://math-atlas.sourceforge.net/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [atlas]) or by setting
    the ATLAS environment variable.
  warnings.warn(AtlasNotFoundError.__doc__)
...
atlas_info:
  libraries f77blas,cblas,atlas_r not found in /usr/home/peter/sage-4.1/local/lib
  libraries lapack_atlas not found in /usr/home/peter/sage-4.1/local/lib
numpy.distutils.system_info.atlas_info
  NOT AVAILABLE

/usr/home/peter/sage-4.1/spkg/build/numpy-1.3.0.p0/src/numpy/distutils/system_info.py:1290: UserWarning:
    Atlas (http://math-atlas.sourceforge.net/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [atlas]) or by setting
    the ATLAS environment variable.
  warnings.warn(AtlasNotFoundError.__doc__)
...
}}}

{{{#!wiki comment
=== clisp-2.46.p7 ===
The FreeBSD/amd64 process memory map is incompatible with the memory mapping done by clisp. The patch moves the memory map down 8 bits. An alternative (used by the FreeBSD clisp port) is to pass `--disable-mmap` to configure.
}}}
{{{#!wiki comment
=== eclib-20080310.p7 ===
Various 'make' fixes - see above. Sage local patch: [[http://trac.sagemath.org/sage_trac/ticket/5864|#5864]]
}}}
{{{#!wiki comment
=== ecm-6.2.1.p0 ===
Portability fixes so the configure script works with a POSIX shell. Submitted upstream as http://gforge.inria.fr/tracker/index.php?func=detail&aid=7639&group_id=135&atid=623
}}}
{{{#!wiki comment
=== fortran-20071120.p5 ===
FreeBSD doesn't have a '-f' option on `readlink` - sage local patch.
}}}
{{{#!wiki comment
=== freetype-2.3.5.p0 ===
Various 'make' fixes - see above. Sage local patch: [[http://trac.sagemath.org/sage_trac/ticket/5866|#5866]]
}}}
{{{#!wiki comment
=== gap-4.4.12.p1 ===
Patches (mostly taken from the FreeBSD port) to make gap compile on FreeBSD.
}}}
{{{#!wiki comment
=== gd-2.0.35.p1 ===
Sage local patch needed to make gd correctly detect libiconv: [[http://trac.sagemath.org/sage_trac/ticket/5867|#5867]]. Otherwise it fails with:
{{{
checking for shared library run path origin... done
checking for iconv... no, consider installing GNU libiconv
checking iconv.h usability... yes
checking iconv.h presence... yes
checking for iconv.h... yes
checking whether iconv.h defines iconv_t... yes
...
 gcc -DHAVE_CONFIG_H -I. -I. -I. -I/home/pjeremy/sage-3.4/local/include/freetype2 -I/home/pjeremy/sage-3.4/local/include -I/home/pjeremy/sage-3.4/local/include -fPIC -g -I/home/pjeremy/sage-3.4/local/include -I/home/pjeremy/sage-3.4/local/include/freetype2/ -MT gdkanji.lo -MD -MP -MF .deps/gdkanji.Tpo -c gdkanji.c -fPIC -DPIC -o .libs/gdkanji.o
gdkanji.c:30: error: conflicting types for 'libiconv'
/usr/local/include/iconv.h:83: error: previous declaration of 'libiconv' was here
gdkanji.c:40: error: conflicting types for 'libiconv'
/usr/local/include/iconv.h:83: error: previous declaration of 'libiconv' was here
make[4]: *** [gdkanji.lo] Error 1
make[4]: Leaving directory `/home/pjeremy/sage-3.4/spkg/build/gd-2.0.35.p1/src'
}#}}
}}}
{{{#!wiki comment
=== gmp-mpir-0.9 ===
Various 'make' fixes - see above.
}}}
{{{#!wiki comment
=== iml-1.0.1.p11 ===
Remove a stray warning by not attempting to execute ${CFLAGS}
}}}
{{{#!wiki comment
=== libgcrypt-1.4.3.p0 ===
Chase shared library name difference on FreeBSD. Sage local patch: [[http://trac.sagemath.org/sage_trac/ticket/5868|#5868]]. Otherwise the gnutls build fails:
{{{
gcc -std=gnu99 -shared .libs/gnutls_openssl.o .libs/openssl_compat.o -Wl,--whole-archive ../lgl/.libs/liblgnu.a ../lib/minitasn1/.libs/libminitasn1.a -Wl,--no-whole-archive -Wl,--rpath -Wl,/home/pjeremy/sage-3.4/local/lib -Wl,--rpath -Wl,/usr/local/lib -L/home/pjeremy/sage-3.4/spkg/build/gnutls-2.2.1.p1/src/lib/.libs -L/home/pjeremy/sage-3.4/local/lib -lgcrypt -L/usr/local/lib -lintl -liconv -lgpg-error -lgnutls -Wl,-soname -Wl,libgnutls-openssl.so.27 -o .libs/libgnutls-openssl.so.27
/usr/bin/ld: /home/pjeremy/sage-3.4/local/lib/libgcrypt.a(libgcrypt_la-visibility.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC
/home/pjeremy/sage-3.4/local/lib/libgcrypt.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
libtool: install: error: relink `libgnutls-openssl.la' with the above command before installing it
make[5]: *** [install-libLTLIBRARIES] Error 1
make[5]: Leaving directory `/home/pjeremy/sage-3.4/spkg/build/gnutls-2.2.1.p1/src/libextra'
}#}}
}}}
{{{#!wiki comment
=== libgpg_error-1.6.p0 ===
Chase shared library name difference on FreeBSD. Sage local patch: [[http://trac.sagemath.org/sage_trac/ticket/5869|#5869]]
. Otherwise the gnutls build fails:
{{{
gcc -std=gnu99 -shared .libs/gnutls_openssl.o .libs/openssl_compat.o -Wl,--whole-archive ../lgl/.libs/liblgnu.a ../lib/minitasn1/.libs/libminitasn1.a -Wl,--no-whole-archive -Wl,--rpath -Wl,/home/pjeremy/sage-3.4/local/lib -Wl,--rpath -Wl,/usr/local/lib -L/home/pjeremy/sage-3.4/spkg/build/gnutls-2.2.1.p1/src/lib/.libs -L/home/pjeremy/sage-3.4/local/lib -lgcrypt -L/usr/local/lib -lintl -liconv -lgpg-error -lgnutls -Wl,-soname -Wl,libgnutls-openssl.so.27 -o .libs/libgnutls-openssl.so.27
/usr/bin/ld: /home/pjeremy/sage-3.4/local/lib/libgpg-error.a(libgpg_error_la-strsource.o): relocation R_X86_64_32S can not be used when making a shared object; recompile with -fPIC
/home/pjeremy/sage-3.4/local/lib/libgpg-error.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
libtool: install: error: relink `libgnutls-openssl.la' with the above command before installing it
make[5]: *** [install-libLTLIBRARIES] Error 1
make[5]: Leaving directory `/home/pjeremy/sage-3.4/spkg/build/gnutls-2.2.1.p1/src/libextra'
}#}}
}}}
{{{#!wiki comment
=== libm4ri-20090128 ===
The configure script is pretty much beyond redemption on FreeBSD. Instead fix the autoconf inputs to support FreeBSD and re-run autoconf. The libm4ri fixes have all be forwarded to the libm4ri maintainer and accepted by them.

Also ensure that CPPFLAGS from the environment is passed into the libm4ri build process. Sage local patch.
}}}
{{{#!wiki comment
=== linbox-1.1.6 ===
Detect FreeBSD and appropriately select BLAS and Atlas libraries. Sage local patch: [[http://trac.sagemath.org/sage_trac/ticket/5870|#5870]].
}}}

=== matplotlib-0.98.5.3rc0-svn6910.p4 ===
Add hooks to ensure that the local Sage versions of dependencies are used by FreeBSD. Otherwise you get:
{{{
BUILDING MATPLOTLIB
            matplotlib: 0.98.6svn
                python: 2.5.2 (r252:60911, Apr 1 2009, 08:50:05) [GCC
                        4.3.4 20090326 (prerelease)]
              platform: freebsd7

REQUIRED DEPENDENCIES
                 numpy: no
                        * You must install numpy 1.1 or later to build
                        * matplotlib.
Error building matplotlib package.
}#}}

Add support for FreeBSD later than 6.x. Otherwise you get :
{{{
REQUIRED DEPENDENCIES
Traceback (most recent call last):
  File "setup.py", line 119, in <module>
    if not check_for_numpy():
  File "/home/pjeremy/sage-3.4/spkg/build/matplotlib-0.98.5.3rc0-svn6910.p3/src/setupext.py", line 499, in check_for_numpy
    add_base_flags(module)
  File "/home/pjeremy/sage-3.4/spkg/build/matplotlib-0.98.5.3rc0-svn6910.p3/src/setupext.py", line 320, in add_base_flags
    [os.path.join(p, 'include') for p in basedir[sys.platform] ])
KeyError: 'freebsd7'
Error building matplotlib package.
}#}}

gcc4.3 (though not gcc4.2) appears to define putchar() in a way that breaks the putchar() definitions inside ttconv. I couldn't quickly identify what the underlying cause was so I took the easy way out and undef'd the offending putchar() macro.

Individual character bounding boxes in AFM files do not have to be integral so convert each bounding box to a list of floats, rather than a list of ints. This corrects a problem where most of the tests would fail with `ValueError: invalid literal for int() with base 10: '539.621'`.

All three sub-patches are in [[http://trac.sagemath.org/sage_trac/ticket/5873|#5873]]

{{{#!wiki comment
=== mpfr-2.4.1 ===
Portability fixes so the configure script works with a POSIX shell.
}}}
{{{#!wiki comment
=== ntl-5.4.2.p6 ===
Correctly pass `-fPIC` when building the shared library - [[http://trac.sagemath.org/sage_trac/ticket/5872|#5872]]
}}}
{{{#!wiki comment
=== numpy-1.2.0.p0 ===
Correctly pass `-fPIC` when building the shared library.
Various fixes to handle correct fortran and library detection on FreeBSD.
}}}
{{{#!wiki comment
=== pari-2.3.3.p0 ===
FreeBSD refers to the x86_64 architecture under its original name of 'amd64' so use this as an alias for x86_64. The `-fPIC' fix is needed to correct:
{{{
gcc -o libpari-gmp.so.2.3.3 -shared -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -Wl,-shared,-soname=libpari-gmp.so.2 mp.o mpinl.o Flx.o Qfb.o RgX.o alglin1.o alglin2.o arith1.o arith2.o base1.o base2.o base3.o base4.o base5.o bibli1.o bibli2.o buch1.o buch2.o buch3.o buch4.o galconj.o gen1.o gen2.o gen3.o ifactor1.o perm.o polarit1.o polarit2.o polarit3.o rootpol.o subcyclo.o subgroup.o trans1.o trans2.o trans3.o anal.o compat.o default.o errmsg.o es.o init.o intnum.o members.o sumiter.o aprcl.o elldata.o elliptic.o galois.o groupid.o kummer.o mpqs.o nffactor.o part.o stark.o subfield.o thue.o -lc -lm -L/home/pjeremy/sage-3.4/local/lib -lgmp
/usr/bin/ld: mp.o: relocation R_X86_64_32S can not be used when making a shared object; recompile with -fPIC
mp.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[3]: *** [libpari-gmp.so.2.3.3] Error 1
make[3]: Leaving directory `/home/pjeremy/sage-3.4/spkg/build/pari-2.3.3.p0/src/Ofreebsd-amd64'
}#}}
}}}
{{{#!wiki comment
=== python-2.5.2.p9 ===
Include the python patches from the FreeBSD port. This adds support for FreeBSD 7 and 8.

The patch to Lib/test/seq_tests.py disables the memory-exhaustion tests on 64-bit architectures. Otherwise, those tests allocate a 32GB chunk of memory and attempt to use it all. The default process size on FreeBSD/amd64 allows the allocation to succeed but actually using the memory generally results in swap exhaustion. This fix comes from python-2.5.4.
}}}

=== r-2.6.1.p23 ===
Pass CFLAGS, CPPFLAGS and LDFLAGS from the environment into the build process. This also corrects a typo in CPPFLAGS.

Note that FreeBSD needs the path to libiconv to be explicitly specified. In theory, --with-libiconv-prefix should work but configure script is broken and ignores that path when looking for libiconv. Hard-wire /usr/local/include and /usr/local/lib via xxFLAGS.

Note that the X11 detection in spkg-install will not work anywhere other than Linux. This needs future work.

These patches are all local to Sage.

{{{#!wiki comment
=== readline-5.2.p6 ===
Chase shared library name difference on FreeBSD. Sage local patch: [[http://trac.sagemath.org/sage_trac/ticket/5874|#5874]]. Without this if, the build fails with
{{{
...
gcc -shared -o libreadline.so.5 readline.so vi_mode.so funmap.so keymaps.so parens.so search.so rltty.so complete.so bind.so isearch.so display.so signals.so util.so kill.so undo.so macro.so input.so callback.so terminal.so text.so nls.so misc.so xmalloc.so history.so histexpand.so histfile.so histsearch.so shell.so mbutil.so tilde.so compat.so
rm -f libhistory.so.5
gcc -shared -o libhistory.so.5 history.so histexpand.so histfile.so histsearch.so shell.so mbutil.so xmalloc.so
make[3]: Leaving directory `/home/pjeremy/sage-3.4/spkg/build/readline-5.2.p6/src/shlib'
( cd shlib ; make -w DESTDIR= install )
make[3]: Entering directory `/home/pjeremy/sage-3.4/spkg/build/readline-5.2.p6/src/shlib'
/bin/sh ../support/mkdirs /home/pjeremy/sage-3.4/local/lib
/bin/sh ../support/shlib-install -O freebsd -d /home/pjeremy/sage-3.4/local/lib -b /home/pjeremy/sage-3.4/local/bin -i "/usr/bin/install -c -m 644" libhistory.so.5
/bin/sh ../support/shlib-install -O freebsd -d /home/pjeremy/sage-3.4/local/lib -b /home/pjeremy/sage-3.4/local/bin -i "/usr/bin/install -c -m 644" libreadline.so.5
install: you may need to run ldconfig
make[3]: Leaving directory `/home/pjeremy/sage-3.4/spkg/build/readline-5.2.p6/src/shlib'
make[2]: Leaving directory `/home/pjeremy/sage-3.4/spkg/build/readline-5.2.p6/src'
Readline's build claims to have finished, but files that should have been built weren't.
}#}}

Applying the fix from FreeBSD ports to remove the check on objformat does not correct the above problem.
}}}
{{{#!wiki comment
=== sage-3.4 ===
FreeBSD does not include a definition for log2() in libm. Use a simplistic definition of log2(x) = log2(e) * ln(x)
}}}

=== sage_scripts-4.1.rc1 ===
Patch sage-spkg to apply local patches. This patch also disables deletion of the spkg/build/FOO temporary directories - which was useful during porting. This latter patch can be safely removed.

{{{#!wiki comment
=== scipy-20071020-0.6.p4 ===
scipy uses local/lib/python2.5/site-packages/numpy/distutils/fcompiler/gnu.py to locate a Fortran compiler. This code only looks for g77, f77, gfortran and f95. Whilst it has some patches to look in sage_fortran, this does not appear to work for scipy. The work-around is to create a symlink to the actual Fortran compiler in local/bin, otherwise the scipy build fails with:
{{{
building 'mach' library
using additional config_fc from setup script for fortran compiler: {'noopt': ('scipy/integrate/setup.py', 1)}
customize Gnu95FCompiler
Could not locate executable gfortran
Could not locate executable f95
Traceback (most recent call last):
  File "setup.py", line 53, in <module>
    setup_package()
  File "setup.py", line 45, in setup_package
    configuration=configuration )
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/site-packages/numpy/distutils/core.py", line 184, in setup
    return old_setup(**new_attr)
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/distutils/dist.py", line 974, in run_commands
    self.run_command(cmd)
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/distutils/dist.py", line 994, in run_command
    cmd_obj.run()
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/site-packages/numpy/distutils/command/build.py", line 37, in run
    old_build.run(self)
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/distutils/command/build.py", line 112, in run
    self.run_command(cmd_name)
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/distutils/cmd.py", line 333, in run_command
    self.distribution.run_command(command)
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/distutils/dist.py", line 994, in run_command
    cmd_obj.run()
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/site-packages/numpy/distutils/command/build_clib.py", line 92, in run
    self.build_libraries(self.libraries)
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/site-packages/numpy/distutils/command/build_clib.py", line 103, in build_libraries
    self.build_a_library(build_info, lib_name, libraries)
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/site-packages/numpy/distutils/command/build_clib.py", line 156, in build_a_library
    fcompiler.customize(base_config_fc)
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/site-packages/numpy/distutils/fcompiler/__init__.py", line 449, in customize
    self.find_executables()
  File "/home/pjeremy/sage-3.4/local/lib/python2.5/site-packages/numpy/distutils/fcompiler/__init__.py", line 342, in find_executables
    raise CompilerNotFound('%s: f90 nor f77' % ctype)
numpy.distutils.fcompiler.CompilerNotFound: gnu95: f90 nor f77
}#}}
}}}
{{{#!wiki comment
=== singular-3-0-4-4-20080711.p4 ===
By default, you get the following, which is corrected by the patch to singuname.sh:
{{{
make[2]: Entering directory `/home/pjeremy/sage-3.4/spkg/build/singular-3-0-4-4-20080711.p4/src'
make[2]: *** No rule to make target `distclean'. Stop.
make[2]: Leaving directory `/home/pjeremy/sage-3.4/spkg/build/singular-3-0-4-4-20080711.p4/src'
rm: /home/pjeremy/sage-3.4/local/bin/Singular*: No such file or directory
creating cache ./config.cache
checking uname for singular... unknown
configure: error: Unknown architecture: Check singuname.sh
Unable to configure Singular.
}#}}

Correct configure script for amd64 by patching the autoconf inputs and re-running autoconf. This corrects a problem where linking libsingular.so reports lots of undefined references to both internal `om`* functions and functions within libncurses.

Several other trivial fixes to support dynamic linking on FreeBSD/amd64.

The rationale behind original code to disable `__cplusplus` in cf_gmp.h is unclear. The result using gcc4.3 on FreeBSD is definitely broken as cf_gmp.h includes gmp.h which includes string.h - which results in strcat() and friends being declared without a surrounding `extern "C" {...}` block. This causes the code to linvoke (non-existent) C++ versions of strcat(char *, const char *), rather than the standard C library strcat(). Commenting out this code fixes the problem. The failure looks
like:
{{{
g++ -O3 -g -fPIC -pipe -I. -I../kernel -I/home/pjeremy/sage-3.4/local/include -I/home/pjeremy/sage-3.4/local/include -I/home/pjeremy/sage-3.4/local/include -fno-implicit-templates -DNDEBUG -DOM_NDEBUG -Dx86_64_freebsd -DHAVE_CONFIG_H -DGENTABLE -o gentable claptmpl.o iparith.cc tesths.cc mpsr_Tok.cc grammar.o scanner.o attrib.o eigenval_ip.o extra.o fehelp.o feOpt.o ipassign.o ipconv.o ipid.o iplib.o ipprint.o ipshell.o lists.o sdb.o fglm.o interpolation.o silink.o subexpr.o janet.o wrapper.o libparse.o sing_win.o gms.o pcv.o maps_ip.o walk.o walk_ip.o cntrlc.o misc.o calcSVD.o slInit_Static.o mpsr_Put.o mpsr_PutPoly.o mpsr_GetPoly.o mpsr_sl.o mpsr_Get.o mpsr_GetMisc.o mpsr_Error.o ndbm.o sing_dbm.o -L../kernel -lkernel -L/home/pjeremy/sage-3.4/local/lib -L/home/pjeremy/sage-3.4/local/lib -lm -lsingfac -lsingcf -lntl -lgmp -lreadline -lncurses -lm -lomalloc ../kernel/mmalloc.o
iparith.cc:443: warning: deprecated conversion from string constant to 'char*'
...
iparith.cc:443: warning: deprecated conversion from string constant to 'char*'
mpsr_Tok.cc: In function 'void mpsr_ttGen()':
mpsr_Tok.cc:538: warning: deprecated conversion from string constant to 'char*'
/home/pjeremy/sage-3.4/local/lib/libsingcf.a(NTLconvert.o)(.text+0x2fa5): In function `convertZZ2CF(NTL::ZZ)':
/home/pjeremy/sage-3.4/spkg/build/singular-3-0-4-4-20080711.p4/src/factory/NTLconvert.cc:649: undefined reference to `strcat(char*, char const*)'
/home/pjeremy/sage-3.4/local/lib/libsingcf.a(NTLconvert.o)(.text+0x2fbf):/home/pjeremy/sage-3.4/spkg/build/singular-3-0-4-4-20080711.p4/src/factory/NTLconvert.cc:662: undefined reference to `strlen(char const*)'
collect2: ld returned 1 exit status
make[4]: *** [iparith.inc] Error 1
make[4]: Leaving directory `/home/pjeremy/sage-3.4/spkg/build/singular-3-0-4-4-20080711.p4/src/Singular'
}#}}
}}}
{{{#!wiki comment
=== tachyon-0.98beta.p8 ===
tachyon does include BSD support (though the code advises that it hasn't been tested for a while). Looking though the source code, there's no obvious bitrot so add FreeBSD support to the spkg-install script. As noted, I haven't added support for either threaded or 64-bit tachyon. The former shouldn't be too difficult to add and the MacOS-X port implies it is optional. The 64-bit support is solely an optimisation - a test to detect wrap-around of `long` integers is removed since wrap-around isn't possible with 64-bit longs.

Sage local patch: [[http://trac.sagemath.org/sage_trac/ticket/5875|#5875]]
}}}