2023-11-16 04:20:00 +00:00
|
|
|
{ stdenv, lib, fetchurl, fetchpatch, texliveSmall, bison, flex, lapack, blas
|
2022-04-27 09:35:20 +00:00
|
|
|
, autoreconfHook, gmp, mpfr, pari, ntl, gsl, mpfi, ecm, glpk, nauty
|
|
|
|
, buildPackages, readline, gettext, libpng, libao, gfortran, perl
|
2021-03-09 03:18:52 +00:00
|
|
|
, enableGUI ? false, libGL, libGLU, xorg, fltk
|
2021-03-12 07:09:13 +00:00
|
|
|
, enableMicroPy ? false, python3
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert (!blas.isILP64) && (!lapack.isILP64);
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "giac${lib.optionalString enableGUI "-with-xcas"}";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "1.9.0-993"; # TODO try to remove preCheck phase on upgrade
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version}.tar.gz";
|
2024-09-19 14:19:46 +00:00
|
|
|
sha256 = "sha256-pqytFWrSWfEwQqRdRbaigGCq68s8mdgj2j8M+kclslE=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-03-12 07:09:13 +00:00
|
|
|
patches = [
|
2024-09-19 14:19:46 +00:00
|
|
|
./remove-old-functional-patterns.patch
|
|
|
|
./fix-fltk-guard.patch
|
|
|
|
|
|
|
|
(fetchpatch {
|
|
|
|
name = "pari_2_15.patch";
|
|
|
|
url = "https://raw.githubusercontent.com/sagemath/sage/07a2afd65fb4b0a1c9cbc43ede7d4a18c921a000/build/pkgs/giac/patches/pari_2_15.patch";
|
|
|
|
sha256 = "sha256-Q3xBFED7XEAyNz6AHjzt63XtospmdGAIdS6iPq1C2UE=";
|
|
|
|
})
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
(fetchpatch {
|
2024-09-19 14:19:46 +00:00
|
|
|
name = "infinity.patch";
|
|
|
|
url = "https://github.com/geogebra/giac/commit/851c2cd91e879c79d6652f8a5d5bed03b65c6d39.patch";
|
|
|
|
sha256 = "sha256-WJRT2b8I9kgAkRuIugMiXoF4hT7yR7qyad8A6IspNTM=";
|
|
|
|
stripLen = 5;
|
|
|
|
extraPrefix = "/src/";
|
|
|
|
excludes = [ "src/kdisplay.cc" ];
|
2021-03-12 07:09:13 +00:00
|
|
|
})
|
2022-11-27 09:42:12 +00:00
|
|
|
|
|
|
|
# giac calls scanf/printf with non-constant first arguments, which
|
|
|
|
# the compiler rightfully warns about (with an error nowadays).
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-string-compiler-error.patch";
|
2023-05-24 13:37:59 +00:00
|
|
|
url = "https://salsa.debian.org/science-team/giac/-/raw/9ca8dbf4bb16d9d96948aa4024326d32485d7917/debian/patches/fix-string-compiler-error.patch";
|
|
|
|
sha256 = "sha256-r+M+9MRPRqhHcdhYWI6inxyNvWbXUbBcPCeDY7aulvk=";
|
2022-11-27 09:42:12 +00:00
|
|
|
})
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
# issue with include path precedence
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix_implicit_declaration.patch";
|
|
|
|
url = "https://salsa.debian.org/science-team/giac/-/raw/c05ae9b9e74d3c6ee6411d391071989426a76201/debian/patches/fix_implicit_declaration.patch";
|
|
|
|
sha256 = "sha256-ompUceYJLiL0ftfjBkIMcYvX1YqG2/XA7e1yDyFY0IY=";
|
|
|
|
})
|
2021-03-12 07:09:13 +00:00
|
|
|
] ++ 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 {
|
|
|
|
name = "nofltk-check.patch";
|
2023-10-09 19:29:22 +00:00
|
|
|
url = "https://raw.githubusercontent.com/sagemath/sage/7553a3c8dfa7bcec07241a07e6a4e7dcf5bb4f26/build/pkgs/giac/patches/nofltk-check.patch";
|
2022-11-27 09:42:12 +00:00
|
|
|
sha256 = "sha256-nAl5q3ufLjK3X9s0qMlGNowdRRf3EaC24eVtJABzdXY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
# 1.9.0-5's tarball contains a binary (src/mkjs) which is executed
|
|
|
|
# at build time. we will delete and rebuild it.
|
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postPatch = ''
|
2021-03-12 07:09:13 +00:00
|
|
|
for i in doc/*/Makefile* micropython*/xcas/Makefile*; do
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace "$i" --replace "/bin/cp" "cp";
|
|
|
|
done;
|
2022-04-27 09:35:20 +00:00
|
|
|
rm src/mkjs
|
|
|
|
substituteInPlace src/Makefile.am --replace "g++ mkjs.cc" \
|
|
|
|
"${buildPackages.stdenv.cc.targetPrefix}c++ mkjs.cc"
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
# to open help
|
|
|
|
substituteInPlace src/global.cc --replace 'browser="mozilla"' 'browser="xdg-open"'
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2023-11-16 04:20:00 +00:00
|
|
|
autoreconfHook texliveSmall bison flex
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# perl is only needed for patchShebangs fixup.
|
|
|
|
buildInputs = [
|
|
|
|
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
|
2021-01-17 00:15:33 +00:00
|
|
|
(lib.getLib gfortran.cc)
|
2020-04-24 23:36:52 +00:00
|
|
|
lapack blas
|
2021-01-17 00:15:33 +00:00
|
|
|
] ++ lib.optionals enableGUI [
|
2020-04-24 23:36:52 +00:00
|
|
|
libGL libGLU fltk xorg.libX11
|
2021-03-12 07:09:13 +00:00
|
|
|
] ++ lib.optional enableMicroPy python3;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# xcas Phys and Turtle menus are broken with split outputs
|
|
|
|
# and interactive use is likely to need docs
|
2021-01-17 00:15:33 +00:00
|
|
|
outputs = [ "out" ] ++ lib.optional (!enableGUI) "doc";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
doCheck = true;
|
2021-03-12 07:09:13 +00:00
|
|
|
preCheck = lib.optionalString (!enableGUI) ''
|
|
|
|
# even with the nofltk patch, some changes in src/misc.cc (grep
|
|
|
|
# for HAVE_LIBFLTK) made it so that giac behaves differently
|
|
|
|
# when fltk is disabled. disable these tests for now.
|
|
|
|
echo > check/chk_fhan2
|
|
|
|
echo > check/chk_fhan9
|
2024-09-26 11:04:55 +00:00
|
|
|
'' + lib.optionalString (stdenv.hostPlatform.isDarwin) ''
|
2024-09-19 14:19:46 +00:00
|
|
|
# these cover a known regression in giac, likely due to how pari state
|
|
|
|
# is shared between multiple giac instances (see pari.cc.old).
|
|
|
|
# see https://github.com/NixOS/nixpkgs/pull/264126 for more information
|
|
|
|
echo > check/chk_fhan4
|
|
|
|
echo > check/chk_fhan6
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--enable-gc" "--enable-png" "--enable-gsl" "--enable-lapack"
|
|
|
|
"--enable-pari" "--enable-ntl" "--enable-gmpxx" # "--enable-cocoa"
|
|
|
|
"--enable-ao" "--enable-ecm" "--enable-glpk"
|
2021-01-17 00:15:33 +00:00
|
|
|
] ++ lib.optionals enableGUI [
|
2020-04-24 23:36:52 +00:00
|
|
|
"--enable-gui" "--with-x"
|
2024-09-26 11:04:55 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
2024-09-19 14:19:46 +00:00
|
|
|
"--disable-nls"
|
2022-11-27 09:42:12 +00:00
|
|
|
] ++ lib.optionals (!enableGUI) [
|
|
|
|
"--disable-fltk"
|
|
|
|
] ++ lib.optionals (!enableMicroPy) [
|
|
|
|
"--disable-micropy"
|
|
|
|
];
|
2020-04-24 23:36:52 +00: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
|
2023-03-27 19:17:25 +00:00
|
|
|
sed -i "s@${builtins.storeDir}/[^/]*/bin/@@" "$file" ;
|
2020-04-24 23:36:52 +00:00
|
|
|
done;
|
|
|
|
|
|
|
|
# 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
|
2021-01-17 00:15:33 +00:00
|
|
|
'' + lib.optionalString (!enableGUI) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
for i in pixmaps application-registry applications icons; do
|
|
|
|
rm -r "$out/share/$i";
|
|
|
|
done;
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Free computer algebra system (CAS)";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://www-fourier.ujf-grenoble.fr/~parisse/giac.html";
|
|
|
|
license = licenses.gpl3Plus;
|
|
|
|
platforms = platforms.linux ++ (optionals (!enableGUI) platforms.darwin);
|
|
|
|
maintainers = [ maintainers.symphorien ];
|
|
|
|
};
|
|
|
|
}
|