# -*- 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           cmake 1.1

name                swi-prolog
conflicts           swi-prolog-devel
epoch               20051223
version             9.2.9
revision            1

categories          lang
universal_variant   no
license             BSD
maintainers         {swi-prolog.org:jan @JanWielemaker} openmaintainer

description         SWI-Prolog compiler plus extra packages (stable version)
long_description    ISO/Edinburgh-style Prolog compiler including modules, \
                    autoload, libraries, Garbage-collector, stack-expandor, \
                    C/C++-interface, Multiple threads, GNU-readline interface, \
                    coroutining, constraint programming, global variables, \
                    very fast compiler. Including packages clib (Unix process \
                    control, sockets, MIME), cpp (C++ interface), sgml (reading \
                    XML/SGML), sgml/RDF (reading RDF into triples), ODBC \
                    interface and XPCE (Graphics UI toolkit, integrated editor \
                    (Emacs-clone) and graphical debugger).

homepage            https://www.swi-prolog.org/
master_sites        https://www.swi-prolog.org/download/stable/src/

distname            swipl-${version}
dist_subdir         swi-prolog

checksums           rmd160  22b10483c594e2bae33d145223ab3dcff7db5944 \
                    sha256  53f428e2d9bbdf30e53b06c9c42def9a13ff82fc36a111d410fc8b0bc889ee2d \
                    size    12321115

depends_build-append \
                    port:pkgconfig

depends_lib-append  port:db62 \
                    port:gmp \
                    port:gperftools \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libarchive \
                    port:libmcrypt \
                    port:ncurses \
                    port:ossp-uuid \
                    port:pcre2 \
                    port:readline \
                    port:Xft2 \
                    port:xorg-libXinerama \
                    port:xorg-libXt \
                    port:xpm \
                    port:libyaml \
                    port:zlib \
                    port:python313

compiler.c_standard 2011
compiler.cxx_standard 2017
compiler.thread_local_storage yes

configure.cmd       cmake
cmake.generator     Ninja
configure.pre_args  -DCMAKE_INSTALL_PREFIX=${prefix} \
                    -DCMAKE_BUILD_TYPE=Release \
                    -DCMAKE_INCLUDE_PATH=${prefix}/include \
                    -DCMAKE_LIBRARY_PATH=/usr/lib:${prefix}/lib \
                    -DSWIPL_PACKAGES_QT=OFF \
                    -DCPYTHON_VERSION="3.13\;EXACT"

variant qt5 description {Add Qt5 GUI} {
    depends_lib-append          port:qt5-qtbase
    configure.pre_args-delete   -DSWIPL_PACKAGES_QT=OFF
}

post-destroot {
    if {[variant_isset qt5]} {
        move ${destroot}/${prefix}/swipl-win.app ${destroot}${applications_dir}
    }
}

test.run            yes
test.cmd            ctest --output-on-failure

livecheck.type      regex
livecheck.url       ${homepage}download/stable/src
livecheck.regex     "swipl-(\\d+\\.\\d+\\.\\d+).tar.gz"
