# $Id: Portfile 50980 2009-05-14 19:41:55Z and.damore@macports.org $

PortSystem 1.0

name                    lua-numlua
version                 0.2
revision                0
categories              devel
platforms               darwin
maintainers             bfulgham
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 (http://www.netlib.org).

homepage                http://luaforge.net/projects/numlua
master_sites            http://luaforge.net/frs/download.php/1400
distname                numlua-${version}

use_configure		no

checksums               md5 a49efb211b94fe3e436f6b00b6b01536 \
                        sha1 8465209f95d12f1803a5f6995a2c9af51fdbb021 \
			rmd160 0f8461b7af617c5e1d4eb0395baef4ccefb7a9b9

depends_build-append	port:gcc42
depends_lib-append      lib:fftw:fftw-3 

patchfiles              patch-Makefile \
                        patch-lib-config \
			patch-lib-Makefile \
			patch-src-Makefile

build.type		gnu
build.cmd		cd lib && make && cd ../src && make && cd ..
build.args		
build.target		

post-patch {
	reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/Makefile
	reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/lib/config
	reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/src/Makefile
}

destroot {
	xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
	file copy INSTALL LICENSE README TODO ${destroot}${prefix}/share/doc/${name}

	# Binaries
	xinstall -m 755 -d ${destroot}${prefix}/lib/lua/5.1
	foreach lib [glob src/*.so] {
		xinstall -m 0644 ${lib} ${destroot}${prefix}/lib/lua/5.1
	}

	# Lua libraries
	xinstall -m 755 -d ${destroot}${prefix}/share/lua/5.1
	foreach luadat [glob lua/*.lua] {
		xinstall -m 0644 ${luadat} ${destroot}${prefix}/share/lua/5.1
	}
	
	# Lua includes
	xinstall -m 755 -d ${destroot}${prefix}/include/lua5.1
	foreach inc [glob src/*.h] {
		xinstall -m 0644 ${inc} ${destroot}${prefix}/include/lua5.1
	}
}
