# $Id: Portfile 55691 2009-08-17 07:15:43Z ryandesign@macports.org $

PortSystem              1.0

name                    dcraw
version                 8.96-20090814020300
set version_number      [lindex [split ${version} -] 0]
categories              graphics
maintainers             ryandesign
platforms               darwin
homepage                http://www.cybercom.net/~dcoffin/dcraw/
master_sites            ${homepage}archive/
distname                ${name}-${version_number}
worksrcdir              $name
dist_subdir             ${name}/${version}
use_parallel_build      yes

description \
    Digital camera raw photo decoding software supporting hundreds of cameras

long_description \
    ${name} is a small program for processing raw, unprocessed CCD data \
    files from any of hundreds of digital cameras with better quality output \
    than the tools provided by camera vendors.

checksums \
    md5     9b852e81319066a5473ae52eb507cd79 \
    sha1    e1ba28918516c576c4b9a363351161ceacdb3403 \
    rmd160  2390892aba8fbf1e3061337752fa1151058638fd

depends_lib \
    port:gettext \
    port:libiconv \
    port:jpeg \
    port:lcms

post-extract {
    xinstall -W ${filespath} Makefile.in ${worksrcpath}/Makefile
}

configure {
    reinplace "s|@CC@|${configure.cc}|g" ${worksrcpath}/Makefile
    reinplace "s|@CFLAGS@|${configure.cflags}|g" ${worksrcpath}/Makefile
    reinplace "s|@CPPFLAGS@|${configure.cppflags}|g" ${worksrcpath}/Makefile
    reinplace "s|@LDFLAGS@|${configure.ldflags}|g" ${worksrcpath}/Makefile
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/Makefile
}

set my_locales          {eo ru fr it de pt es zh_TW zh_CN nl pl hu ca cs sv}

post-destroot {
    xinstall -m 644 -W ${worksrcpath} dcraw.1 ${destroot}${prefix}/share/man/man1
    foreach locale ${my_locales} {
        if {[file exist ${worksrcpath}/dcraw_${locale}.1]} {
            xinstall -m 755 -d ${destroot}${prefix}/share/man/${locale}/man1
            xinstall -m 644 -W ${worksrcpath} dcraw_${locale}.1 ${destroot}${prefix}/share/man/${locale}/man1/dcraw.1
        }
        if {[file exist ${worksrcpath}/build/dcraw_${locale}.mo]} {
            xinstall -m 755 -d ${destroot}${prefix}/share/locale/${locale}/LC_MESSAGES
            xinstall -m 644 -W ${worksrcpath}/build dcraw_${locale}.mo ${destroot}${prefix}/share/locale/${locale}/LC_MESSAGES/dcraw.mo
        }
    }
}

pre-activate {
    ui_msg "This port conflicts with ufraw. If this port fails to"
    ui_msg "activate, uninstall or deactivate ufraw and attempt to"
    ui_msg "activate this port again."
}

livecheck.check         regex
livecheck.url           http://www.ryandesign.com/macports/version.php/${name}
livecheck.regex         (.*)
