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

github.setup        interkosmos fortran-sqlite3 33b1f0da566cd4aaa36e59ceb70be8c89a6a3443
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             0.2.0
revision            0
categories          fortran databases
license             ISC
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         Fortran 2018 interface bindings to SQLite 3
long_description    {*}${description}
checksums           rmd160  882ba76c07647f7355147fdcad4c49937ad97559 \
                    sha256  9c75722c8aa1c11a99fba29a8496806c6d95fda268255a14e1e4af1457ebcab6 \
                    size    14112

depends_lib-append  port:sqlite3

patchfiles          patch-Makefile.diff

post-patch {
    reinplace "s,@PREFIX@,${prefix}," ${worksrcpath}/Makefile
    reinplace "s,@FC@,${configure.fc}," ${worksrcpath}/Makefile
}

compilers.setup     require_fortran
compiler.blacklist-append *gcc-4.* {clang < 500}

use_parallel_build  no
build.target        all test

destroot {
    xinstall -d ${destroot}${prefix}/include/${name}
    copy ${worksrcpath}/libfortran-sqlite3.a ${destroot}${prefix}/lib/
    foreach mod {callbacks.mod sqlite3.mod sqlite3_util.mod} {
        copy ${worksrcpath}/${mod} ${destroot}${prefix}/include/${name}/
    }
}

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} LICENCE README.md ${destroot}${docdir}
}

test.run            yes
test.cmd            ./test_sqlite3
test.target