# -*- 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$

PortSystem          1.0
PortGroup           github 1.0

github.setup        ispc ispc 1.8.2 v
categories          lang parallel               
platforms           darwin
supported_archs     x86_64
license             BSD
maintainers         takeshi openmaintainer
description         Intel SPMD program compiler
long_description \
    ${name} is a compiler for a variant of the C programming language, \
    with extensions for single program, multiple data programming. 
homepage            http://${name}.github.com
checksums           rmd160  eedf3c7092f421b7c447ea93e101fdc5f96df417 \
                    sha256  5484437b1349df9141b0b45ec533264b7dd184ec3a808a5cca3e392eedff9e5a

set llvm_version    3.6

depends_build       port:bison \
                    port:flex \
                    port:python27
depends_lib         port:clang-${llvm_version}

use_configure       no

configure.compiler  macports-clang-${llvm_version}
patchfiles          patch-Makefile.diff
post-patch {
    if {[variant_isset doc]} {
        reinplace {s|rst2html.py|rst2html-2.7.py|} ${worksrcpath}/docs/build.sh
    }
}

build.args          LLVM_CONFIG=${prefix}/bin/llvm-config-mp-${llvm_version} \
                    PYTHON=${prefix}/bin/python2.7 \
                    CLANG=${configure.cc}\
                    CXX=${configure.cxx} \
                    OPT="${configure.cxxflags} -fvisibility=hidden" \
                    LEX=${prefix}/bin/flex \
                    YACC="${prefix}/bin/bison -d -v -t" \
                    BUILD_VERSION=${version} \
                    LDFLAGS=${configure.ldflags}
build.target        ""

test.run            yes
test.cmd            {python run_tests.py}
test.target         ""

destroot {
    xinstall -m 755 ${worksrcpath}/ispc ${destroot}${prefix}/bin
    xinstall -d -m 755 ${destroot}${prefix}/share/${name}
    file copy ${worksrcpath}/examples ${destroot}${prefix}/share/${name}
    if {[variant_isset doc]} {
        system "cd ${worksrcpath}/docs; ./build.sh"
        xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
        file copy ${worksrcpath}/docs ${destroot}${prefix}/share/doc/${name}
    }
}

variant doc description {build and install documentation} {
    depends_build-append    port:py27-docutils
}

livecheck.type      regex
livecheck.url       ${homepage}/downloads.html
livecheck.regex     {v([0-9]+\.[0-9]+\.[0-9])}