# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem              1.0

name                    pari-extra
version                 20230725
revision                0

categories              math
platforms               {darwin any}
supported_archs         noarch

maintainers             nomaintainer

license                 GPL-2+

description             PARI/GP optional packages.
long_description        {*}${description}

homepage                https://pari.math.u-bordeaux.fr/
master_sites            ${homepage}pub/pari/packages/

use_configure           no

depends_run             port:pari

build                   {}

extract.suffix          .tgz

subport pari-elldata {
    version             20210301
    revision            0
    description         PARI/GP version of J. E. Cremona Elliptic Curve Data
    long_description    {*}${description}, needed by ellsearch and ellidentify.

    checksums           rmd160  5d9c5683c13c1f7a86512720dd19483f0db72936 \
                        sha256  dd551e64932d4ab27b3f2b2d1da871c2353672fc1a74705c52e3c0de84bd0cf6 \
                        size    57455317
}

subport pari-galpol {
    version             20180625
    revision            0
    description         PARI package of the GALPOL database of polynomials defining Galois extensions of the rationals
    long_description    {*}${description}, accessed by galoisgetpol, galoisgetgroup, galoisgetname.

    checksums           rmd160  c311d0e5f4f81c020f1b7d3693c553871f6f832f \
                        sha256  562af28316ee335ee38c1172c2d5ecccb79f55c368fb9f2c6f40fc0f416bb01b \
                        size    10049371
}

subport pari-seadata {
    version             20090618
    revision            0
    description         These polynomials were extracted from the ECHIDNA databases and computed by David R. Kohel
    long_description    {*}${description}. This covers finite fields of cardinality q up to 750 bits. \
                        PARI/GP 2.9 contains fallback code to go on when all modular polynomials in the database have been exhausted \
                        and can handle larger fields (with an important slowdown). Needed by ellap and ellcard for large primes.

    checksums           rmd160  e88637426f74c5223068fc2d916741c10d8279e4 \
                        sha256  c9282a525ea3f92c1f9c6c69e37ac5a87b48fb9ccd943cfd7c881a3851195833 \
                        size    19214199

    conflicts           pari-seadata-small
}

subport pari-seadata-small {
    version             20090618
    revision            0
    description         The second one is a much smaller version that should be suitable for fields up to 350 bits.
    long_description    {*}${description}

    checksums           rmd160  b0437047c45f4e2e9155a52e857355723d279a54 \
                        sha256  bf5be913472b268df7f1242f94c68113fcacceb30c280507447ff2be62760a8f \
                        size    670664

    conflicts           pari-seadata
}

subport pari-seadata-big {
    version             20170418
    revision            0
    description         The third one is huge and contains extra modular polynomials of level between 500 and 800.
    long_description    {*}${description} This is suitable for fields up to 1100 bits.

    checksums           rmd160  7c4623ecfe0c23c608af510f832de35b401e361b \
                        sha256  7c4db2624808a5bbd2ba00f8b644a439f0508532efd680a247610fdd5822a5f2 \
                        size    103526400

    extract.suffix      .tar
    extract.cmd         cat
    extract.pre_args
}

subport pari-nftables {
    version             20080929
    revision            0
    description         Repackaging of the historical megrez number field tables (errors fixed, 1/10th the size, easier to use).
    long_description    {*}${description} This package requires no installation: extract it where desired and look at the README. \
                        Individual tables from the package are available separately.

    checksums           rmd160  48a9c48246f91c1983712682937d666ba1ae6458 \
                        sha256  8dd3393ce6b3cfcf599f094f7b22bdffe17c3ba25deb912513d54676bd7cfe92 \
                        size    8393731
}

subport pari-galdata {
    version             20080412
    revision            0
    description         Needed by polgalois to compute Galois group in degrees 8 through 11.
    long_description    {*}${description}

    checksums           rmd160  488afbddf7026dd6d0c9ebbed72cb14c8c37173e \
                        sha256  b7c1650099b24a20bdade47a85a928351c586287f0d4c73933313873e63290dd \
                        size    53229
}

subport pari-nflistdata {
    version             20220729
    revision            0
    description         Needed by nflist to list fields of small discriminant
    long_description    {*}${description}  (currently needed by the single Galois groups A5 and A5(6)) or to list regular extensions of Q(T) in degree 7 to 15.

    checksums           rmd160  8c948956c89a0b1520cb365f042894527cd94cb5 \
                        sha256  2c19a3e02afd3bba2af3071a7faa80924a75b00bb9713286c886b7fb460944bc \
                        size    3623252
}

distname                [regsub ***=pari- $subport ""]

destroot {
    if {[file exists ${workpath}/data]} {
        move ${workpath}/data ${destroot}${prefix}/share/pari
    } else {
        xinstall -m 755 -d ${destroot}${prefix}/share/pari
        move ${workpath}/${distname} ${destroot}${prefix}/share/pari/${distname}
    }
}

livecheck.type          regex
livecheck.url           [lindex ${master_sites} 0]
livecheck.version       [regsub {(....)(..)(..)} ${version} {\1-\2-\3}]
livecheck.regex         "${distname}${extract.suffix}</a></td><td align=\"right\">(\\d+-\\d+-\\d+) "

if {${name} eq ${subport}} {
    PortGroup           stub 1.0

    depends_run-append  port:pari-elldata \
                        port:pari-galpol \
                        port:pari-seadata \
                        port:pari-seadata-big \
                        port:pari-nftables \
                        port:pari-galdata \
                        port:pari-nflistdata

    livecheck.type      none
}
