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

github.setup            otfried ipe 7.2.29 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball

revision                0
categories              graphics
maintainers             {gmail.com:jjstickel @jjstickel} \
                        openmaintainer
description             The Ipe extensible drawing editor
long_description        \
                        Ipe is a drawing editor for creating figures in PDF or \
                        (encapsulated) Postscript format. It supports making small \
                        figures for inclusion into LaTeX-documents as well as making \
                        multi-page PDF presentations that can be shown on-line with \
                        Acrobat Reader.
license                 GPL-3+
homepage                https://ipe.otfried.org
platforms               macosx

worksrcdir              ${name}-${version}/src

checksums               rmd160  3aab1c281c938f10c80d29d23c46df963c645b8c \
                        sha256  2d7e87ad8a2a84c33bca16dd2cc6c91b4aa931500a6ad0b7970bc7d2d7955e1a \
                        size    932128

depends_build-append    port:pkgconfig

depends_lib-append      port:freetype \
                        port:gsl \
                        path:lib/pkgconfig/cairo.pc:cairo \
                        port:lua \
                        port:libpng \
                        port:libspiro \
                        port:zlib

use_configure           no
universal_variant       no

variant qvoronoi description {Add qvoronoi ipelet} {
    depends_lib-append  port:qhull
    build.args-append   IPEQVORONOI=1 QHULL_CFLAGS=-I${prefix}/include/libqhull_r
    destroot.post_args  IPEQVORONOI=1
}

default_variants        +qvoronoi

pre-build {
    build.env           CXXFLAGS=[get_canonical_archflags cxx] \
                        LDFLAGS=[get_canonical_archflags ld]
    build.args-append   IPEPREFIX=${prefix} \
                        CXX=${configure.cxx} \
                        LUA_PACKAGE="lua" \
                        JPEG_LIBS="-framework ApplicationServices" \
                        IPECONFIGMAK="config.mak" \
                        IPEBUNDLE=1
}

use_parallel_build      no

destroot.args-append    IPEPREFIX=${prefix} \
                        IPECONFIGMAK="config.mak" \
                        IPEBUNDLE=1

destroot.target         app
use_xcode               yes


platform macosx {
    post-destroot {
        copy ${worksrcpath}/../build/Ipe.app ${destroot}${applications_dir}/Ipe.app
        reinplace "s|/usr/local/bin|/usr/local/bin:${prefix}/bin|g" ${destroot}${applications_dir}/Ipe.app/Contents/Info.plist
        xinstall -m 755 ${filespath}/ipe.in ${destroot}${prefix}/bin/ipe
        reinplace "s|@APPLICATIONSDIR@|${applications_dir}|g" ${destroot}${prefix}/bin/ipe
        xinstall -m 755 ${filespath}/ipetoipe.in ${destroot}${prefix}/bin/ipetoipe
        reinplace "s|@APPLICATIONSDIR@|${applications_dir}|g" ${destroot}${prefix}/bin/ipetoipe
    }
}

livecheck.type          regex
livecheck.url           ${homepage}
livecheck.regex         "${name}-(\\d+(?:\\.\\d+)*)-src"
