# $Id: Portfile 85970 2011-10-17 23:04:53Z takanori@macports.org $

PortSystem      1.0

name            imaxima
version         1.0
categories      math
maintainers     nomaintainer
description     GUI front-end for Maxima
long_description \
                Imaxima provides a graphical user interface front-end \
                for the computer algebra system Maxima in an Emacs buffer.
platforms       darwin
license         GPL-2+
homepage        http://sites.google.com/site/imaximaimath/
master_sites    http://sites.google.com/site/imaximaimath/download-and-install/
distname        ${name}-imath-${version}
patchfiles      patch-imaxima.el.diff
checksums       md5     1cd6d58ec186d9b0477d99540358953a \
                sha1    7ae8d3a4dffed322ed6c79af6fe2a81df7c253e8 \
                rmd160  8cc125e6d9cd9d678506b856ab71b640bf23c966
depends_lib     path:bin/emacs:emacs
depends_run     port:ghostscript \
                port:texlive \
                port:maxima

set dir_info    ${prefix}/share/info
configure.args  --infodir=${dir_info}

notes-append    "
    Before using ${name}, put the following lines in your .emacs

    ;; for Imaxima
    (setq exec-path (cons \"${prefix}/bin\" exec-path))
    (autoload 'imaxima \"imaxima\" \"Image support for Maxima.\" t)
    "

use_parallel_build yes

test.run        yes
test.target     check

post-destroot {
    xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
    set docs {AUTHORS COPYING ChangeLog INSTALL NEWS README}
    foreach f ${docs} {
        xinstall -m 644 ${worksrcpath}/${f} ${destroot}${prefix}/share/doc/${name}
    }

    delete ${destroot}${dir_info}/dir
    if (![variant_isset emacs_app]) {
        # port:maxima installs ${prefix}/share/info/imaxima.info
        delete ${destroot}${dir_info}/imaxima.info
    }
}

universal_variant   no

variant emacs_app description {Use this package with Emacs.app} {
    depends_lib-delete  path:bin/emacs:emacs
    depends_lib-append  path:${applications_dir}/Emacs.app/Contents/MacOS/Emacs:emacs-app

    set dir_info    ${applications_dir}/Emacs.app/Contents/Resources/info
    configure.env   EMACS=${applications_dir}/Emacs.app/Contents/MacOS/Emacs
    configure.args  --with-lispdir=${applications_dir}/Emacs.app/Contents/Resources/site-lisp/${name} \
                    --infodir=${dir_info}
}

variant ptex description {Use pTeX instead of texlive} {
    depends_run-delete    port:texlive
    depends_run-append    port:pTeX
}

livecheck.type  regex
livecheck.url   "http://sites.google.com/site/imaximaimath/download-and-install"
livecheck.regex "${name}-imath-(\[0-9.a-z\+\-\]+).tar.gz"
