# -*- 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 119757 2014-05-05 20:35:00Z mf2k@macports.org $

PortSystem          1.0
PortGroup           perl5 1.0

perl5.branches      5.8 5.10 5.12 5.14 5.16
perl5.setup         PDL 2.007
maintainers         saao.ac.za:tim
license             Artistic GPL-2
description         Perl Data Language - scientific computing capability for perl
long_description    The perlDL project aims to turn perl into an efficient numerical \
                    language for scientific computing. The PDL module gives standard perl \
                    the ability to COMPACTLY store and SPEEDILY manipulate the large \
                    N-dimensional data sets which are the bread and butter of scientific \
                    computing.

platforms           darwin

homepage            http://pdl.perl.org/

checksums           rmd160  8d700ea03cb937ca94768e8a2e7338919f2ba561 \
                    sha256  609f6661061e444f2b5de845b2ab927adb9007b6511cf2f08aa0d6df0c62500c

if {${perl5.major} != ""} {
    depends_lib-append \
                        port:fftw-3 \
                        port:gsl \
                        port:hdf5-18 \
                        port:jpeg \
                        port:netpbm \
                        port:p${perl5.major}-astro-fits-header \
                        port:p${perl5.major}-convert-uu \
                        port:p${perl5.major}-extutils-f77 \
                        port:p${perl5.major}-file-map \
                        port:p${perl5.major}-inline \
                        port:p${perl5.major}-module-compile \
                        port:p${perl5.major}-pgplot \
                        port:p${perl5.major}-term-readline-gnu \
                        port:p${perl5.major}-test-warn \
                        port:pgplot \
                        port:plplot

                        # In core:
                        # port:p${perl5.major}-data-dumper \
                        # port:p${perl5.major}-extutils-makemaker \
                        # port:p${perl5.major}-file-temp \
                        # port:p${perl5.major}-filter-util-call \
                        # port:p${perl5.major}-pod-select \
                        # port:p${perl5.major}-text-balanced \

                        # Depreciated from core in 5.16 but still there in
                        # 5.18. Will need macports packages for these at some
                        # point:
                        # port:p${perl5.major}-filter-simple \
                        # port:p${perl5.major}-pod-parser \

                        # Needed for pdl2, but no MacPort package available
                        # and the dependency chain is very long
                        # port:p${perl5.major}-devel-repl \

    # Prereqs in Makefile.PL:
    # 'Astro::FITS::Header' => 0,
    # 'Convert::UU'         => 0,
    # 'Data::Dumper'        => 2.121,       # core 2.121 in 5.6.2
    # 'ExtUtils::MakeMaker' => 6.31,        # core 6.30 in 5.8.8
    # 'File::Map'           => 0.47,
    # 'File::Spec'          => 0.6,         # core 0.6 in 5.00405
    # 'File::Temp'          => 0,           # core in 5.6.1
    # 'Filter::Util::Call'  => 0,           # core in 5.7.4
    # 'Filter::Simple'      => 0.88,        # core, but only 0.84
    # 'Inline'              => 0.43,
    # 'Module::Compile'     => 0.23,
    # 'Pod::Parser'         => 0,           # core in 5.6.0
    # 'Pod::Select'         => 0,           # core in 5.6.0
    # 'Storable'            => 1.03,        # core 2.04 in 5.8.0
    # 'Text::Balanced'      => 1.89,        # core 1.89 in 5.7.3
    # 'Test::Warn'          => 0,


    # pgplot is not universal
    universal_variant   no

    post-patch {
        reinplace "s|/usr/local|${prefix}|g" \
            ${worksrcpath}/Basic/Core/pdlsimple.h.PL \
            ${worksrcpath}/Doc/Doc/Config.pm.PL \
            ${worksrcpath}/Graphics/PLplot/Makefile.PL \
            ${worksrcpath}/Graphics/TriD/Makefile.PL \
            ${worksrcpath}/IO/Browser/Makefile.PL \
            ${worksrcpath}/IO/GD/Makefile.PL \
            ${worksrcpath}/IO/HDF/Makefile.PL \
            ${worksrcpath}/Lib/FFT/Makefile.PL \
            ${worksrcpath}/Lib/GIS/Proj/Makefile.PL \
            ${worksrcpath}/Lib/Transform/Proj4/Makefile.PL \
            ${worksrcpath}/t/callext.t
    }

    post-build {
        # Create the pdldoc.db file for the help system
        exec ${perl5.bin} -I ${worksrcpath}/blib/arch \
            -I ${worksrcpath}/blib/lib \
            ${worksrcpath}/Doc/scantree.pl ${worksrcpath}/blib/lib \
            ${worksrcpath}/pdldoc.db \
            ${worksrcpath}/blib/lib/PDL/Index.pod \
            >/dev/null 2>/dev/null

        # Rewrite the paths in the pdldoc.db file. scantree will have the
        # ${worksrcpath}/blib/lib paths, we need ${perl5.archlib}.
        exec ${perl5.bin} ${filespath}/fix-pdldocdb.pl \
            ${worksrcpath}/pdldoc.db \
            ${worksrcpath}/blib/lib/PDL/pdldoc.db \
            "${worksrcpath}/blib/lib" \
            "${perl5.archlib}"
    }
}
