# -*- 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           muniversal 1.1

name                ffcall
version             2.5
license             GPL-2
categories          devel
maintainers         nomaintainer
description         Foreign function call libraries
long_description    ffcall is a collection of four libraries which can \
                    be used to build foreign function call interfaces \
                    in embedded interpreters.
homepage            https://www.gnu.org/software/libffcall/
distname            libffcall-${version}
checksums           rmd160 8fdf1c1aebe0c1c212a65b8ec01ceaffce033bf5 \
                    sha256 7f422096b40498b1389093955825f141bb67ed6014249d884009463dc7846879
master_sites        gnu:libffcall

patchfiles          parallel.patch

test.run            yes
test.target         check

compiler.blacklist-append \
                    *gcc-3.* *gcc-4.*

configure.checks.implicit_function_declaration.whitelist-append strchr

# configure accepts --infodir, although there is no info pages (yet?).
configure.args      --mandir=${prefix}/share/man \
                    --infodir=${prefix}/share/info

foreach arch {arm64 x86_64 i386 ppc ppc64} {
    # `libtool` compiles assembly with CC but without any way to set compiler flags
    # this is a problem if ${configure.build_arch} is not the same as the compiler default architecture
    # and for universal builds
    configure.args.${arch}-append \
                    CC="${configure.cc} -arch ${arch}"
}

# https://trac.macports.org/ticket/65736
platform darwin 10 powerpc {
    configure.args-append \
                    --build=powerpc-apple-darwin${os.major}
}

if {${os.platform} eq "darwin" && ${os.major} < 10} {
    depends_build-append port:cctools
    configure.env-append NM=${prefix}/bin/nm
    configure.args-append lt_cv_path_NM=${prefix}/bin/nm
}

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    move {*}[glob ${destroot}${prefix}/share/html/*] \
        ${destroot}${prefix}/share/doc/${name}
}
