# -*- 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                spot
version             2.11.6
revision            0
checksums           rmd160  4bc9b4e1f68b0d92e9cf2be40858e7998a5e1bbf \
                    sha256  a692794f89c0db3956ba5919bdd5313e372e0de34000a9022f29e1c6e91c538a \
                    size    7573694

categories          science math
maintainers         nomaintainer
description         Spot is an object-oriented model checking library written in C++.
long_description    {*}${description}
homepage            https://spot.lrde.epita.fr/index.html
license             GPL-3
master_sites        http://www.lrde.epita.fr/dload/spot/

compiler.cxx_standard 2014
configure.args-append --disable-python

set pythons_suffixes {39 310 311 312}

set pythons_ports {}
foreach s ${pythons_suffixes} {
    lappend pythons_ports python${s}
}

proc python_dir {} {
    global pythons_suffixes
    foreach s ${pythons_suffixes} {
        if {[variant_isset python${s}]} {
            set p python[string index ${s} 0].[string range ${s} 1 end]
            return [file normalize [exec ${p} -c "import sys; print(sys.prefix)"]/lib/${p}/site-packages]
        }
    }
    error "Python support not enabled."
}

foreach s ${pythons_suffixes} {
    set p python${s}
    set v [string index ${s} 0].[string range ${s} 1 end]
    set i [lsearch -exact ${pythons_ports} ${p}]
    set c [lreplace ${pythons_ports} ${i} ${i}]
    set packagepath ${destroot}${frameworks_dir}/Python.framework/Versions/${v}/lib/python${v}
    variant ${p} description "Use Python ${v} for python bindings" conflicts {*}${c} "
        depends_lib-append      port:${p}
        configure.env-append    PYTHON=${prefix}/bin/python${v}
        configure.args-delete   --disable-python
        post-destroot {
            file mkdir ${destroot}${frameworks_dir}/Python.framework/Versions/${v}/lib/python${v}
            move ${destroot}${prefix}/lib/python${v}/site-packages ${packagepath}/site-packages
        }
    "
}

# enable one python variant so that the python bindings can be compiled
set selected_python python311
foreach s ${pythons_suffixes} {
    if {[variant_isset python${s}]} {
        set selected_python python${s}
    }
}
default_variants +${selected_python}

livecheck.type  regex
livecheck.url   ${master_sites}
livecheck.regex ${name}-(\[0-9.\]+).tar.gz
