# -*- 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 88078 2011-12-18 08:11:44Z ryandesign@macports.org $

PortSystem          1.0

name                reduce-algebra
svn.revision        1530
version             3.8.0-r${svn.revision}
categories          math
platforms           darwin
license             BSD
maintainers         gmail.com:mark.brethen

description         REDUCE algebra system

long_description    REDUCE is an interactive program designed for general \
                    algebraic computations of interest to mathematicians, \
                    scientists and engineers.

homepage            http://reduce-algebra.sourceforge.net/

fetch.type          svn
svn.url             https://reduce-algebra.svn.sourceforge.net/svnroot/reduce-algebra/trunk
svn.method          checkout
worksrcdir          trunk

depends_build       port:pkgconfig

depends_lib         port:ncurses \
                    port:Xft2 \
                    port:xorg-libX11 \
                    port:xorg-libXext

configure.args      --with-psl

use_parallel_build  no
universal_variant   no

set dest_dir        ${prefix}/libexec/${name}

destroot {
# At present 'make install' is deeply broken, so manually install required files
    xinstall -d ${destroot}${dest_dir}/doc

    xinstall -m 0644 -W ${worksrcpath} BUGS BUILDING Contributor-Release.txt \
        DEPENDENCY_TRACKING INSTALL README ${destroot}${dest_dir}/doc

    xinstall -d ${destroot}${dest_dir}/bin
    xinstall ${worksrcpath}/bin/redpsl ${destroot}${dest_dir}/bin

    xinstall -d ${destroot}${dest_dir}/pslbuild
    eval copy [glob ${worksrcpath}/pslbuild/*] ${destroot}${dest_dir}/pslbuild

    xinstall -d ${destroot}${dest_dir}/scripts
    eval copy [glob ${worksrcpath}/scripts/*] ${destroot}${dest_dir}/scripts

    xinstall ${worksrcpath}/config.guess ${destroot}${dest_dir}
}

variant html description {Install documentation in HTML format} {
    depends_build-append bin:makeindex:texlive-basic
    depends_build-append bin:mk4ht:texlive-htmlxml

    post-build {
        system -W ${worksrcpath}/doc/manual "./mkhtml.sh"
    }

    post-destroot {
        xinstall -d ${destroot}${dest_dir}/doc/html
        eval xinstall -m 0644 [glob ${worksrcpath}/doc/manual/*.html] ${destroot}${dest_dir}/doc/html
    }
}

variant pdf description {Install documentation in PDF format} {
    depends_build-append bin:makeindex:texlive-basic
    depends_build-append bin:pdflatex:texlive-basic

    post-build {
        system -W ${worksrcpath}/doc/manual "./mkpdf.sh"
    }

    post-destroot {
        xinstall -d ${destroot}${dest_dir}/doc/pdf
        xinstall -m 0644 ${worksrcpath}/doc/manual/manual-pdf.pdf ${destroot}${dest_dir}/doc/pdf
    }
}

livecheck.type      none

notes "
To use the PSL version of Reduce, add this directory to your PATH environment variable:
    ${prefix}/libexec/reduce-algebra/bin/
"
