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

github.setup        Dsplib libdspl-2.0 83f8106416ddbd2380560e631163cb4de3553a39
name                dspl
version             2024.06.05
revision            0
categories          science math
license             LGPL-3
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         Opensource cross-platform digital signal processing algorithm library
long_description    {*}${description}, written in C.
homepage            http://en.dsplib.org
checksums           rmd160  430f7960db73d2e0788186384d854f9da4546e8a \
                    sha256  b7fbe64d7f2e27bf60bbbcf21e6f8882bd71c6389c6585f28d0cfad173138c49 \
                    size    5960186
github.tarball_from archive

post-extract {
    # DOS to UNIX line endings so we can patch.
    reinplace -W ${worksrcpath}/dspl/src/dft "s|\r||g" fft_cmplx.c ifft_cmplx.c
}

patchfiles          0001-Fixes-for-Macports.patch

compilers.setup     require_fortran
compiler.blacklist-append \
                    {*gcc-[3-4].*} {clang < 400}

post-patch {
    reinplace "s,@CC@,${configure.cc}," ${worksrcpath}/make.inc
    reinplace "s,@FC@,${configure.fc}," ${worksrcpath}/make.inc
    reinplace "s,@PREFIX@,${prefix},g" ${worksrcpath}/make.inc
    reinplace "s,@PREFIX@,${prefix}," ${worksrcpath}/dspl/Makefile

    platform darwin 10 powerpc {
        # Hack for Rosetta:
        reinplace "s,-lquadmath,,g" ${worksrcpath}/make.inc
    }
}

destroot {
    copy ${worksrcpath}/_release/dspl.h ${destroot}${prefix}/include/
    copy ${worksrcpath}/_release/libdspl.so ${destroot}${prefix}/lib/
    xinstall -d ${destroot}${prefix}/share/${name}
    copy ${worksrcpath}/_release/dspl.c ${destroot}${prefix}/share/${name}/
    xinstall -m 0644 -W ${worksrcpath} README.md LICENSE ${destroot}${prefix}/share/${name}/
}