--- Portfile.orig	2009-12-10 18:22:03.000000000 +0100
+++ Portfile	2010-03-08 21:46:28.000000000 +0100
@@ -4,10 +4,12 @@
 
 name                        dcmtk
 version                     3.5.4_p2
+set unpatched_version       [lindex [split ${version} _] 0]
+set stripped_version        [string map {. ""} ${unpatched_version}]
+revision                    1
 categories                  graphics
 platforms                   darwin
-maintainers                 uni-koblenz.de:guidolorenz \
-                            openmaintainer
+maintainers                 nomaintainer
 description                 The DICOM Toolkit.
 long_description            DCMTK is a collection of libraries and applications implementing \
                             large parts of the DICOM standard. It includes software for examining, \
@@ -17,13 +19,23 @@
 
 homepage                    http://dicom.offis.de/dcmtk
 
-master_sites                ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/dcmtk354/ \
-                            http://dicom.offis.de/download/dcmtk/dcmtk354/
-distname                    dcmtk-3.5.4
-
-checksums                   md5 0afd971cdf976a5b336722ef2f68e6d7 \
-                            sha1 169056874947083e68eb941fcd53faaebc862ae5 \
-                            rmd160 d1558c9c68e53e0ea3b080fd2fb50b9d8e30eeba
+master_sites                ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/dcmtk${stripped_version}/:dcmtk \
+                            http://dicom.offis.de/download/dcmtk/dcmtk${stripped_version}/:dcmtk \
+                            ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/dcmtk${stripped_version}/patch/:patch \
+                            http://dicom.offis.de/download/dcmtk/dcmtk${stripped_version}/patch/:patch
+
+distname                    ${name}-${unpatched_version}
+distfiles                   ${distname}${extract.suffix}:dcmtk \
+                            dcmtk-3.5.4_p2.tar.gz:patch
+
+checksums                   ${distname}${extract.suffix} \
+                                md5 0afd971cdf976a5b336722ef2f68e6d7 \
+                                sha1 169056874947083e68eb941fcd53faaebc862ae5 \
+                                rmd160 d1558c9c68e53e0ea3b080fd2fb50b9d8e30eeba \
+                            dcmtk-3.5.4_p2.tar.gz \
+                                md5 d6df5f5c34291d44dd74d6fd0e146a23 \
+                                sha1 41c96c8054d3d74529a5b6f67552b2d5b9aea0c2 \
+                                rmd160 34c19b62c56b6242bf5ca75e620503c40895efb6
 
 depends_lib                 port:zlib \
                             port:tiff \
@@ -32,23 +44,23 @@
 
 destroot.target-append      install-lib
 
-# Apply changes made in ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/dcmtk354/patch/dcmtk-3.5.4_p2.tar.gz
-patchfiles                  patch-dcmnet-apps-findscu.cc.diff \
-                            patch-dcmnet-apps-movescu.cc.diff
-
-platform darwin 9 {
-	# See http://forum.dcmtk.org/viewtopic.php?t=1372
-	
-	patchfiles-append       patch-config-configure.in.diff
-	
-	post-patch {
-		# Usually, we would system "cd ${worksrcpath}/config && ./autoall" here, but due to a
-		# conflict with the MacPorts installation of autoconf, we must make sure that the
-		# original autoconf distrubuted with Leopard (from /usr/bin) is used.
-		system "cd ${worksrcpath}/config && /usr/bin/autoheader"
-		system "cd ${worksrcpath}/config && /usr/bin/autoconf"
-		system "cd ${worksrcpath}/config && /usr/bin/autoconf confmod.in > confmod"
-	}
+post-extract {
+    # Two files have to be replaced by patched ones from dcmtk-3.5.4_p2.tar.gz
+    move -force ${worksrcpath}_p2/dcmnet/apps/findscu.cc ${worksrcpath}/dcmnet/apps/findscu.cc
+    move -force ${worksrcpath}_p2/dcmnet/apps/movescu.cc ${worksrcpath}/dcmnet/apps/movescu.cc
+}
+
+# Darwin 9+10 compatibility, see http://forum.dcmtk.org/viewtopic.php?t=1372
+patchfiles                  patch-config-configure.in.diff
+
+post-patch {
+    # After patching config/configure.in, autotools have to be run again.
+    # Usually, we would system "cd ${worksrcpath}/config && ./autoall" here,
+    # but due to a conflict with the MacPorts version of autoconf, we must
+    # make sure that autoconf from /usr/bin is used.
+    system "cd ${worksrcpath}/config && /usr/bin/autoheader"
+    system "cd ${worksrcpath}/config && /usr/bin/autoconf"
+    system "cd ${worksrcpath}/config && /usr/bin/autoconf confmod.in > confmod"
 }
 
 use_parallel_build          no
