# -*- 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 87500 2011-11-23 21:39:48Z devans@macports.org $

PortSystem 1.0

name                    ipe-tools
version                 20110916
revision                1
categories              graphics
maintainers             jacobs-university.de:m.thon
description             Tools for the Ipe extensible drawing editor
long_description        \
                        The following tools for the Ipe extensible drawing \
                        editor are provided: \
                        - svgtoipe \
                        - pdftoipe \
                        - figtoipe \
                        - ipe5toxml
license                 {GPL-2 GPL-3}
homepage                http://ipe7.sourceforge.net/
master_sites            sourceforge:project/ipe7/tools
platforms               darwin
set svgtoipe-vers       20100608
set pdftoipe-vers       20110916
set figtoipe-vers       20091205
set ipe5toxml-vers      20051114

distfiles               svgtoipe-${svgtoipe-vers}${extract.suffix} \
                        pdftoipe-${pdftoipe-vers}-src${extract.suffix} \
                        figtoipe-${figtoipe-vers}${extract.suffix} \
                        ipe5toxml-${ipe5toxml-vers}${extract.suffix}

checksums               svgtoipe-${svgtoipe-vers}${extract.suffix} \
                            sha1    7c7af21eaa7273f74ac44570bbc659f674e01322 \
                            rmd160  7c39ad574e9add8e2b660e29a2e6ed80ebe533b3 \
                        pdftoipe-${pdftoipe-vers}-src${extract.suffix} \
                            sha1    2cd4f70ebafa0310bbc3a0217f7d6acad2eda10f \
                            rmd160  67d27456a1f7e46aa27eb67054c91ad52f51b0c3 \
                        figtoipe-${figtoipe-vers}${extract.suffix} \
                            sha1    b81f2f0cc568e165bdedb618ced9384ebfcb19a3 \
                            rmd160  cc1615b55313ab8c151565bdb498fff8ba945029 \
                        ipe5toxml-${ipe5toxml-vers}${extract.suffix} \
                            sha1    23cb8b40f1aa8a9bc4904d295b08fe0293cda7fc \
                            rmd160  44c22367e3ef3cb4607310d15af51f527b006be0

worksrcdir              .
patchfiles              patch-pdftoipe-${pdftoipe-vers}-src-xmloutputdev.cpp.diff \
                        patch-svgtoipe-python_path.diff

depends_build           port:pkgconfig
depends_lib             port:poppler

use_configure           no
use_parallel_build      no

eval build.env          CPPFLAGS+='${configure.cppflags}' \
                        CFLAGS+='${configure.cppflags} ${configure.cflags} ${configure.cc_archflags}' \
                        CXXFLAGS+='${configure.cxxflags} ${configure.cxx_archflags}' \
                        LDFLAGS+='${configure.cc_archflags}' \
                        CC=${configure.cc} CXX=${configure.cxx}

build {
        system "cd ${workpath}/figtoipe-${figtoipe-vers} && ${build.env} ${build.cmd} ${build.target} CXX=${configure.cxx}"
        system "cd ${workpath}/ipe5toxml && ${build.env} ${build.cmd}"
        system "cd ${workpath}/pdftoipe-${pdftoipe-vers}-src && ${build.env} CC=${configure.cxx} ${build.cmd} ${build.target}"
}

destroot {
        xinstall -m 755 ${workpath}/figtoipe-${figtoipe-vers}/figtoipe ${destroot}${prefix}/bin
        xinstall -m 644 ${workpath}/figtoipe-${figtoipe-vers}/figtoipe.1 ${destroot}${prefix}/share/man/man1
        xinstall -m 755 ${workpath}/ipe5toxml/ipe5toxml ${destroot}${prefix}/bin
        xinstall -m 755 ${workpath}/pdftoipe-${pdftoipe-vers}-src/pdftoipe ${destroot}${prefix}/bin
        xinstall -m 644 ${workpath}/pdftoipe-${pdftoipe-vers}-src/pdftoipe.1 ${destroot}${prefix}/share/man/man1
        xinstall -m 755 ${workpath}/svgtoipe-${svgtoipe-vers}/svgtoipe ${destroot}${prefix}/bin
}

variant python24 conflicts python25 python26 python27 description {Use PIL from MacPorts Python 2.4} {
    depends_lib-append port:py24-pil
    post-patch {
        reinplace "s|__MP_PYTHON_BIN__|${prefix}/bin/python2.4|" ${workpath}/svgtoipe-${svgtoipe-vers}/svgtoipe
    }
}

variant python25 conflicts python24 python26 python27 description {Use PIL from MacPorts Python 2.5} {
    depends_lib-append port:py25-pil
    post-patch {
        reinplace "s|__MP_PYTHON_BIN__|${prefix}/bin/python2.5|" ${workpath}/svgtoipe-${svgtoipe-vers}/svgtoipe
    }
}

variant python26 conflicts python24 python25 python27 description {Use PIL from MacPorts Python 2.6} {
    depends_lib-append port:py26-pil
    post-patch {
        reinplace "s|__MP_PYTHON_BIN__|${prefix}/bin/python2.6|" ${workpath}/svgtoipe-${svgtoipe-vers}/svgtoipe
    }
}

variant python27 conflicts python24 python25 python26 description {Use PIL from MacPorts Python 2.7} {
    depends_lib-append port:py27-pil
    post-patch {
        reinplace "s|__MP_PYTHON_BIN__|${prefix}/bin/python2.7|" ${workpath}/svgtoipe-${svgtoipe-vers}/svgtoipe
    }
}

if {![variant_isset python24] && ![variant_isset python25] && ![variant_isset python26] && ![variant_isset python27]} {
    default_variants +python27
}

livecheck.type  regex
livecheck.url   http://sourceforge.net/projects/ipe7/files/tools/
livecheck.regex "to(?:ipe|xml)-(\[0-9\]*)"
