# $Id: Portfile 59973 2009-10-28 07:05:26Z pguyot@kallisys.net $

PortSystem 1.0

name                    llvm-devel
version                 53722
revision                1
set checker-version     62
categories              lang
platforms               darwin
use_parallel_build      yes
maintainers             erickt
description             llvm is a next generation compiler infrastructure
long_description        llvm brings tools to work on the llvm intermediate \
                        language incl. a C and C++ frontend.

homepage                http://llvm.org/
master_sites            macports:pguyot

distname                llvm-${version}

checksums               ${distname}${extract.suffix} \
                            md5     2572a3e6bc2d2356942dbae1929621c8 \
                            sha1    be776f49fe15c7599631eff0e6a4db575593f480 \
                            rmd160  efa4833664a2ff5b017645b13ce642d3fa1f1167 \
                        checker-${checker-version}${extract.suffix} \
                            md5     a04f5c35a65556b73e56c28f766e3750 \
                            sha1    85dcdc6a592fa4000b3314c55320dad7065f2522 \
                            rmd160  243bb4e053c2b435ac0af137d49ab5be4011e292

depends_build           bin:flex:flex \
                        bin:bison:bison

configure.dir           ${workpath}/build
build.dir               ${configure.dir}
destroot.dir            ${configure.dir}

post-extract {
    file mkdir ${configure.dir}
}

patchfiles              patch-Makefile.config.in.diff

configure.cppflags
configure.ldflags
configure.cmd           ${worksrcpath}/configure
configure.args          --enable-optimized --enable-jit

post-destroot {
    file mkdir ${destroot}${prefix}/lib/llvm
    file mkdir ${destroot}${prefix}/lib/llvm/src
    file mkdir ${destroot}${prefix}/lib/llvm/obj

    file copy ${worksrcpath}/include ${destroot}${prefix}/lib/llvm/src
    file copy ${configure.dir}/include ${destroot}${prefix}/lib/llvm/obj
    file copy ${configure.dir}/Release ${destroot}${prefix}/lib/llvm/obj

    reinplace "s|${worksrcpath}|${prefix}/lib/llvm/src|g"       ${destroot}${prefix}/bin/llvm-config \
                                                                ${destroot}${prefix}/lib/llvm/obj/Release/bin/llvm-config
    reinplace "s|${configure.dir}|${prefix}/lib/llvm/obj|g"     ${destroot}${prefix}/bin/llvm-config \
                                                                ${destroot}${prefix}/lib/llvm/obj/Release/bin/llvm-config

    fs-traverse item ${destroot} {
        if {[file isfile ${item}] && ".dir" == [file tail ${item}]} {
            delete ${item}
        }
    }
}

variant clang description {Install clang (with checker tools)} {
    distfiles-append    checker-${checker-version}${extract.suffix}
    post-extract {
        move ${workpath}/checker-${checker-version} ${worksrcpath}/tools/clang
    }
    patchfiles-append   patch-tools-Makefile.diff
    depends_lib-append  port:python25
    post-destroot {
        reinplace "s|/usr/bin/env python|${prefix}/bin/python2.5|g" ${worksrcpath}/tools/clang/utils/ccc-analyzer
        xinstall -W ${worksrcpath}/tools/clang/utils \
            ccc \
            ccc-analyzer \
            scan-build \
            sorttable.js \
            ${destroot}${prefix}/bin
    }
}
