# -*- 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
# $Id: Portfile 89056 2012-01-19 00:57:21Z ryandesign@macports.org $

PortSystem 1.0
PortGroup               qt4 1.0

name                    ipe
version                 7.1.2
set branch              [join [lrange [split ${version} .] 0 1] .]
categories              graphics
maintainers             jacobs-university.de:m.thon 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                http://ipe7.sourceforge.net/
platforms               darwin
master_sites            sourceforge:project/ipe7/ipe/${branch}.0
distname                ${name}-${version}-src
worksrcdir              ${name}-${version}/src

checksums               sha1    7c55d2b72bb256dc99b18145644ae27edc9a056c \
                        rmd160  7ddf4f624be5d4c591096e85165cc6c5271e548b

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

use_configure           no

build.env               CXXFLAGS="${configure.cxx_archflags}" \
                        LDFLAGS="${configure.ld_archflags}"

build.args              IPEPREFIX=${prefix} \
                        ZLIB_CFLAGS="`pkg-config --cflags zlib`" \
                        ZLIB_LIBS="`pkg-config --libs zlib`" \
                        FREETYPE_CFLAGS="`pkg-config --cflags freetype2`" \
                        FREETYPE_LIBS="`pkg-config --libs freetype2`" \
                        CAIRO_CFLAGS="`pkg-config --cflags cairo`" \
                        CAIRO_LIBS="`pkg-config --libs cairo`" \
                        LUA_CFLAGS="`pkg-config --cflags lua`" \
                        LUA_LIBS="`pkg-config --libs lua`" \
                        QT_CFLAGS="`pkg-config --cflags QtGui QtCore`" \
                        QT_LIBS="`pkg-config --libs QtGui QtCore`" \
                        MOC=${qt_moc_cmd} \
                        CXX=${configure.cxx}

destroot.args-append    IPEPREFIX=${prefix}
use_parallel_build      no

platform macosx {
    depends_build-append port:makeicns
    post-destroot {
        set app Ipe
        xinstall -d ${destroot}${applications_dir}/${app}.app/Contents/MacOS \
            ${destroot}${applications_dir}/${app}.app/Contents/Resources
        xinstall -m 644 ${filespath}/Info.plist.in ${destroot}${applications_dir}/${app}.app/Contents/Info.plist
        reinplace "s|@VERSION@|${version}|g" ${destroot}${applications_dir}/${app}.app/Contents/Info.plist
        reinplace "s|@PREFIX@|${prefix}|g" ${destroot}${applications_dir}/${app}.app/Contents/Info.plist
        ln -s ${prefix}/bin/ipe ${destroot}${applications_dir}/${app}.app/Contents/MacOS/${app}
        system "${prefix}/bin/makeicns -in ${worksrcpath}/ipe/icons/ipe.png -out ${destroot}${applications_dir}/${app}.app/Contents/Resources/${name}.icns"
    }
}
