# -*- 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           cmake 1.1
PortGroup           github 1.0

github.setup        TeXworks texworks 0.6.3 release-
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
categories          editors tex
maintainers         nomaintainer
license             GPL-2

description         Editor for TeX documents
long_description    TeXworks is an environment for authoring TeX (LaTeX, ConTeXt, etc) documents, \
                    with a Unicode-based, TeX-aware editor, integrated PDF viewer, and a clean, \
                    simple interface accessible to casual and non-technical users.

# Avoid stealth update
master_sites        macports_distfiles

checksums           rmd160  dc56df2c97b4bc408fbfeb9c2b30d4024ed8c5f5 \
                    sha256  eb7426b9296aa92da06183690f542c2dcf0f2236215de5843f4585dd544d28be \
                    size    12082392

depends_build-append \
                    path:bin/pkg-config:pkgconfig
depends_lib         port:fontconfig \
                    port:hunspell \
                    port:lua \
                    path:lib/pkgconfig/poppler.pc:poppler \
                    port:zlib

# not sure why zlib is needed

configure.args-append       -DWITH_LUA=ON \
                            -DWITH_MUPDF=OFF \
                            -DWITH_POPPLER=ON \
                            -DWITH_PYTHON=OFF \
                            -DQTPDF_VIEWER=OFF \
                            -DPREFER_BUNDLED_SYNCTEX=ON

variant qt4 description {Build against Qt 4} {
    PortGroup               qt4 1.0
    depends_lib-append      port:poppler-qt4-mac
    configure.args-append   -DDESIRED_QT_VERSION=4
    configure.env-append    PKG_CONFIG_PATH=${prefix}/libexec/poppler-qt4-mac/lib/pkgconfig:${prefix}/lib/pkgconfig
}

# TODO: doesn't work at the moment
variant qt5 description {Build against Qt 5} {
    PortGroup               qt5 1.0
    depends_lib-append      port:poppler-qt5
    configure.args-append   -DDESIRED_QT_VERSION=5
}

# not properly tested yet
variant qtpdf description {Build with an experimental PDF viewer} {
    # and zlib
    depends_lib-append      port:freetype
    configure.args-replace  -DQTPDF_VIEWER=OFF -DQTPDF_VIEWER=ON
}

if {![variant_isset qt4] && ![variant_isset qt5]} {
    if {${os.platform} eq "darwin"} {
        default_variants    +qt4
    } else {
        default_variants    +qt5
    }
}

post-destroot {
    # alternatively set the DESTDIR straight to ${destroot}${applications_dir}
    move ${destroot}${prefix}/TeXworks.app ${destroot}${applications_dir}
}
