# -*- 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
PortGroup               makefile 1.0

name                    gfan
version                 0.6.2
revision                0

categories              math
license                 {GPL-2 GPL-3}

maintainers             nomaintainer

homepage                https://users-math.au.dk/jensen/software/gfan/gfan.html
description             Gfan is a software package for computing Gröbner fans and tropical varieties.
long_description        {*}${description}

master_sites            https://users-math.au.dk/jensen/software/gfan/
distfiles               ${name}${version}${extract.suffix}

checksums               rmd160  01a49b25644bd5e7cabb26fb7733eb6aec97f3fc \
                        sha256  a674d5e5dc43634397de0d55dd5da3c32bd358d05f72b73a50e62c1a1686f10a \
                        size    1321059

extract.rename          yes

compiler.c_standard     2011
compiler.cxx_standard   2014

configure.cflags-append -std=c++14


patchfiles              patch-log.diff \
                        patch-Makefile.diff


post-patch {
    reinplace "s|-L/usr/local|-L${prefix}/lib|" ${worksrcpath}/Makefile

    if { [string match *clang* ${configure.compiler}] } {
        reinplace "s|-fno-guess-branch-probability||" ${worksrcpath}/Makefile
    }
}

depends_lib-append      port:cddlib \
                        port:gmp

configure.cflags-append -I${prefix}/include/cddlib

build.pre_args          cddnoprefix=true

destroot {
    file copy ${worksrcpath}/gfan ${destroot}${prefix}/bin
    system -W ${destroot}${prefix}/bin "./gfan installlinks"

    xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
    xinstall    -m 644 -W ${worksrcpath} LICENSE COPYING README ${destroot}${prefix}/share/doc/${name}
}

livecheck.type          regex
livecheck.url           https://users-math.au.dk/jensen/software/gfan/gfan.html
livecheck.regex         "${name}(\[\\d.]+)${extract.suffix}"
