@@ -0,0 +1,89 @@
1+{ stdenv
2+, fetchurl
3+, fetchpatch
4+, makeWrapper
5+}:
6+
7+stdenv.mkDerivation rec {
8+ version = "1.018.1";
9+ name = "sympow-${version}";
10+
11+ src = fetchurl {
12+ # Original website no longer reachable
13+ url = "http://mirrors.mit.edu/sage/spkg/upstream/sympow/sympow-${version}.tar.bz2";
14+ sha256 = "0hphs7ia1wr5mydf288zvwj4svrymfpadcg3pi6w80km2yg5bm3c";
15+ };
16+
17+ nativeBuildInputs = [
18+ makeWrapper
19+ ];
20+
21+ configurePhase = ''
22+ runHook preConfigure
23+ ./Configure # doesn't take any options
24+ runHook postConfigure
25+ '';
26+
27+ installPhase = ''
28+ runHook preInstall
29+ install -d datafiles "$out/share/sympow/datafiles"
30+ install *.gp "$out/share/sympow/"
31+ install -Dm755 sympow "$out/share/sympow/sympow"
32+ install -D new_data "$out/bin/new_data"
33+
34+ makeWrapper "$out/share/sympow/sympow" "$out/bin/sympow" \
35+ --run 'export SYMPOW_LOCAL="$HOME/.local/share/sympow"' \
36+ --run 'if [ ! -d "$SYMPOW_LOCAL" ]; then
37+ mkdir -p "$SYMPOW_LOCAL"
38+ cp -r ${placeholder "out"}/share/sympow/* "$SYMPOW_LOCAL"
39+ chmod -R +xw "$SYMPOW_LOCAL"
40+ fi' \
41+ --run 'cd "$SYMPOW_LOCAL"'
42+ runHook postInstall
43+ '';
44+
45+ patches = [
46+ # don't hardcode paths
47+ (fetchpatch {
48+ name = "do_not_hardcode_paths.patch";
49+ url = "https://git.sagemath.org/sage.git/plain/build/pkgs/sympow/patches/Configure.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
50+ sha256 = "1611p8ra8zkxvmxn3gm2l64bd4ma4m6r4vd6vwswcic91k1fci04";
51+ })
52+
53+ # bug on some platforms in combination with a newer gcc:
54+ # https://trac.sagemath.org/ticket/11920
55+ (fetchpatch {
56+ name = "fix_newer_gcc1.patch";
57+ url = "https://git.sagemath.org/sage.git/plain/build/pkgs/sympow/patches/fpu.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
58+ sha256 = "14gfa56w3ddfmd4d5ir9a40y2zi43cj1i4d2l2ij9l0qlqdy9jyx";
59+ })
60+ (fetchpatch {
61+ name = "fix_newer_gcc2.patch";
62+ url = "https://git.sagemath.org/sage.git/plain/build/pkgs/sympow/patches/execlp.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
63+ sha256 = "190gqhgz9wgw4lqwz0nwb1izc9zffx34bazsiw2a2sz94bmgb54v";
64+ })
65+
66+ # fix pointer initialization bug (https://trac.sagemath.org/ticket/22862)
67+ (fetchpatch {
68+ name = "fix_pointer_initialization1.patch";
69+ url = "https://git.sagemath.org/sage.git/plain/build/pkgs/sympow/patches/initialize-tacks.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
70+ sha256 = "02341vdbbidfs39s26vi4n5wigz619sw8fdbl0h9qsmwwhscgf85";
71+ })
72+ (fetchpatch {
73+ name = "fix_pointer_initialization2.patch";
74+ url = "https://git.archlinux.org/svntogit/community.git/plain/trunk/sympow-datafiles.patch?h=packages/sympow";
75+ sha256 = "1m0vz048layb47r1jjf7fplw650ccc9x0w3l322iqmppzmv3022a";
76+ })
77+ ];
78+
79+ meta = with stdenv.lib; {
80+ description = "A package to compute special values of symmetric power elliptic curve L-functions";
81+ license = {
82+ shortName = "sympow";
83+ fullName = "Custom, BSD-like. See COPYING file.";
84+ free = true;
85+ };
86+ maintainers = with maintainers; [ timokau ];
87+ platforms = platforms.all;
88+ };
89+}