# -*- 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           gcc_dependency 1.0
PortGroup           muniversal 1.1

name                isl

# for library name changes, cross-compilers do *not* show up in traditional dependency searches
# (e.g. port file all | sort -u | xargs grep -E ':isl( |$)' | cut -d / -f 13 | sort -u)
# see https://lists.macports.org/pipermail/macports-dev/2019-May/040678.html
epoch               4
version             0.27
revision            0

categories          devel math
license             MIT
maintainers         {mcalhoun @MarcusCalhoun-Lopez} openmaintainer

description         Integer Set Library
long_description    isl is a library for manipulating sets and \
                    relations of integer points bounded by linear \
                    constraints. Supported operations on sets include \
                    intersection, union, set difference, emptiness \
                    check, convex hull, (integer) affine hull, integer \
                    projection, computing the lexicographic minimum \
                    using parametric integer programming, coalescing \
                    and parametric vertex enumeration. It also \
                    includes an ILP solver based on generalized basis \
                    reduction, transitive closures on maps (which may \
                    encode infinite graphs), dependence analysis and \
                    bounds on piecewise step-polynomials.
homepage            https://libisl.sourceforge.io

depends_lib         port:gmp

master_sites        sourceforge:libisl
use_bzip2           yes

checksums           rmd160  95056c9e98142c02a8884873502a6ad644da98e0 \
                    sha256  626335529331f7c89fec493de929e2e92fb3d8cc860fc7af554e0518ee0029ee \
                    size    2417649

# This duplicates condition from gcc_dependency PG:
if {(${os.arch} eq "powerpc" && ${configure.cxx_stdlib} eq "libc++") || \
    (${os.arch} ne "powerpc" && ${configure.cxx_stdlib} eq "macports-libstdc++")} {
    # Build system smuggles in wrong values.
    configure.args-append   CC_FOR_BUILD=${prefix}/libexec/gcc10-bootstrap/bin/gcc
    configure.args-append   CPP_FOR_BUILD=${prefix}/libexec/gcc10-bootstrap/bin/cpp
    configure.args-append   CXX_FOR_BUILD=${prefix}/libexec/gcc10-bootstrap/bin/g++
}

configure.args      --disable-silent-rules

triplet.add_build   cross

test.run            yes
test.target         check

livecheck.type      regex

if {${subport} eq ${name}} {
    conflicts           isl-devel

    # Be more strict about detecting C++11 for older compilers
    patchfiles-append   patch-configure_c++11.diff

    # https://trac.macports.org/ticket/65532
    if {${os.major} > 10 && ${os.major} < 18} {
        # cxx17 support on these systems is incomplete when building against libc++
        patchfiles-append   patch-configure-force-cxx17-to-fail.diff
    }

    # ./include/isl/typed_cpp.h:2132:12: error: no matching conversion for functional-style cast from 'const isl::basic_set' to 'isl::typed::basic_set<>'
    compiler.blacklist  {clang < 500}

    livecheck.regex ${name}-(\[0-9.\]+)${extract.suffix}
} else {
    livecheck.regex isl-([join [lrange [split ${version} .] 0 2] .]\[0-9.\]*)${extract.suffix}
}

subport isl14 {
    epoch           0
    version         0.14.1
    revision        0
    distname        isl-${version}
    checksums       rmd160  e4e45a8b777f89108303c165b149404ef84fd190 \
                    sha256  1f20561843eb9f6ae2076800bc45f3680ff7696520257cd5734ccfb843464cae \
                    size    1402630

    # Don't link using "-flat_namespace -undefined suppress" on Yosemite and later.
    patchfiles          yosemite-libtool.patch

    configure.pre_args  --prefix=${prefix}/libexec/${subport}
}

subport isl18 {
    epoch           0
    version         0.18
    revision        0
    distname        isl-${version}
    checksums       rmd160  e876f1049893de5be4a82a63f272f62547d455ca \
                    sha256  6b8b0fd7f81d0a957beb3679c81bbb34ccc7568d5682844d8924424a0dadcb1b \
                    size    1658291

    # Add a missing include to the isl_int headers.
    # Upstream doesn't want to bother fixing deprecated APIs.
    # (https://groups.google.com/d/msg/isl-development/N6UWJDbKXNA/2CY6WHDvOYoJ),
    # so this should be applied until they remove the headers outright.
    patchfiles          fix-deprecated-headers.patch

    configure.pre_args  --prefix=${prefix}/libexec/${subport}
}

subport isl24 {
    epoch           0
    version         0.24
    revision        0
    distname        isl-${version}
    checksums       rmd160  b3bf8e1ad50207d4eebecc47cb4cffdac6581a57 \
                    sha256  fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0 \
                    size    2261594

    # Be more strict about detecting C++11 for older compilers
    patchfiles          patch-configure_c++11.diff

    # ./include/isl/typed_cpp.h:2132:12: error: no matching conversion for functional-style cast from 'const isl::basic_set' to 'isl::typed::basic_set<>'
    compiler.blacklist  {clang < 500}

    configure.pre_args  --prefix=${prefix}/libexec/${subport}
}
