# -*- 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           github 1.0

set uname           yao
github.setup        frigaut ${uname} 5.4.0 v
license             GPL-2+
name                yorick-${uname}
categories          science yorick
platforms           darwin
maintainers         {thibaut @paumard} openmaintainer
description         A Yorick-based adaptive optics system simulator
long_description    Yao is a monte-carlo simulation package for adaptive \
                    optics. It can be used stand-alone through a GTK-based \
                    integrated graphical user interface or as a Yorick \
                    language extension.
homepage            http://maumae.net/yorick/doc/plugins.php

checksums           rmd160  367af012dfca0b98a556f1ab5793e2ba735d17f6 \
                    sha256  cd0e3bebc2027acab1beb8dec38437430db59769af37c27504504e1fe7f102ef

depends_lib-append  path:bin/yorick:yorick \
                    port:yorick-imutil \
                    port:fftw-3-single

depends_run         port:yorick-yutils \
                    port:yorick-soy \
                    port:yorick-svipc \
                    port:py27-pygtk

universal_variant   no

post-patch {
    reinplace "s|#!/usr/bin/env python2|#!${prefix}/bin/python2.7|" \
        ${worksrcpath}/${uname}.py
}

configure.cmd       ${prefix}/bin/yorick
configure.pre_args
configure.args      -batch make.i

build.args          PKG_CFLAGS="${configure.cppflags}" \
                    PKG_DEPLIBS="-L${prefix}/lib/yorick/lib -limutil -lfftw3f"

post-destroot {
    xinstall -d ${destroot}${prefix}/lib/yorick/packages/installed/
    xinstall -m 644 ${worksrcpath}/${uname}.info \
        ${destroot}${prefix}/lib/yorick/packages/installed/
    xinstall -m 644 ${worksrcpath}/doc/${uname}.1 \
        ${destroot}${prefix}/share/man/man1/
    ln -s ${prefix}/lib/yorick/bin/${uname} ${destroot}${prefix}/bin/
    fs-traverse x ${destroot}${prefix}/lib/yorick/share/${uname}/doc {
        file attributes ${x} -permissions a+r
    }
}
