2021-04-26 19:14:03 +00:00
|
|
|
{ stdenv, fetchFromGitHub, gmp, bison, perl, ncurses, readline, coreutils, pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
, lib
|
|
|
|
, autoreconfHook
|
2022-02-10 20:34:41 +00:00
|
|
|
, buildPackages
|
2021-04-26 19:14:03 +00:00
|
|
|
, sharutils
|
2020-04-24 23:36:52 +00:00
|
|
|
, file
|
|
|
|
, flint
|
|
|
|
, ntl
|
|
|
|
, cddlib
|
2021-04-26 19:14:03 +00:00
|
|
|
, gfan
|
|
|
|
, lrcalc
|
|
|
|
, doxygen
|
|
|
|
, graphviz
|
2022-02-10 20:34:41 +00:00
|
|
|
, latex2html
|
2021-04-26 19:14:03 +00:00
|
|
|
# upstream generates docs with texinfo 4. later versions of texinfo
|
|
|
|
# use letters instead of numbers for post-appendix chapters, and we
|
|
|
|
# want it to match the upstream format because sage depends on it.
|
|
|
|
, texinfo4
|
|
|
|
, texlive
|
|
|
|
, enableDocs ? true
|
2020-04-24 23:36:52 +00:00
|
|
|
, enableGfanlib ? true
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "singular";
|
2022-02-10 20:34:41 +00:00
|
|
|
version = "4.3.0";
|
2021-04-26 19:14:03 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
# since the tarball does not contain tests, we fetch from GitHub.
|
2021-04-26 19:14:03 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Singular";
|
|
|
|
repo = "Singular";
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
# if a release is tagged (which sometimes does not happen), it will
|
|
|
|
# be in the format below.
|
|
|
|
# rev = "Release-${lib.replaceStrings ["."] ["-"] version}";
|
|
|
|
rev = "d895b0f1f543c61eb03adddad20f08655a419d4e";
|
|
|
|
sha256 = "sha256-c5Qr6VUuPKjfw8fowjJJz3oGAyUwo/K0WeMvU5djzVA=";
|
2021-04-26 19:14:03 +00:00
|
|
|
|
|
|
|
# the repository's .gitattributes file contains the lines "/Tst/
|
|
|
|
# export-ignore" and "/doc/ export-ignore" so some directories are
|
2022-02-10 20:34:41 +00:00
|
|
|
# not included in the tarball downloaded by fetchzip.
|
|
|
|
forceFetchGit = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--with-ntl=${ntl}"
|
2021-04-26 19:14:03 +00:00
|
|
|
"--disable-pyobject-module"
|
|
|
|
] ++ lib.optionals enableDocs [
|
|
|
|
"--enable-doc-build"
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ lib.optionals enableGfanlib [
|
|
|
|
"--enable-gfanlib"
|
|
|
|
];
|
|
|
|
|
2021-04-26 19:14:03 +00:00
|
|
|
prePatch = ''
|
|
|
|
# don't let the tests depend on `hostname`
|
|
|
|
substituteInPlace Tst/regress.cmd --replace 'mysystem_catch("hostname")' 'nix_test_runner'
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
patchShebangs .
|
|
|
|
'';
|
|
|
|
|
|
|
|
# For reference (last checked on commit 75f460d):
|
2021-04-26 19:14:03 +00:00
|
|
|
# https://github.com/Singular/Singular/blob/spielwiese/doc/Building-Singular-from-source.md
|
|
|
|
# https://github.com/Singular/Singular/blob/spielwiese/doc/external-packages-dynamic-modules.md
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs = [
|
|
|
|
# necessary
|
|
|
|
gmp
|
|
|
|
# by upstream recommended but optional
|
|
|
|
ncurses
|
|
|
|
readline
|
|
|
|
ntl
|
|
|
|
flint
|
2021-04-26 19:14:03 +00:00
|
|
|
lrcalc
|
|
|
|
gfan
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ lib.optionals enableGfanlib [
|
|
|
|
cddlib
|
|
|
|
];
|
2022-02-10 20:34:41 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
bison
|
|
|
|
perl
|
2021-02-05 17:12:51 +00:00
|
|
|
pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
autoreconfHook
|
2021-04-26 19:14:03 +00:00
|
|
|
sharutils # needed for regress.cmd install checks
|
|
|
|
] ++ lib.optionals enableDocs [
|
|
|
|
doxygen
|
|
|
|
graphviz
|
2022-02-10 20:34:41 +00:00
|
|
|
latex2html
|
2021-04-26 19:14:03 +00:00
|
|
|
texinfo4
|
|
|
|
texlive.combined.scheme-small
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
2022-02-10 20:34:41 +00:00
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
preAutoreconf = ''
|
|
|
|
find . -type f -readable -writable -exec sed \
|
|
|
|
-e 's@/bin/rm@${coreutils}&@g' \
|
|
|
|
-e 's@/bin/uname@${coreutils}&@g' \
|
|
|
|
-e 's@/usr/bin/file@${file}/bin/file@g' \
|
|
|
|
-i '{}' ';'
|
|
|
|
'';
|
|
|
|
|
|
|
|
hardeningDisable = lib.optional stdenv.isi686 "stackprotector";
|
|
|
|
|
2021-04-26 19:14:03 +00:00
|
|
|
doCheck = true; # very basic checks, does not test any libraries
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = ''
|
|
|
|
make install
|
2021-04-26 19:14:03 +00:00
|
|
|
'' + lib.optionalString enableDocs ''
|
2022-02-10 20:34:41 +00:00
|
|
|
# Sage uses singular.info, which is not installed by default
|
2021-04-26 19:14:03 +00:00
|
|
|
mkdir -p $out/share/info
|
2022-02-10 20:34:41 +00:00
|
|
|
cp doc/singular.info $out/share/info
|
2021-04-26 19:14:03 +00:00
|
|
|
'' + ''
|
2020-04-24 23:36:52 +00:00
|
|
|
# Make sure patchelf picks up the right libraries
|
|
|
|
rm -rf libpolys factory resources omalloc Singular
|
|
|
|
'';
|
|
|
|
|
2021-04-26 19:14:03 +00:00
|
|
|
# singular tests are a bit complicated, see
|
|
|
|
# https://github.com/Singular/Singular/tree/spielwiese/Tst
|
2021-05-20 23:08:51 +00:00
|
|
|
# https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2773
|
2021-04-26 19:14:03 +00:00
|
|
|
testsToRun = [
|
|
|
|
"Old/universal.lst"
|
|
|
|
"Buch/buch.lst"
|
|
|
|
"Plural/short.lst"
|
|
|
|
"Old/factor.tst"
|
|
|
|
] ++ lib.optionals enableGfanlib [
|
|
|
|
# tests that require gfanlib
|
|
|
|
"Short/ok_s.lst"
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# simple test to make sure singular starts and finds its libraries
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
2021-04-26 19:14:03 +00:00
|
|
|
# Very basic sanity check to make sure singular starts and finds its libraries.
|
|
|
|
# This is redundant with the below tests. It is only kept because the singular test
|
|
|
|
# runner is a bit complicated. In case we decide to give up those tests in the future,
|
|
|
|
# this will still be useful. It takes barely any time.
|
2020-04-24 23:36:52 +00:00
|
|
|
"$out/bin/Singular" -c 'LIB "freegb.lib"; exit;'
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo >&2 "Error loading the freegb library in Singular."
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-04-26 19:14:03 +00:00
|
|
|
|
|
|
|
# Run the test suite
|
|
|
|
cd Tst
|
|
|
|
perl ./regress.cmd \
|
|
|
|
-s "$out/bin/Singular" \
|
|
|
|
${lib.concatStringsSep " " (map lib.escapeShellArg testsToRun)} \
|
|
|
|
2>"$TMPDIR/out-err.log"
|
|
|
|
|
|
|
|
# unfortunately regress.cmd always returns exit code 0, so check stderr
|
2021-05-20 23:08:51 +00:00
|
|
|
# https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2773
|
2021-04-26 19:14:03 +00:00
|
|
|
if [[ -s "$TMPDIR/out-err.log" ]]; then
|
|
|
|
cat "$TMPDIR/out-err.log"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Exit status $?"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A CAS for polynomial computations";
|
2020-11-21 19:51:51 +00:00
|
|
|
maintainers = teams.sage.members;
|
2020-04-24 23:36:52 +00:00
|
|
|
# 32 bit x86 fails with some link error: `undefined reference to `__divmoddi4@GCC_7.0.0'`
|
2021-04-26 19:14:03 +00:00
|
|
|
# https://www.singular.uni-kl.de:8002/trac/ticket/837
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = subtractLists platforms.i686 platforms.unix;
|
|
|
|
license = licenses.gpl3; # Or GPLv2 at your option - but not GPLv4
|
|
|
|
homepage = "http://www.singular.uni-kl.de";
|
|
|
|
downloadPage = "http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/";
|
2022-02-10 20:34:41 +00:00
|
|
|
mainProgram = "Singular";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|