# -*- 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           boost 1.0
PortGroup           makefile 1.0

name                pythia
version             8.303
revision            1
set my_version      [strsed ${version} g/\\.//]
categories          science
platforms           darwin
maintainers         nomaintainer
license             LGPL-2.1
description         Generator of high-energy physics events
long_description    PYTHIA is a program for the generation of high-energy physics events, \
                    i.e. for the description of collisions at high energies between elementary particles \
                    such as e+, e-, p and pbar in various combinations. It contains theory and models for \
                    a number of physics aspects, including hard and soft interactions, parton distributions, \
                    initial- and final-state parton showers, multiple interactions, fragmentation and decay. \
                    It is largely based on original research, but also borrows many formulae and other \
                    knowledge from the literature.

homepage            http://home.thep.lu.se/~torbjorn/Pythia.html
master_sites        http://home.thep.lu.se/~torbjorn/pythia8/

distname            ${name}${my_version}
extract.suffix      .tgz

checksums           rmd160  ad1700ea79ec17b1d842b621c17b4e0489586c4d \
                    sha256  cd7c2b102670dae74aa37053657b4f068396988ef7da58fd3c318c84dc37913e \
                    size    22050105

universal_variant   no

depends_lib         port:zlib

compiler.cxx_standard   2011
configure.cxxflags-append -std=c++11

configure.args      --arch=DARWIN --enable-shared \
                    --cxx=${configure.cxx} \
                    --with-boost=[boost::install_area] \
                    --with-gzip=${prefix} \
                    --cxx-common="${configure.cxxflags}"

# g++-4.2 on 10.6 doesn't know about -stdlib (#44145)
# build.args        CC=${configure.cc} CXX="${configure.cxx} -stdlib=${configure.cxx_stdlib}"
pre-configure {
    if { ${configure.cxx_stdlib} eq "libc++" } {
        build.args  CC=${configure.cc} CXX="${configure.cxx} -stdlib=${configure.cxx_stdlib}"
    } else {
        build.args  CC=${configure.cc} CXX=${configure.cxx}
    }
}

post-build {
    foreach f [glob -directory ${worksrcpath}/lib *.dylib] {
        set dylib [file tail $f]
        system "install_name_tool -id ${prefix}/lib/${dylib} ${worksrcpath}/lib/${dylib}"
    }
}

destroot {
    foreach f [glob -directory ${worksrcpath}/lib *.*] {
        set fname [file tail $f]
        xinstall -W ${worksrcpath}/lib $fname ${destroot}${prefix}/lib
    }
    file mkdir ${destroot}${prefix}/include/${name}/Pythia8/
    xinstall -m 644 {*}[glob ${worksrcpath}/include/Pythia8/*.h] ${destroot}${prefix}/include/${name}/Pythia8/
    foreach x [glob -directory ${worksrcpath}/share/Pythia8 *] {
        set dname [file tail $x]
        file mkdir ${destroot}${prefix}/share/doc/${name}/${dname}
        foreach f [glob -nocomplain -directory ${x} *] {
            if {[file isfile ${f}]} {
                xinstall -m 644 ${f} ${destroot}${prefix}/share/doc/${name}/${dname}/
            }
        }
    }
}

livecheck.type      regex
livecheck.version   ${my_version}
livecheck.url       [lindex ${master_sites} 0]
livecheck.regex     ${name}(\\d+)${extract.suffix}
