# -*- 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 54602 2009-07-30 06:29:03Z toby@macports.org $

PortSystem          1.0

name                gsl
version             1.12
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     3ec101903c8157756fa1352161bd4c39 \
                    sha1    3b5cba13f4b90e1473f693a5dc7efdcaae55fc46 \
                    rmd160  07c9d6a1e1fc1efb43dcc883fd15a2ca5d312da0

platforms           darwin
# Lower optimization level (-O1) is required to avoid code generation
# bugs in Apple's gcc 3.3 and earlier.
platform darwin 7 {
    configure.cflags-append "-O1"
}

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 description "Use GCC 4.3 for compilation of GSL - optimized for host machine" {
    depends_build-append        port:gcc43
    configure.cc                gcc-mp-4.3
    configure.cflags-append     "-ftree-vectorize -O3"
}

platform i386 {
  if {[variant_isset gcc43]} {
    configure.cflags-append     "-march=native"
  }
}
