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

name                            faust2pd
github.setup                    agraef pure-lang 2.16 ${name}-
github.tarball_from             releases
distname                        ${name}-${version}
homepage                        https://github.com/agraef/pure-lang/wiki/Addons#${name}

categories                      pure audio devel
platforms                       darwin
maintainers                     ryandesign gmail.com:aggraef
license                         GPL-3+

description                     a utility to generate Pd GUI patches from Faust programs

long_description                ${name} is ${description}.

checksums                       rmd160  cddc64a42ed718dbdeddef4c7ec196294e20e8ef \
                                sha256  6538f85f913d11441a6746d2f352b3e14ea2012ab3c77658a5500ffc641c20e6

use_configure                   no

# copied from pure-1.0.tcl
build.args-append               PUREC_FLAGS=-mcpu=generic

pre-build {
    if {${configure.cxx_stdlib} ne "" && [string match "*clang*" [option configure.cxx]]} {
        configure.cxxflags-append -stdlib=${configure.cxx_stdlib}
    }
    build.args-append           CC="${configure.cc}" \
                                CFLAGS="${configure.cflags} ${configure.cc_archflags}" \
                                CPPFLAGS="${configure.cppflags}" \
                                CXX="${configure.cxx}" \
                                CXXFLAGS="${configure.cxxflags} ${configure.cxx_archflags}" \
                                LDFLAGS="${configure.ldflags} ${configure.ld_archflags}"
}

post-destroot {
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    foreach f {COPYING README} {
        if {[file exists ${worksrcpath}/${f}]} {
            xinstall -m 644 ${worksrcpath}/${f} ${destroot}${prefix}/share/doc/${name}
        }
    }
    if {[file exists ${worksrcpath}/examples]} {
        xinstall -d ${destroot}${prefix}/share/examples
        copy ${worksrcpath}/examples ${destroot}${prefix}/share/examples/${name}
    }
}

depends_lib-append              port:pure \
                                port:pure-xml

build.args-append               LIBRARY_PATH=${prefix}/lib \
                                prefix=${prefix} \
                                pdprefix=${prefix}

destroot.target-append          install-pd
destroot.args-append            prefix=${prefix} \
                                pdprefix=${prefix}
