--- Portfile.orig	2011-10-25 00:29:59.000000000 +0200
+++ Portfile	2011-10-25 00:28:49.000000000 +0200
@@ -1,10 +1,10 @@
+# -*- 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 82514 2011-08-15 05:11:11Z ryandesign@macports.org $
 
 PortSystem 1.0
 
 name                    ipe-tools
-version                 20110116
-revision                1
+version                 20110916
 categories              graphics
 maintainers             jacobs-university.de:m.thon
 description             Tools for the Ipe extensible drawing editor
@@ -15,25 +15,26 @@
                         - 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       20110116
+set pdftoipe-vers       20110916
 set figtoipe-vers       20091205
 set ipe5toxml-vers      20051114
 
 distfiles               svgtoipe-${svgtoipe-vers}${extract.suffix} \
-                        pdftoipe-${pdftoipe-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}${extract.suffix} \
-                            sha1    6e4a7072e5bd05f941f8d3a0aab92ab1d3bb6aab \
-                            rmd160  3210a1d5889299cb2b6ae8fa45af960ea080d06a \
+                        pdftoipe-${pdftoipe-vers}-src${extract.suffix} \
+                            sha1    2cd4f70ebafa0310bbc3a0217f7d6acad2eda10f \
+                            rmd160  67d27456a1f7e46aa27eb67054c91ad52f51b0c3 \
                         figtoipe-${figtoipe-vers}${extract.suffix} \
                             sha1    b81f2f0cc568e165bdedb618ced9384ebfcb19a3 \
                             rmd160  cc1615b55313ab8c151565bdb498fff8ba945029 \
@@ -41,9 +42,12 @@
                             sha1    23cb8b40f1aa8a9bc4904d295b08fe0293cda7fc \
                             rmd160  44c22367e3ef3cb4607310d15af51f527b006be0
 
+worksrcdir              .
+patchfiles              patch-pdftoipe-${pdftoipe-vers}-src-xmloutputdev.cpp.diff
+
 depends_build           port:pkgconfig
-depends_lib             port:poppler \
-                        port:py26-pil
+depends_lib             port:poppler
+
 use_configure           no
 use_parallel_build      no
 
@@ -56,14 +60,34 @@
 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} && ${build.env} CC=${configure.cxx} ${build.cmd} ${build.target}"
+        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}/pdftoipe ${destroot}${prefix}/bin
-        xinstall -m 644 ${workpath}/pdftoipe-${pdftoipe-vers}/pdftoipe.1 ${destroot}${prefix}/share/man/man1
+        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 Python 2.4} {
+    depends_lib-append port:py24-pil
+}
+
+variant python25 conflicts python24 python26 python27 description {Use PIL from Python 2.5} {
+    depends_lib-append port:py25-pil
+}
+
+variant python26 conflicts python24 python25 python27 description {Use PIL from Python 2.6} {
+    depends_lib-append port:py26-pil
+}
+
+variant python27 conflicts python24 python25 python26 description {Use PIL from Python 2.7} {
+    depends_lib-append port:py27-pil
+}
+
+if {![variant_isset python24] && ![variant_isset python25] && ![variant_isset python26] && ![variant_isset python27]} {
+    default_variants +python27
+}
