# $Id: Portfile 54133 2009-07-21 21:18:07Z toby@macports.org $

PortSystem 1.0
PortGroup  muniversal 1.0

name		tiff
version		3.8.2
revision    3
categories	graphics
maintainers	waqar
description	Library and tools for dealing with Tag Image File Format
long_description \
	This software provides support for the Tag Image File 		\
	Format (TIFF), a widely used format for storing image 		\
	data.  Included in this software distribution is a 		\
	library, libtiff, for reading and writing TIFF, a small 	\
	collection of tools for doing simple manipulations of 		\
	TIFF images on UNIX systems, documentation on the library 	\
	and tools.  A small assortment of TIFF-related software 	\
	for UNIX that has been contributed by others is also 		\
	included.  The library is capable of dealing with images 	\
	that are written to follow the 5.0 or 6.0 TIFF spec. 		\
	There is also considerable support for some of the more 	\
	esoteric portions of the 6.0 TIFF spec.
homepage	http://www.remotesensing.org/libtiff
platforms	darwin
master_sites	ftp://ftp.remotesensing.org/pub/libtiff/ \
		http://dl.maptools.org/dl/libtiff/ \
		freebsd

checksums   md5 fbb6f446ea4ed18955e2714934e5b698 \
            sha1 549e67b6a15b42bfcd72fe17cda7c9a198a393eb \
            rmd160 1b4d825e3be08764e953fc58246d0c25ab4dd17d

# Turn on OpenGL with --with-apple-opengl-framework.
patchfiles      patch-configure.diff

depends_lib	port:jpeg port:zlib

test.run        yes
test.target     check

configure.args	--mandir=${prefix}/share/man \
                --with-docdir=${prefix}/share/doc/${name}-${version} \
		--with-jpeg-include-dir=${prefix}/include \
		--with-jpeg-lib-dir=${prefix}/lib \
		--with-zlib-include-dir=${prefix}/include \
		--with-zlib-lib-dir=${prefix}/lib

use_parallel_build  yes

post-destroot {
	xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
	file copy ${worksrcpath}/html/images \
		${destroot}${prefix}/share/doc/${name}
	eval xinstall -m 644 [glob ${worksrcpath}/html/*.html] \
		${destroot}${prefix}/share/doc/${name}
}

platform macosx {
    if { ![variant_isset universal] } {
        configure.args-append   --with-apple-opengl-framework
    } else {
        # Tiger does not have 64-bit OpenGL.
        if { ${os.major} > 8 } {
            configure.args-append   --with-apple-opengl-framework
        } else {
            global merger_configure_args
            array set merger_configure_args {
                ppc  --with-apple-opengl-framework
               i386  --with-apple-opengl-framework
            }
        }
    }
    pre-extract {
        if {9 == ${os.major}} {
            # http://developer.apple.com/qa/qa2007/qa1567.html
            set minimum_xcodeversion 3.1
            set current_xcodeversion [exec defaults read [exec xcode-select -print-path]/Applications/Xcode.app/Contents/Info CFBundleShortVersionString]
            if {[rpm-vercomp ${current_xcodeversion} ${minimum_xcodeversion}] < 0} {
                ui_msg "On Mac OS X ${macosx_version}, ${name} ${version} requires Xcode ${minimum_xcodeversion} or later but you have Xcode ${current_xcodeversion}."
                return -code error "incompatible Xcode version"
            }
        }
    }
}

livecheck.check regex
livecheck.url   http://www.remotesensing.org/libtiff/
livecheck.regex {v(\d+(?:\.\d+)*)</a>}
