# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 65146 2010-03-22 20:41:22Z snc@macports.org $

PortSystem          1.0

name                gsl
version             1.14
categories          math science
maintainers         openmaintainer jochen
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.

master_sites        gnu
checksums           md5     d55e7b141815412a072a3f0e12442042 \
                    sha1    e1a600e4fe359692e6f0e28b7e12a96681efbe52 \
                    rmd160  c89a30a0b38a0c83d73ded19180d52acd56e6a52

platforms           darwin

depends_build       port:texinfo
use_parallel_build  yes

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

post-activate    {
    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
    }
}

variant gcc43 conflicts gcc44 description "Use GCC 4.3 for compilation of GSL" {
    depends_build-append        port:gcc43
    configure.compiler          macports-gcc-4.3
}

variant gcc44 conflicts gcc43 description "Use GCC 4.4 for compilation of GSL" {
    depends_build-append        port:gcc44
    configure.compiler          macports-gcc-4.4
}

variant optimize description "Provide further optimization options (depending on compiler used)" {
    configure.cflags-append     "-ftree-vectorize -O3"
}

platform darwin i386 {
    if { [variant_isset optimize] && ( [variant_isset gcc43] || [variant_isset gcc44] ) } {
        configure.cflags-append "-march=native"
    }
}
