# $Id: Portfile,v 1.16 2005/12/30 22:26:41 yves Exp $
PortSystem 1.0
name            netpbm
version         10.31
categories      graphics
maintainers     yves@opendarwin.org
description     Image manipulation
long_description \
    A whole bunch of utilities for primitive manipulation \
    of graphic images.  Wide array of converters from one \
    graphics format to another.  E.g. from g3 fax format to \
    jpeg.  Many basic graphics editing tools such as \
    magnifying and cropping.

homepage        http://netpbm.sourceforge.net/
master_sites    sourceforge:netpbm
platforms       darwin

depends_lib     port:zlib port:jpeg port:tiff \
                port:libpng port:jasper
extract.suffix  .tgz
checksums       md5 6ba2e0ee998eb23f4620ec9c175a90b6

set gcc-suffix ""
patchfiles      patch-lib-Makefile

post-fetch {
    if {![catch {set is_installed [registry_installed ${name}]} result]} {
        ui_msg "##################################################################################"
        ui_msg "    If you are upgrading from a previous netpbm version,"
        ui_msg "    using the 'port upgrade' command will sometimes miserably fail"
        ui_msg "    Please use the following commands instead :"
        ui_msg "        port deactivate netpbm"
        ui_msg "        port install netpbm"
        ui_msg "##################################################################################"
    }
}

configure {
    system "cd ${worksrcpath} &&
        cat Makefile.config.in ${filespath}/Makefile.config.darwin |
        sed -e '/@PREFIX@/s@@${prefix}@' -e '/@GCC_SUFFIX@/s@@${gcc-suffix}@' \
            > Makefile.config";
}

build.args    "messages=yes"
build.target  ""

destroot {
    file delete -force ${destroot}${prefix}
    system "cd ${worksrcpath} && make package pkgdir=${destroot}${prefix}"
    xinstall -m 755 -d ${destroot}${prefix}/share/netpbm
    system "cd ${destroot}${prefix} &&
        mv bin/doc.url misc/* share/netpbm &&
        mv man share &&
        rm -rf README VERSION config_template link misc pkginfo share/man/web"
}

# work around bug in Apple's gcc build 4061
platform darwin 8 {
    set fl [open "| gcc --version"]
    set data [read $fl]
    if {[regexp "build 4061" $data]} {
        set gcc-suffix "-3.3"
    }
}
