# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 68471 2010-06-04 09:16:10Z ryandesign@macports.org $

PortSystem  1.0

set realname    jpeg
version         6b
name            ${realname}${version}

categories  graphics
maintainers takeshi openmaintainer
description Library for manipulating JPEG images
long_description  \
  This distribution contains the sixth public release of the  \
  Independent JPEG Group's free JPEG software. You are welcome  \
  to redistribute this software and to use it for any purpose,  \
  subject to the conditions under LEGAL ISSUES, below.    \
  Serious users of this software (particularly those    \
  incorporating it into larger programs) should contact IJG at  \
  jpeg-info@uunet.uu.net to be added to our electronic mailing  \
  list.  Mailing list members are notified of updates and have  \
  a chance to participate in technical discussions, etc.

homepage        http://www.ijg.org/
platforms       darwin freebsd sunos
master_sites    http://distfiles.macports.org/${realname}/

distname        ${realname}src.v${version}
worksrcdir      ${realname}-${version}
set jpegmain    ${distname}${extract.suffix}
distfiles       ${jpegmain} \
                droppatch.tar.gz:drop
dist_subdir     ${realname}
                
checksums       ${jpegmain} md5 dbd5f3b47ed13132f04c685d608a7547 \
                droppatch.tar.gz md5 511c39779ac96cd41ca1e0a87b239287
extract.only    ${jpegmain}

patchfiles      patch-config.sub patch-config.guess patch-ltmain.sh \
                patch-ltconfig patch-makefile.cfg patch-jpeglib.h
post-patch {
    system "cd ${worksrcpath} &&
        tar zxf ${distpath}/droppatch.tar.gz"

    # Reorder link flags so that so that local -L options come first (especially before -L${prefix}/lib)
    #     (see http://trac.macports.org/ticket/16411).
    reinplace {s|\(.*\)\($(LDFLAGS)\)\(.*\)\($(LDLIBS)\)\(.*\)|\1\4\3\2\5|} ${worksrcpath}/makefile.cfg

    # As in the case of -L, CPPFLAGS come before -I. during compilation.
    configure.cppflags-append -isystem${prefix}/include
    configure.cppflags-delete -I${prefix}/include
}

configure.args      --prefix=${prefix}/lib/${name} --enable-shared --enable-static
if {![variant_isset universal]} {
    configure.ldflags-append   ${configure.cc_archflags}
}

use_parallel_build  yes

destroot.destdir    prefix=${destroot}${prefix}/lib/${name}
pre-destroot {
    xinstall -d ${destroot}${prefix}/lib/${name}/bin
    xinstall -d ${destroot}${prefix}/lib/${name}/share/man/man1
    xinstall -d ${destroot}${prefix}/lib/${name}/include
    xinstall -d ${destroot}${prefix}/lib/${name}/lib
}
