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

# CMake fails to build tests, therefore using Meson:
# https://github.com/josephalevin/fson/issues/32
github.setup        josephalevin fson 1.0.5 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0
categories          devel fortran
license             BSD
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         Fortran 95 JSON Parser
long_description    {*}${description}
checksums           rmd160  b00692ec7197bebefa464eeb561048f91736ea93 \
                    sha256  0bce1e2d9789de60ee252e3870a761a202a40b6002e473771601bd58e6a067c3 \
                    size    33787

depends_build-append \
                    port:pkgconfig \
                    port:zofu

compilers.choose    fc cc
compilers.setup     require_fortran

# Apple clang on 10.7 fails to build it:
# https://github.com/josephalevin/fson/issues/33
# error: invalid instruction mnemonic 'cvttss2sil'
compiler.blacklist-append {clang < 500}

configure.args-append \
                    -Dincludedir=${prefix}/include/${name}

post-destroot {
    # Delete build objects, keep .mod files:
    fs-traverse f ${destroot}${prefix}/include/${name} {
        if {[file isfile ${f}] && !([file extension ${f}] == ".mod")} {
            delete ${f}
        }
    }
}

depends_test-append port:ninja \
                    port:zofu

test.run            yes
test.target         test
