summary refs log tree commit diff
path: root/pkgs/applications/science/math/singular/default.nix
blob: 9cd72c2fd50110ffcdc953cc54d01fd31ea3e057 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{ stdenv, fetchurl, gmp, bison, perl, autoconf, ncurses, readline, coreutils, pkgconfig
, asLibsingular ? false
}:

stdenv.mkDerivation rec {
  name = "singular-${version}";
  version="3-1-7";

  src = fetchurl {
    url = "http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${version}/Singular-${version}.tar.gz";
    sha256 = "1j4mcpnwzdp3h4qspk6ww0m67rmx4s11cy17pvzbpf70lm0jzzh2";
  };

  buildInputs = [ gmp perl ncurses readline ];
  nativeBuildInputs = [ autoconf bison pkgconfig ];

  preConfigure = ''
    find . -exec sed -e 's@/bin/rm@${coreutils}&@g' -i '{}' ';'
    find . -exec sed -e 's@/bin/uname@${coreutils}&@g' -i '{}' ';'
    ${stdenv.lib.optionalString asLibsingular ''NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DLIBSINGULAR"''}
  '';

  hardeningDisable = stdenv.lib.optional stdenv.isi686 "stackprotector";

  # The Makefile actually defaults to `make install` anyway
  buildPhase = "true;";

  installPhase = ''
    mkdir -p "$out"
    cp -r Singular/LIB "$out/LIB"
    make install${stdenv.lib.optionalString asLibsingular "-libsingular"}

    binaries="$(find "$out"/* \( -type f -o -type l \) -perm -111 \! -name '*.so' -maxdepth 1)"
    ln -s "$out"/*/{include,lib} "$out"
    mkdir -p "$out/bin"
    for b in $binaries; do
      bbn="$(basename "$b")"
      echo -e '#! ${stdenv.shell}\n"'"$b"'" "$@"' > "$out/bin/$bbn"
      chmod a+x "$out/bin/$bbn"
    done
  '';

  enableParallelBuild = true;

  meta = with stdenv.lib; {
    description = "A CAS for polynomial computations";
    maintainers = with maintainers; [ raskin ];
    platforms = subtractLists platforms.i686 platforms.linux;
    license = licenses.gpl3; # Or GPLv2 at your option - but not GPLv4
    homepage = "http://www.singular.uni-kl.de/index.php";
    downloadPage = "http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/";
  };
}