# -*- 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.14.5
revision            0
checksums           rmd160  533df05dba382aa5c7bea3e8544ac3702c1b3d93 \
                    sha256  8703d33426eea50a8e3b7f4b984c05b8058cbff054b260863a1688980d8b8d19 \
                    size    8587011

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 2017
configure.args-append --disable-python

set pythons_suffixes {310 311 312 313 314}

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
