# $Id: Portfile,v 1.5 2006/06/11 17:30:43 markd Exp $

PortSystem 1.0
name			itk
version			3.3
revision		2
categories		x11 tk
maintainers		darwinports@opendarwin.org
description		\[incr Tk\] A.K.A. \"itk\".  Object oriented extension to Tk.
platforms		darwin
master_sites		sourceforge:incrtcl:itk \
			http://www.opendarwin.org/~markd/:tclpheaders
distname                ${portname}${portversion}
distfiles		${distname}.tar.gz:itk \
			tcl8.4.12-privateheaders-full.tar.gz:tclpheaders
checksums		${portname}${portversion}.tar.gz md5 a97c17f3cfa5e377f43073c653c501b5 \
			tcl8.4.12-privateheaders-full.tar.gz md5 ec9b85fad111b51b746fe45a2dc1e8fb
depends_build           port:tk port:itcl
build.args              CPPFLAGS=-I${prefix}/include
worksrcdir              ${portname}${portversion}

set tclconfig ${prefix}/lib
configure.args		--with-tcl=${tclconfig} \
			--with-itcl=${prefix}/lib/itcl3.3 \
			--with-tk=${prefix}/lib

configure.env		TCLROOT=${prefix} \
			CFLAGS=-I${workpath}/tcl8.4.12-privateheaders-full/generic \
			LDFLAGS="-L${prefix}/lib -ltcl -L/usr/X11R6/lib -lX11"

platform darwin 7 {
	global tclconfig

	set tclconfig /System/Library/Frameworks/Tcl.framework
}

post-patch {
	reinplace "s|@itk_LIB_SPEC@|-L${prefix}/lib -litk|g" \
                ${worksrcpath}/itkConfig.sh.in
	reinplace "s|@ITK_BUILD_LIB_SPEC@|-L${prefix}/lib -litk|g" \
                ${worksrcpath}/itkConfig.sh.in
	reinplace "s|\"@PKG_LIB_FILE@\"|.. @PKG_LIB_FILE@|g" \
                ${worksrcpath}/pkgIndex.tcl.in
}

destroot {
	set _d ${destroot}${prefix}
	set _w ${worksrcpath}
	file mkdir -p ${_d}/lib/itk3.3
	xinstall -m 755 ${_w}/itkConfig.sh ${_d}/lib/itk3.3

	foreach x [glob ${worksrcpath}/library/*] {
		file copy -force $x ${_d}/lib/itk3.3
        }
	file copy -force ${_w}/pkgIndex.tcl ${_d}/lib/itk3.3

	file copy -force ${_w}/libitk3.3.dylib ${_d}/lib

	file mkdir -p ${_d}/include
	foreach x {itk.h itkDecls.h } {
                file copy -force ${_w}/generic/$x ${_d}/include
        }
	foreach x [glob ${_w}/doc/*.n] {
		file copy -force $x ${_d}/share/man/mann
	file delete -force ${_d}/share/man/mann/Toplevel.n
	}
}
