# $Id: Portfile 86229 2011-10-23 04:24:05Z takeshi@macports.org $

PortSystem        1.0

name              fgsl
version           0.9.4
categories        math science
maintainers       takeshi
license           GPL-2
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     cee6760809bc1ddbb6172fc8818a76b2 \
                  sha1    82f3047a3b1b1970fae741946fd8479f15595362 \
                  rmd160  7c12162b4fb64746d91715756c01e52dbb4e0e09
depends_lib       port:gsl port:g95
patch {
    reinplace "s| \$bits | \"\$bits\" |" ${worksrcpath}/configure
    reinplace "s|fgsl_doc|share/doc/fgsl|" ${worksrcpath}/Makefile
    reinplace "s|\$(PREFIX)|\$(DESTDIR)\$(PREFIX)|" ${worksrcpath}/Makefile
    reinplace "s|error_3\.exe||" ${worksrcpath}/doc/examples/Makefile
}

#pre-configure {
#        reinplace "s|gfortran|gfortran-mp-4.3|" ${worksrcpath}/configure
#}
configure.pre_args-delete --prefix=${prefix}
configure.args    "--prefix ${prefix} --f90 g95 --cc ${configure.cc} --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}
    }
}

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 {deprecated. dummy variant} {
#        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]*)}
