nixpkgs/pkgs/applications/science/math/giac/default.nix

111 lines
4.0 KiB
Nix
Raw Normal View History

{ stdenv, lib, fetchurl, fetchpatch, texlive, bison, flex, lapack, blas
, gmp, mpfr, pari, ntl, gsl, mpfi, ecm, glpk, nauty
2017-09-30 14:34:11 +01:00
, readline, gettext, libpng, libao, gfortran, perl
2019-11-10 16:44:34 +00:00
, enableGUI ? false, libGL ? null, libGLU ? null, xorg ? null, fltk ? null
2017-09-30 10:33:14 +01:00
}:
2019-11-10 16:44:34 +00:00
assert enableGUI -> libGLU != null && libGL != null && xorg != null && fltk != null;
assert (!blas.isILP64) && (!lapack.isILP64);
2017-09-30 10:33:14 +01:00
stdenv.mkDerivation rec {
pname = "giac${lib.optionalString enableGUI "-with-xcas"}";
2020-11-30 13:02:20 +00:00
version = "1.5.0-87"; # TODO try to remove preCheck phase on upgrade
2017-09-30 10:33:14 +01:00
src = fetchurl {
url = "https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version}.tar.gz";
2020-11-30 13:02:20 +00:00
sha256 = "1d0h1yb7qvh9x7wwv9yrzmcp712f49w1iljkxp4y6g9pzsmg1mmv";
2017-09-30 10:33:14 +01:00
};
2018-04-11 20:14:16 +01:00
patches = stdenv.lib.optionals (!enableGUI) [
# when enableGui is false, giac is compiled without fltk. That means some
# outputs differ in the make check. Patch around this:
(fetchpatch {
url = "https://git.sagemath.org/sage.git/plain/build/pkgs/giac/patches/nofltk-check.patch?id=7553a3c8dfa7bcec07241a07e6a4e7dcf5bb4f26";
sha256 = "0xkmfc028vg5w6va04gp2x2iv31n8v4shd6vbyvk4blzgfmpj2cw";
})
];
2017-09-30 14:34:11 +01:00
postPatch = ''
for i in doc/*/Makefile*; do
2017-09-30 10:33:14 +01:00
substituteInPlace "$i" --replace "/bin/cp" "cp";
done;
2017-09-30 14:34:11 +01:00
'';
2017-09-30 10:33:14 +01:00
nativeBuildInputs = [
2017-09-30 14:34:11 +01:00
texlive.combined.scheme-small bison flex
2017-09-30 10:33:14 +01:00
];
2017-09-30 14:34:11 +01:00
# perl is only needed for patchShebangs fixup.
2017-09-30 10:33:14 +01:00
buildInputs = [
2018-12-08 20:58:57 +00:00
gmp mpfr pari ntl gsl blas mpfi glpk nauty
readline gettext libpng libao perl ecm
# gfortran.cc default output contains static libraries compiled without -fPIC
# we want libgfortran.so.3 instead
(stdenv.lib.getLib gfortran.cc)
lapack blas
2017-09-30 14:34:11 +01:00
] ++ stdenv.lib.optionals enableGUI [
2019-11-10 16:44:34 +00:00
libGL libGLU fltk xorg.libX11
2017-09-30 10:33:14 +01:00
];
/* fixes:
configure:16211: checking for main in -lntl
configure:16230: g++ -o conftest -g -O2 conftest.cpp -lntl -llapack -lblas -lgfortran -ldl -lpng16 -lm -lmpfi -lmpfr -lgmp >&5
/nix/store/y9c1v4x7y39j2rfbg17agjwqdzxpsn18-ntl-11.3.2/lib/libntl.so: undefined reference to `pthread_key_create'
*/
NIX_CFLAGS_LINK="-lpthread";
# xcas Phys and Turtle menus are broken with split outputs
# and interactive use is likely to need docs
outputs = [ "out" ] ++ stdenv.lib.optional (!enableGUI) "doc";
2018-04-11 20:14:16 +01:00
doCheck = true;
preCheck = ''
# One test in this file fails. That test just tests a part of the pari
# interface that isn't actually used in giac. Of course it would be better
# to only remove that one test, but that would require a patch.
# Removing the whole test set should be good enough for now.
# Upstream report: https://xcas.univ-grenoble-alpes.fr/forum/viewtopic.php?f=4&t=2102#p10326
echo > check/chk_fhan11
'';
2017-09-30 14:34:11 +01:00
2017-09-30 10:33:14 +01:00
enableParallelBuilding = true;
configureFlags = [
2017-09-30 14:34:11 +01:00
"--enable-gc" "--enable-png" "--enable-gsl" "--enable-lapack"
"--enable-pari" "--enable-ntl" "--enable-gmpxx" # "--enable-cocoa"
"--enable-ao" "--enable-ecm" "--enable-glpk"
2017-09-30 14:34:11 +01:00
] ++ stdenv.lib.optionals enableGUI [
"--enable-gui" "--with-x"
];
2017-09-30 10:33:14 +01:00
postInstall = ''
# example Makefiles contain the full path to some commands
# notably texlive, and we don't want texlive to become a runtime
# dependency
for file in $(find $out -name Makefile) ; do
sed -i "s@/nix/store/[^/]*/bin/@@" "$file" ;
done;
2018-04-11 20:14:16 +01:00
# reference cycle
rm "$out/share/giac/doc/el/"{casinter,tutoriel}/Makefile
if [ -n "$doc" ]; then
mkdir -p "$doc/share/giac"
mv "$out/share/giac/doc" "$doc/share/giac"
mv "$out/share/giac/examples" "$doc/share/giac"
fi
'' + stdenv.lib.optionalString (!enableGUI) ''
for i in pixmaps application-registry applications icons; do
rm -r "$out/share/$i";
done;
2017-09-30 10:33:14 +01:00
'';
meta = with stdenv.lib; {
description = "A free computer algebra system (CAS)";
homepage = "https://www-fourier.ujf-grenoble.fr/~parisse/giac.html";
license = licenses.gpl3Plus;
platforms = platforms.linux ++ (optionals (!enableGUI) platforms.darwin);
2017-09-30 20:40:50 +01:00
maintainers = [ maintainers.symphorien ];
2017-09-30 10:33:14 +01:00
};
}