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

github.setup        libffi libffi 3.4.8 v
revision            0

checksums           rmd160  ea8558bf3afdf92f470859807a31c6dc78921d0e \
                    sha256  bc9842a18898bfacb0ed1252c4febcc7e78fa139fd27fdc7a3e30d9d9356119b \
                    size    1397992

github.tarball_from releases
categories          devel
license             MIT
maintainers         {fwright.net:fw @fhgwright} openmaintainer

description         A portable foreign function interface library
long_description    The libffi library provides a portable, high level \
                    programming interface to various calling \
                    conventions. This allows a programmer to call any \
                    function specified by a call interface description \
                    at run-time.

homepage            https://www.sourceware.org/libffi/


# Patches derived from MacPorts-enhanced GitHub fork at
# github.com/fhgwright/libffi

# patch-sources.diff: fixes for various issues.
#
# This diff is from v3.4.8 vs. macports-3.4.8.
#
patchfiles          patch-sources.diff

# Don't use macports gcc or clang toolchains to build this due to dependency cycles
compiler.blacklist-append macports-*

# Since libffi doesn't use C++, the cxx_stdlib setting is irrelevant, and
# having it differ from the OS default stdlib constrains the compiler selection,
# possibly even resulting in a circular dependency.  Hence, we clear the
# cxx_stdlib setting.
#
# Although libffi itself doesn't use C++, it provides support for the C++ ABI,
# and hence includes some tests written in C++.  The stdlib selection is not
# expected to impact libffi's own behavior, and if it did there would need to
# be appropriate conditional code to accommodate the difference.
#
# On the relevant OS versions (currently 10.6-10.8), this assumption can be
# tested by running the applicable port commands with
# "configure.cxx_stdlib=libc++".
#
platform darwin {
    configure.cxx_stdlib
}

# The architecture-detection code in the configure script is based on the
# compiler's default architecture.  We need to force this to match the
# target architecture to get the correct build.  Merely providing the
# correct architecture options in xxFLAGS is insufficient.
#
if { [variant_isset universal] } {
    merger_arch_compiler yes
} else {
    configure.cc "${configure.cc} ${configure.cc_archflags}"
}

# There used to be a hack to force the use of the integrated assembler when
# building with clang.  Not only is that no longer necessary, but it also
# causes slightly worse test results in at least one case.

array set merger_host {
    ppc64 powerpc-apple-darwin
}

lappend merger_dont_diff \
    ${prefix}/include/ffi.h \
    ${prefix}/include/ffitarget.h

depends_test-append port:dejagnu
test.run            yes
test.target         check

# Some warnings need to be disabled when building tests with gcc-4.2
if {[string match *gcc-4.2 ${configure.compiler}]} {
    test.env-append LIBFFI_TEST_OLDGCC=1
}

github.livecheck.regex {(\d+(?:\.\d+)+)}
