# $Id$

PortSystem 1.0
PortGroup               github  1.0

github.setup            carvalho numlua 0.3
revision                9
name                    lua-numlua
license                 MIT
categories              devel
platforms               darwin
maintainers             bfulgham openmaintainer
description             Numerical package for the Lua programming language.
long_description        ${description} It includes support for complex numbers, multidimensional \
                        matrices, random generation and special functions. Much of the routines are \
                        simple wrappers for the stable and well-known libraries from Netlib

use_zip                 yes
# stealth packaging update
master_sites            macports_distfiles
set     archive_hash    f05281e96030adb9c09a01b9d9be4fa9fa4c795e
distfiles               ${archive_hash}.zip
worksrcdir              numlua-${archive_hash}

checksums               md5     acfce2eb1c0c5f1942b3a9917893c17c \
                        sha1    2fe543baedc9e62112a2df7b0dfbf8e8b304658d \
                        rmd160  df58135379ce8f01e0b454a8073257a01f23a03e

use_configure           no

# there used to be a dependency on a gccXX port due to the need for a fortran compiler
# this has now been removed due to dependency on port atlas

depends_lib-append      port:lua \
                        port:atlas \
                        lib:fftw:fftw-3 \
                        lib:hdf5:hdf5

post-extract {
    xinstall -m 644 ${filespath}/Makefile ${worksrcpath} }

post-patch {
    reinplace -W $worksrcpath "s|%%PREFIX%%|${prefix}|" Makefile }

build.args-append       CC=${configure.cc} \
                        CPP=${configure.cpp} \
                        PREFIX=$prefix \
                        CFLAGS="${configure.cflags} [get_canonical_archflags]" \
                        CPPFLAGS=${configure.cppflags} \
                        LDFLAGS=${configure.ldflags} \
                        DEPLOYMENT_TARGET=${macosx_deployment_target}

destroot.args-append    PREFIX=$prefix

pre-destroot {
    destroot.args-append    LUA_VERSION=[string range [lindex [lindex [registry_active lua] 0] 1] 0 2]
}

post-destroot {
    xinstall -d -m 755 ${destroot}${prefix}/share/doc
    xinstall -d -m 755 ${destroot}${prefix}/share/examples

    file copy ${worksrcpath}/docs ${destroot}${prefix}/share/doc/${name}
    file copy ${worksrcpath}/examples ${destroot}${prefix}/share/examples/${name}
    file copy ${worksrcpath}/lhp ${destroot}${prefix}/share/doc/${name}/lhp }