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

name                gle-graphics
version             4.2.5
set major           [lindex [split ${version} .] 0]
categories          graphics
platforms           darwin
maintainers         nomaintainer
license             BSD

description         Graphics Layout Engine

long_description    A graphics scripting language designed for creating \
                    publication quality graphics, plots, diagrams, figures \
                    and slides.

homepage            http://glx.sourceforge.net/
master_sites        sourceforge:project/glx/gle${major}%20%28Current%20Active%20Version%29/${version}

distname            ${name}-${version}f-src

checksums           rmd160  4101bd5ae35e64122a93b04ececefeb8bbae4041 \
                    sha256  6cd6b1d82cbf2c7a0b0affbd67c0ec32460ef6a13f6b41dfdd6f308fd651f102

depends_build       port:pkgconfig

depends_lib         path:lib/pkgconfig/cairo.pc:cairo \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libpng \
                    path:lib/pkgconfig/poppler.pc:poppler \
                    port:tiff \
                    port:zlib

worksrcdir          ${name}-${version}

patchfiles          patch-abs.diff \
                    patch-install_name.diff \
                    patch-qgle-carbon.diff \
                    patch-qgle-libgs.diff \
                    patch-qgle-glu.diff \
                    patch-hash-map.diff \
                    patch-src-gle-gle-poppler.cpp.diff

post-patch {
    reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/src/gui/qgslibloader.cpp
}

configure.args      --with-jpeg=${prefix} \
                    --with-png=${prefix} \
                    --with-poppler \
                    --with-tiff=${prefix} \
                    --with-z=${prefix} \
                    --with-qt=no \
                    --with-libgle=yes \
                    --with-manip=yes \
                    --with-debug=no \
                    --with-extrafonts=yes \
                    --with-arch=no \
                    --with-staticlink=no

# fix me
universal_variant   no

if {${name} eq ${subport}} {
    revision                4

    depends_lib-append      port:ncurses

    categories-append       aqua
    
    post-destroot {
        set docdir ${prefix}/share/doc/${subport}
        xinstall -d ${destroot}${docdir}
        xinstall -m 644 -W ${worksrcpath} \
            LICENSE.txt \
            README.txt \
            ${destroot}${docdir}
    }
    
    livecheck.type          regex
    livecheck.url           ${homepage}downloads/downloads.html
    livecheck.regex         ${name}-(\[0-9A-Za-z.\]+)f-src${extract.suffix}
} else {
    livecheck.type          none
}

subport QGLE {
    revision                18
    license                 GPL-2+
    
    description             graphical user interface of GLE
    
    long_description        ${subport} is the ${description}.
    
    depends_lib-append      port:${name} \
                            port:qt4-mac \
                            port:ghostscript
    
    configure.args-delete   --with-qt=no
    configure.args-append   --with-qt=${prefix}/libexec/qt4
    
    build.target            gui
    use_parallel_build      no
    
    destroot {
        copy ${worksrcpath}/build/bin/QGLE.app ${destroot}${applications_dir}
    }
}
