# -*- 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
# $Id: Portfile 90577 2012-03-09 06:38:41Z ryandesign@macports.org $

PortSystem                      1.0
PortGroup                       pure 1.0

pure.setup                      gen 0.15
categories                      devel
platforms                       darwin
maintainers                     ryandesign
license                         GPL-3

description                     a Pure C bindings generator

long_description                ${name} is ${description}.

checksums                       rmd160  eb3dab4fede5f0d1896bfa618295c51664e9841f \
                                sha256  e51921028f09710564b973d4ecd279f8654a8943c5aed8ddde0355bbb8a67bc6

depends_build-append            path:bin/ghc:ghc \
                                port:hs-language-c

depends_lib-append              port:gmp


# pure-gen uses gcc at runtime to parse C headers but the
# -fdirectives-only option it needs is only available in gcc 4.3 and up.
variant gcc43 conflicts gcc44 gcc45 gcc46 description {Use gcc43 for runtime C header parsing} {
    depends_run-append          path:bin/gcc-mp-4.3:gcc43
    global gcc_version
    set gcc_version             4.3
}
variant gcc44 conflicts gcc43 gcc45 gcc46 description {Use gcc44 for runtime C header parsing} {
    depends_run-append          path:bin/gcc-mp-4.4:gcc44
    global gcc_version
    set gcc_version             4.4
}
variant gcc45 conflicts gcc43 gcc44 gcc46 description {Use gcc45 for runtime C header parsing} {
    depends_run-append          path:bin/gcc-mp-4.5:gcc45
    global gcc_version
    set gcc_version             4.5
}
variant gcc46 conflicts gcc43 gcc44 gcc45 description {Use gcc46 for runtime C header parsing} {
    depends_run-append          path:bin/gcc-mp-4.6:gcc46
    global gcc_version
    set gcc_version             4.6
}
if {![variant_isset gcc43] && ![variant_isset gcc44] && ![variant_isset gcc45] && ![variant_isset gcc46]} {
    if {${os.platform} == "darwin" && ${os.major} < 9} {
        # gcc44 doesn't build for me on Tiger
        default_variants +gcc43
    } else {
        default_variants +gcc45
    }
}

patchfiles-append               patch-pure-gen.pure.diff
post-patch {
    reinplace "s|@CC@|${prefix}/bin/gcc-mp-${gcc_version}|g" ${worksrcpath}/pure-gen.pure
}

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