# -*- 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           makefile 1.0

github.setup        interkosmos fortran-zlib 0.2.0
revision            0
categories          fortran archivers
license             ISC
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         Collection of Fortran 2018 ISO_C_BINDING interfaces to selected zlib functions
long_description    {*}${description}
checksums           rmd160  5c594ae2508d5a5afe02cacb2f892b65b487658b \
                    sha256  1663329684feef1dab69a1fe679533aea57f01f42934da6462039669cb1fde79 \
                    size    5895
github.tarball_from archive

depends_lib-append  port:zlib

patchfiles          patch-Makefile.diff

post-patch {
    reinplace "s,@PREFIX@,${prefix}," ${worksrcpath}/Makefile
    reinplace "s,@FC@,${configure.fc}," ${worksrcpath}/Makefile
    reinplace "s,@FFLAGS@,${configure.fcflags}," ${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-zlib.a ${destroot}${prefix}/lib/
    copy ${worksrcpath}/zlib.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_zlib
test.target
