# -*- 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
# $Id: Portfile 84550 2011-09-27 21:05:11Z snc@macports.org $

PortSystem          1.0

name                gsl-devel
conflicts           gsl
version             1.14.91
categories          math science
maintainers         nomaintainer
homepage            http://www.gnu.org/software/gsl
description         A numerical library for C and C++ programmers
long_description    The GNU Scientific Library (GSL) is a numerical library  \
                    for C and C++ programmers.  It is free software under the \
                    GNU General Public License.  \
                    \
                    The library provides a wide range of mathematical routines \
                    such as random number generators, special functions and \
                    least-squares fitting. There are over 1000 functions in total.

distname            gsl-${version}
master_sites        ftp://alpha.gnu.org/gnu/gsl/
checksums           md5     d1dd5ee21cf297b382a531421fcdb1fc \
                    sha1    a153f25199d24271b423ff2f4e394dc66b0ec1e8 \
                    rmd160  b7f5a3bfebccd9c8e885531960bd25d7f4ed6ce6

platforms           darwin

configure.args      --mandir=${prefix}/share/man --infodir=${prefix}/share/info
depends_build       port:texinfo
test.run            yes
test.target         check

post-install    {
    system "install-info ${destroot}${prefix}/share/info/gsl-ref.info ${prefix}/share/info/dir"
}

variant doc description "Install PDF and HTML documentation" {
    depends_build   port:ghostscript bin:latex:texlive
    post-destroot   {
        system "cd ${worksrcpath} && make dvi"
        system "cd ${worksrcpath}/doc && dvipdf gsl-ref.dvi gsl-ref.pdf"
        xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
        xinstall -c -m 644 ${worksrcpath}/doc/gsl-ref.pdf ${destroot}${prefix}/share/doc/${name}
        system "cd ${worksrcpath}/doc && latex fftalgorithms"
        system "cd ${worksrcpath}/doc && bibtex fftalgorithms"
        system "cd ${worksrcpath}/doc && latex fftalgorithms"
        system "cd ${worksrcpath}/doc && latex fftalgorithms"
        system "cd ${worksrcpath}/doc && dvipdf fftalgorithms.dvi fftalgorithms.pdf"
        xinstall -c -m 644 ${worksrcpath}/doc/fftalgorithms.pdf ${destroot}${prefix}/share/doc/${name}
        system "cd ${worksrcpath} && make html"
        xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}/html
        eval xinstall -c -m 644 [glob ${worksrcpath}/doc/gsl-ref.html/*] ${destroot}${prefix}/share/doc/${name}/html
    }
}
