2018-08-03 14:03:55 +01:00
|
|
|
{ stdenv, fetchFromGitHub, gmp, bison, perl, ncurses, readline, coreutils, pkg-config
|
2018-07-20 16:01:23 +01:00
|
|
|
, lib
|
2018-07-25 17:58:57 +01:00
|
|
|
, fetchpatch
|
2021-04-21 17:34:32 +01:00
|
|
|
, autoreconfHook
|
2018-08-03 14:03:55 +01:00
|
|
|
, sharutils
|
2018-04-23 15:28:25 +01:00
|
|
|
, file
|
2018-04-11 12:52:10 +01:00
|
|
|
, flint
|
|
|
|
, ntl
|
|
|
|
, cddlib
|
2018-08-03 14:03:55 +01:00
|
|
|
, gfan
|
|
|
|
, lrcalc
|
|
|
|
, doxygen
|
|
|
|
, graphviz
|
|
|
|
# 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
|
2018-04-11 12:52:10 +01:00
|
|
|
, enableGfanlib ? true
|
2016-10-12 19:22:52 +01:00
|
|
|
}:
|
2010-12-05 18:37:47 +00:00
|
|
|
|
2015-06-25 21:46:54 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "singular";
|
2018-08-03 14:03:55 +01:00
|
|
|
version = "4.2.0p2";
|
|
|
|
|
|
|
|
# since the tarball does not contain tests or documentation (and
|
|
|
|
# there is no separate tests tarball for 4.2.0), we fetch from
|
|
|
|
# GitHub.
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Singular";
|
|
|
|
repo = "Singular";
|
|
|
|
|
2021-05-05 13:03:42 +01:00
|
|
|
# 4.2.0p2 is not tagged, but the tarball matches the commit below.
|
|
|
|
rev = "6f68939ddf612d96e3caaaaa8275f77613ac1da8";
|
|
|
|
sha256 = "sha256-BJNzYylzDqD/5YjzjxPRb/c96tYiuGy9Y+A7qf3ZSG8=";
|
2018-08-03 14:03:55 +01:00
|
|
|
|
|
|
|
# if a release is tagged it will be in the format below.
|
|
|
|
# rev = "Release${lib.replaceStrings ["."] ["-"] version}";
|
|
|
|
|
|
|
|
# the repository's .gitattributes file contains the lines "/Tst/
|
|
|
|
# export-ignore" and "/doc/ export-ignore" so some directories are
|
|
|
|
# not included in the tarball downloaded by fetchzip. setting
|
|
|
|
# fetchSubmodules works around this by using fetchgit instead of
|
|
|
|
# fetchzip.
|
|
|
|
fetchSubmodules = true;
|
2010-12-05 18:37:47 +00:00
|
|
|
};
|
|
|
|
|
2021-04-21 17:34:32 +01:00
|
|
|
patches = [
|
|
|
|
# add aarch64 support to cpu-check.m4. copied from redhat.
|
|
|
|
./redhat-aarch64.patch
|
2021-04-22 00:05:48 +01:00
|
|
|
|
2021-04-22 03:53:20 +01:00
|
|
|
# vspace causes hangs in modstd and other libraries on aarch64
|
|
|
|
./disable-vspace-on-aarch64.patch
|
|
|
|
|
2021-04-22 00:05:48 +01:00
|
|
|
# the newest version of ax-prog-cc-for-build.m4 seems to trigger
|
|
|
|
# linker errors. see
|
|
|
|
# https://github.com/alsa-project/alsa-firmware/issues/3 for a
|
|
|
|
# related issue.
|
|
|
|
./use-older-ax-prog-cc-for-build.patch
|
2021-05-05 13:03:42 +01:00
|
|
|
|
|
|
|
# https://github.com/Singular/Singular/issues/1086
|
|
|
|
(fetchpatch {
|
|
|
|
name = "schubert-lib-fails-with-too-many-cpus.patch";
|
|
|
|
url = "https://github.com/Singular/Singular/commit/3cda50c00a849455efa2502e56596955491a353a.patch";
|
|
|
|
sha256 = "sha256-fgYd+2vT32w5Ki8kKx6PfZn2e4QSJcYWOwEFXtc+lSA=";
|
|
|
|
})
|
2021-04-21 17:34:32 +01:00
|
|
|
] ++ lib.optionals enableDocs [
|
2018-08-03 14:03:55 +01:00
|
|
|
# singular supports building without 4ti2, bertini, normaliz or
|
|
|
|
# topcom just fine, but the docbuilding does not skip manual pages
|
|
|
|
# tagged as depending on those binaries (probably a bug in
|
|
|
|
# doc2tex.pl::HandleLib, since it seems to ignore "-exclude"
|
|
|
|
# argumens). skip them manually.
|
|
|
|
./disable-docs-for-optional-unpackaged-deps.patch
|
2021-05-05 13:03:42 +01:00
|
|
|
|
|
|
|
# fix some non-ascii characters in doc/decodegb.doc
|
|
|
|
(fetchpatch {
|
|
|
|
name = "decodegb-ascii.patch";
|
|
|
|
url = "https://github.com/Singular/Singular/commit/36966d9009de572ee4dbc487f3e5744098fe91be.patch";
|
|
|
|
sha256 = "sha256-9WcEov/oOQRC584ag6WVHFwY2aCjbM75HWyvZoEwppw=";
|
|
|
|
})
|
2018-08-03 14:03:55 +01:00
|
|
|
];
|
|
|
|
|
2018-04-23 15:28:25 +01:00
|
|
|
configureFlags = [
|
|
|
|
"--with-ntl=${ntl}"
|
2018-08-03 14:03:55 +01:00
|
|
|
"--disable-pyobject-module"
|
|
|
|
] ++ lib.optionals enableDocs [
|
|
|
|
"--enable-doc-build"
|
2018-07-20 16:01:23 +01:00
|
|
|
] ++ lib.optionals enableGfanlib [
|
2018-04-11 12:52:10 +01:00
|
|
|
"--enable-gfanlib"
|
|
|
|
];
|
|
|
|
|
2018-08-03 14:03:55 +01:00
|
|
|
prePatch = ''
|
|
|
|
# don't let the tests depend on `hostname`
|
|
|
|
substituteInPlace Tst/regress.cmd --replace 'mysystem_catch("hostname")' 'nix_test_runner'
|
|
|
|
|
2018-04-11 12:52:10 +01:00
|
|
|
patchShebangs .
|
|
|
|
'';
|
|
|
|
|
|
|
|
# For reference (last checked on commit 75f460d):
|
2018-08-03 14:03:55 +01: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
|
2018-04-11 12:52:10 +01:00
|
|
|
buildInputs = [
|
|
|
|
# necessary
|
|
|
|
gmp
|
|
|
|
# by upstream recommended but optional
|
|
|
|
ncurses
|
|
|
|
readline
|
|
|
|
ntl
|
|
|
|
flint
|
2018-08-03 14:03:55 +01:00
|
|
|
lrcalc
|
|
|
|
gfan
|
2018-07-20 16:01:23 +01:00
|
|
|
] ++ lib.optionals enableGfanlib [
|
2018-04-11 12:52:10 +01:00
|
|
|
cddlib
|
|
|
|
];
|
2018-04-23 15:28:25 +01:00
|
|
|
nativeBuildInputs = [
|
|
|
|
bison
|
|
|
|
perl
|
2021-01-19 06:50:56 +00:00
|
|
|
pkg-config
|
2021-04-21 17:34:32 +01:00
|
|
|
autoreconfHook
|
2018-08-03 14:03:55 +01:00
|
|
|
sharutils # needed for regress.cmd install checks
|
|
|
|
] ++ lib.optionals enableDocs [
|
|
|
|
doxygen
|
|
|
|
graphviz
|
|
|
|
texinfo4
|
|
|
|
texlive.combined.scheme-small
|
2018-04-23 15:28:25 +01:00
|
|
|
];
|
2015-06-25 21:46:54 +01:00
|
|
|
|
2018-04-23 15:28:25 +01: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 '{}' ';'
|
2015-06-25 21:46:54 +01:00
|
|
|
'';
|
2010-12-05 18:37:47 +00:00
|
|
|
|
2018-07-20 16:01:23 +01:00
|
|
|
hardeningDisable = lib.optional stdenv.isi686 "stackprotector";
|
2016-04-03 13:25:05 +01:00
|
|
|
|
2016-10-12 19:22:52 +01:00
|
|
|
# The Makefile actually defaults to `make install` anyway
|
2018-07-20 16:01:23 +01:00
|
|
|
buildPhase = ''
|
|
|
|
# do nothing
|
|
|
|
'';
|
2016-10-12 19:22:52 +01:00
|
|
|
|
2018-08-03 14:03:55 +01:00
|
|
|
doCheck = true; # very basic checks, does not test any libraries
|
|
|
|
|
2016-10-12 19:22:52 +01:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out"
|
2018-04-11 12:52:10 +01:00
|
|
|
cp -r Singular/LIB "$out/lib"
|
|
|
|
make install
|
2018-08-03 14:03:55 +01:00
|
|
|
'' + lib.optionalString enableDocs ''
|
|
|
|
# Sage uses singular.hlp (which is not in the tarball)
|
|
|
|
mkdir -p $out/share/info
|
|
|
|
cp doc/singular.hlp $out/share/info
|
|
|
|
'' + ''
|
2018-04-11 12:52:10 +01:00
|
|
|
# Make sure patchelf picks up the right libraries
|
|
|
|
rm -rf libpolys factory resources omalloc Singular
|
|
|
|
'';
|
|
|
|
|
2018-08-03 14:03:55 +01:00
|
|
|
# singular tests are a bit complicated, see
|
|
|
|
# https://github.com/Singular/Singular/tree/spielwiese/Tst
|
2021-05-05 13:03:42 +01:00
|
|
|
# https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2773
|
2018-08-03 14:03:55 +01: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"
|
|
|
|
];
|
|
|
|
|
2018-04-11 12:52:10 +01:00
|
|
|
# simple test to make sure singular starts and finds its libraries
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
2018-08-03 14:03:55 +01: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.
|
2018-07-20 16:01:23 +01:00
|
|
|
"$out/bin/Singular" -c 'LIB "freegb.lib"; exit;'
|
2018-04-11 12:52:10 +01:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo >&2 "Error loading the freegb library in Singular."
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-08-03 14:03:55 +01: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-05 13:03:42 +01:00
|
|
|
# https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2773
|
2018-08-03 14:03:55 +01:00
|
|
|
if [[ -s "$TMPDIR/out-err.log" ]]; then
|
|
|
|
cat "$TMPDIR/out-err.log"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Exit status $?"
|
2015-06-25 21:46:54 +01:00
|
|
|
'';
|
2014-07-28 10:43:20 +01:00
|
|
|
|
2017-05-20 14:38:01 +01:00
|
|
|
enableParallelBuilding = true;
|
2016-10-12 19:22:52 +01:00
|
|
|
|
2018-07-20 16:01:23 +01:00
|
|
|
meta = with lib; {
|
2010-12-05 18:37:47 +00:00
|
|
|
description = "A CAS for polynomial computations";
|
2020-11-18 20:29:24 +00:00
|
|
|
maintainers = teams.sage.members;
|
2018-07-20 16:01:23 +01:00
|
|
|
# 32 bit x86 fails with some link error: `undefined reference to `__divmoddi4@GCC_7.0.0'`
|
2018-08-03 14:03:55 +01:00
|
|
|
# https://www.singular.uni-kl.de:8002/trac/ticket/837
|
2019-09-15 09:48:07 +01:00
|
|
|
platforms = subtractLists platforms.i686 platforms.unix;
|
2015-06-25 21:46:54 +01:00
|
|
|
license = licenses.gpl3; # Or GPLv2 at your option - but not GPLv4
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "http://www.singular.uni-kl.de";
|
2016-10-12 16:34:29 +01:00
|
|
|
downloadPage = "http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/";
|
2010-12-05 18:37:47 +00:00
|
|
|
};
|
2015-06-25 21:46:54 +01:00
|
|
|
}
|