# $Id: Portfile 68300 2010-05-31 13:07:46Z takeshi@macports.org $

PortSystem        1.0

name              fgsl
version           0.9.3
categories        math science
maintainers       takeshi
license           GPLv2
description       Fortran interface to the GNU scientific library
long_description  \
    A portable, object-based Fortran interface to the GNU scientific library, \
    a collection of numerical routines for scientific computing.
homepage          http://www.lrz-muenchen.de/services/software/mathematik/gsl/fortran/
platforms         darwin
master_sites      ${homepage}
checksums         md5     c947c761121900dcd81f544b1a0dbe6e \
                  sha1    96e0e0c6b538377bdbe043c8c064e5d60ba6e428 \
                  rmd160  159162527256408ecf210b382461794b71c4738c
depends_lib       port:gsl port:g95
patch {
    reinplace "s| \$bits | \"\$bits\" |" ${worksrcpath}/configure
    reinplace "s|uname -i|uname -p|" ${worksrcpath}/configure
    reinplace "s|\$(PREFIX)|\$(DESTDIR)\$(PREFIX)|" ${worksrcpath}/Makefile
    reinplace "s|/usr/local|${prefix}|" ${worksrcpath}/doc/usage.texi
}

#pre-configure {
#        reinplace "s|gfortran|gfortran-mp-4.3|" ${worksrcpath}/configure
#}
configure.pre_args-delete --prefix=${prefix}
configure.args    "--prefix ${prefix} --f90 g95 --gsl ${prefix}"

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/${name}/examples
    eval xinstall -m 644 [glob ${worksrcpath}/doc/examples/*] ${destroot}${prefix}/share/${name}/examples
    xinstall -m 644 ${worksrcpath}/make.inc ${destroot}${prefix}/share/${name}
    reinplace "s|../make.inc|make.inc|" ${destroot}${prefix}/share/${name}/examples/Makefile
    reinplace "s|-I../..|-I${prefix}/include/\$(F90)|" ${destroot}${prefix}/share/${name}/examples/Makefile
    if {[variant_isset doc]} {
        xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
        xinstall -m 644 ${worksrcpath}/doc/fgsl-ref.pdf ${destroot}${prefix}/share/doc/${name}/
    }
}

universal_variant no

# gfortran 4.3.x does not support complex(c_double)
#variant gcc43 description {build with gcc43} {
#        depends_build-delete port:g95
#        depends_build-append port:gcc43
#        configure.args    "--prefix ${prefix} --f90 gfortran-mp-4.3 --gsl ${prefix}"
#        reinplace "s|g95|gfortran-mp-4.3|" ${worksrcpath}/doc/usage.texi
#}

variant doc description {typeset documentation} {
        depends_build-append port:texinfo bin:dvipdf:teTeX
        post-build {
                system "cd ${worksrcpath}/doc/; make"
        }
}

livecheck.type  regex
livecheck.url   ${homepage}
livecheck.regex {Download .*version ([0-9]+\.[0-9]+\.*[0-9]*)}
