# $Id: Portfile 67316 2010-05-05 11:20:49Z ryandesign@macports.org $

PortSystem 1.0

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                 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, \
                            constructing and converting DICOM image files, handling offline \
                            media, sending and receiving images over a network connection, as \
                            well as demonstrative image storage and worklist servers.

homepage                    http://dicom.offis.de/dcmtk

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 \
                            port:libpng \
                            port:libxml2 \
                            port:openssl

destroot.target-append      install-lib

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
