# -*- 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 115902 2014-01-14 01:14:51Z ryandesign@macports.org $

PortSystem                      1.0
PortGroup                       pure 1.0

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

description                     a Pure C bindings generator

long_description                ${name} is ${description}.

checksums                       rmd160  bd6da6de8c4cb51acea2a8bb2a92d645fef585c7 \
                                sha256  077c2db73b0894f45b68a8d1d98b493bc94c63d85de04f918d66771732b3aa8c

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 gcc47 gcc48 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 gcc47 gcc48 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 gcc47 gcc48 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 gcc47 gcc48 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
}
variant gcc47 conflicts gcc43 gcc44 gcc45 gcc46 gcc48 description {Use gcc47 for runtime C header parsing} {
    depends_run-append          path:bin/gcc-mp-4.7:gcc47
    global gcc_version
    set gcc_version             4.7
}
variant gcc48 conflicts gcc43 gcc44 gcc45 gcc46 gcc47 description {Use gcc48 for runtime C header parsing} {
    depends_run-append          path:bin/gcc-mp-4.8:gcc48
    global gcc_version
    set gcc_version             4.8
}
if {![variant_isset gcc43] && ![variant_isset gcc44] && ![variant_isset gcc45] && ![variant_isset gcc46] && ![variant_isset gcc47] && ![variant_isset gcc48]} {
    if {${os.platform} eq "darwin" && ${os.major} < 9} {
        # gcc44 doesn't build for me on Tiger
        default_variants +gcc43
    } else {
        default_variants +gcc48
    }
}

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
