# -*- 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-curl 317f0f5c0e5045a0f3c402d4137a869cda6194fc
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             0.3.0
revision            0
categories          fortran devel net
license             ISC
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         Fortran 2018 ISO_C_BINDING interfaces to Perl-compatible Regular Expressions 2
long_description    {*}${description}
checksums           rmd160  d8c4a4bc90b84ecc5f8b848811437bc7c82f9d6c \
                    sha256  2d7fe13933ffe5187e1481e6d8479f098db4996c589b92fb350aeb9909f6636a \
                    size    16951

depends_lib-append  port:curl

patchfiles          patch-Makefile.diff

post-patch {
    reinplace "s,@PREFIX@,${prefix}," ${worksrcpath}/Makefile
    reinplace "s,@CC@,${configure.cc}," ${worksrcpath}/Makefile
    reinplace "s,@FC@,${configure.fc}," ${worksrcpath}/Makefile
    reinplace "s,@CFLAGS@,${configure.cflags} [get_canonical_archflags cc]," ${worksrcpath}/Makefile
    reinplace "s,@FFLAGS@,${configure.fcflags}," ${worksrcpath}/Makefile
}

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

destroot {
    xinstall -d ${destroot}${prefix}/include/${name}
    copy ${worksrcpath}/libfortran-curl.a ${destroot}${prefix}/lib/
    copy ${worksrcpath}/curl.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}
}
