2018-07-21 01:44:44 +01:00
|
|
|
{ stdenv, fetchurl, gmp, bison, perl, ncurses, readline, coreutils, pkgconfig
|
2018-07-20 16:01:23 +01:00
|
|
|
, lib
|
2018-07-25 17:58:57 +01:00
|
|
|
, fetchpatch
|
2018-04-11 12:52:10 +01:00
|
|
|
, autoreconfHook
|
2018-04-23 15:28:25 +01:00
|
|
|
, file
|
2018-04-11 12:52:10 +01:00
|
|
|
, flint
|
|
|
|
, ntl
|
|
|
|
, cddlib
|
|
|
|
, enableFactory ? true
|
|
|
|
, 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-07-20 16:01:23 +01:00
|
|
|
version = "4.1.1p2";
|
2015-06-25 21:46:54 +01:00
|
|
|
|
2018-07-20 16:01:23 +01:00
|
|
|
src = let
|
|
|
|
# singular sorts its tarballs in directories by base release (without patch version)
|
|
|
|
# for example 4.1.1p1 will be in the directory 4-1-1
|
|
|
|
baseVersion = builtins.head (lib.splitString "p" version);
|
|
|
|
urlVersion = builtins.replaceStrings [ "." ] [ "-" ] baseVersion;
|
|
|
|
in
|
|
|
|
fetchurl {
|
|
|
|
url = "http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${urlVersion}/singular-${version}.tar.gz";
|
|
|
|
sha256 = "07x9kri8vl4galik7lr6pscq3c51n8570pyw64i7gbj0m706f7wf";
|
2010-12-05 18:37:47 +00:00
|
|
|
};
|
|
|
|
|
2018-04-23 15:28:25 +01:00
|
|
|
configureFlags = [
|
|
|
|
"--with-ntl=${ntl}"
|
2018-07-20 16:01:23 +01:00
|
|
|
] ++ lib.optionals enableFactory [
|
2018-04-11 12:52:10 +01:00
|
|
|
"--enable-factory"
|
2018-07-20 16:01:23 +01:00
|
|
|
] ++ lib.optionals enableGfanlib [
|
2018-04-11 12:52:10 +01:00
|
|
|
"--enable-gfanlib"
|
|
|
|
];
|
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
|
|
|
|
2018-07-25 17:58:57 +01:00
|
|
|
patches = [
|
|
|
|
# NTL error handler was introduced in the library part, preventing users of
|
|
|
|
# the library from implementing their own error handling
|
|
|
|
# https://www.singular.uni-kl.de/forum/viewtopic.php?t=2769
|
|
|
|
(fetchpatch {
|
|
|
|
name = "move_error_handler_out_of_libsingular.patch";
|
|
|
|
# rebased version of https://github.com/Singular/Sources/commit/502cf86d0bb2a96715be6764774b64a69c1ca34c.patch
|
|
|
|
url = "https://git.sagemath.org/sage.git/plain/build/pkgs/singular/patches/singular-ntl-error-handler.patch?h=50b9ae2fd233c30860e1cbb3e63a26f2cc10560a";
|
|
|
|
sha256 = "0vgh4m9zn1kjl0br68n04j4nmn5i1igfn28cph0chnwf7dvr9194";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2018-04-11 12:52:10 +01:00
|
|
|
# For reference (last checked on commit 75f460d):
|
|
|
|
# https://github.com/Singular/Sources/blob/spielwiese/doc/Building-Singular-from-source.md
|
|
|
|
# https://github.com/Singular/Sources/blob/spielwiese/doc/external-packages-dynamic-modules.md
|
|
|
|
buildInputs = [
|
|
|
|
# necessary
|
|
|
|
gmp
|
|
|
|
# by upstream recommended but optional
|
|
|
|
ncurses
|
|
|
|
readline
|
|
|
|
ntl
|
|
|
|
flint
|
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
|
|
|
|
pkgconfig
|
|
|
|
autoreconfHook
|
|
|
|
];
|
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
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out"
|
2018-04-11 12:52:10 +01:00
|
|
|
cp -r Singular/LIB "$out/lib"
|
|
|
|
make install
|
|
|
|
|
|
|
|
# Make sure patchelf picks up the right libraries
|
|
|
|
rm -rf libpolys factory resources omalloc Singular
|
|
|
|
'';
|
|
|
|
|
|
|
|
# simple test to make sure singular starts and finds its libraries
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
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
|
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'`
|
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
|
|
|
}
|