# -*- 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.30 v
github.tarball_from     archive

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  74b51fd32b10a6a84c6efbac8ea97249c2a8f19a \
                        sha256  9228650edc48ad5deeab5d92272e242e906f90d292c90af132a3f20d9354735a \
                        size    932256

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"
