# -*- 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

PortSystem          1.0
PortGroup           qt4 1.0

name                TeXmacs
conflicts           fig2ps
version             1.99.2
revision            6
distname            ${distname}-src
categories          editors
maintainers         nomaintainer
platforms           darwin
license             GPL-3+

description         GNU TeXmacs: A Scientific Text Editor
long_description    \
        GNU TeXmacs is a free scientific text editor,          \
        which was both inspired by TeX and GNU Emacs.          \
        The editor allows you to write structured documents    \
        via a wysiwyg (what-you-see-is-what-you-get) and       \
        user friendly interface. New styles may be created by  \
        the user. The program implements high-quality          \
        typesetting algorithms and TeX fonts, which help you   \
        to produce professionally looking documents.           \
                                                               \
        The high typesetting quality still goes through for    \
        automatically generated formulas, which makes TeXmacs  \
        suitable as an interface for computer algebra systems. \
        TeXmacs also supports the Guile/Scheme extension       \
        language, so that you may customize the interface and  \
        write your own extensions to the editor.

#user_notes          If texmacs can't find guile's modules, you will have to \
#                    set GUILE_LOAD_PATH explicitly (usually                 \
#                    ${prefix}/share/guile/1.8).                             \
#                                                                            \
#                    Also, you may need to set DISPLAY to localhost:0.0 if   \
#                    launching TeXmacs from a non-X11 terminal.

#bugs                Some of the computer algebra system sessions (e.g.,     \
#                    maxima) will hang if you try to use the online help     \
#                    function.

homepage            http://www.texmacs.org/
master_sites        ${homepage}Download/ftp/tmftp/source/:source \
                    ftp://ftp.texmacs.org/pub/${name}/fonts/:fonts

distfiles           ${name}-${version}-src${extract.suffix}:source \
                    ${name}-extra-fonts-1.0-noarch${extract.suffix}:fonts

checksums           ${name}-${version}-src${extract.suffix}                                  \
                    md5     544ee0ada9a7fe0ea39e33d94e8d5ff5                                 \
                    sha1    5298e9bd3f61cd8f2117fe1d96a7435f8a788cc8                         \
                    rmd160  f4dbbbd80832f3527e4e0c58f651da1adf8a0df5                         \
                    sha256  da017f0d5c927adc33952a6efd773165f63e1eaa509f627857f145434e7a8850 \
                    size    18957858                                                         \
                    ${name}-extra-fonts-1.0-noarch${extract.suffix}                          \
                    md5     4666d29252da18bbc3fa7e162bb00b17                                 \
                    sha1    c7a1af56b1af4c18c0792cec69330bd6daea002b                         \
                    rmd160  ae539c873f16463a3c19fcaf69fd338a1eadd7ce                         \
                    sha256  671a1bc008c8b99a7117bbf742c2dae144c0e7e4aad2b5a0f2c997d4aa7cd443 \
                    size    5395696

depends_lib         port:freetype     \
                    port:guile-1.8    \
                    port:libiconv     \
                    port:libtool      \
                    port:texlive      \
                    port:xorg-libXext \
                    port:zlib

depends_run         bin:gs:ghostscript

extract.only        ${name}-${version}-src${extract.suffix}

post-extract    { system "${extract.cmd} ${extract.pre_args} ${distpath}/${name}-extra-fonts-1.0-noarch${extract.suffix} ${extract.post_args} -C ${worksrcpath}/${name}"
        }

patchfiles-append   patch-Makefile.in.diff
patchfiles-append   patch-aclocal.m4.diff
patchfiles-append   patch-configure.in.diff

use_autoconf        yes

configure.ldflags-append -lz

build.target

post-destroot   { file mkdir ${destroot}${prefix}/share/${name}
                  system "chown -R root:admin ${destroot}${prefix}/share/${name}"

          file rename ${destroot}${prefix}/share/${name}/plugins/cadabra \
                  ${destroot}${prefix}/share/${name}/plugins/cadabra.texmacs
                }

post-activate {
    system "${prefix}/bin/update-mime-database ${prefix}/share/mime || true"
}

post-deactivate {
    system "${prefix}/bin/update-mime-database ${prefix}/share/mime || true"
}

livecheck.type      regex
livecheck.url       ${homepage}tmweb/download/sources.en.html
livecheck.regex     /${name}-(\[0-9.\]+)-src${extract.suffix}">latest stable version
