# $Id: Portfile,v 1.11 2006/06/11 17:33:37 markd Exp $

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

set tclconfig ${prefix}/lib
configure.args		--with-tcl=${tclconfig} --with-tk=${prefix}/lib
configure.env		TCLROOT=${prefix} \
			CFLAGS=-I${workpath}/tcl8.4.12-privateheaders-full/generic \
			LDFLAGS="-L${prefix}/lib -tcl8.4"

platform darwin 7 {
	global tclconfig

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

post-patch {
	reinplace "s|@itcl_LIB_FILE@|${prefix}/lib/libitcl3.3.dylib|g" \
               ${worksrcpath}/itclConfig.sh.in
	reinplace "s|@PACKAGE_VERSION@|3.3|g" \
                ${worksrcpath}/itclConfig.sh.in
	reinplace "s|@itcl_BUILD_LIB_SPEC@|-L${prefix}/lib -litcl|g" \
                ${worksrcpath}/itclConfig.sh.in
	reinplace "s|@itcl_LIB_SPEC@|-L${prefix}/lib -litcl|g" \
                ${worksrcpath}/itclConfig.sh.in
	reinplace "s|\"@PKG_LIB_FILE@\"|.. @PKG_LIB_FILE@|g" \
		${worksrcpath}/pkgIndex.tcl.in
}

post-build {
                system "ranlib ${worksrcpath}/libitclstub3.3.a"
}

destroot {
	set _d ${destroot}${prefix}
	set _w ${worksrcpath}
	file mkdir -p ${_d}/lib/itcl3.3
	xinstall -m 755 ${_w}/itclConfig.sh ${_d}/lib/itcl3.3
	file copy -force ${_w}/pkgIndex.tcl ${_d}/lib/itcl3.3
	file copy -force ${_w}/library/itcl.tcl ${_d}/lib/itcl3.3
	file copy -force ${_w}/libitcl3.3.dylib ${_d}/lib
	file copy -force ${_w}/libitclstub3.3.a ${_d}/lib

	file mkdir -p ${_d}/include
        foreach x {itcl.h itclDecls.h itclInt.h itclIntDecls.h } {
                file copy -force ${_w}/generic/$x ${_d}/include
        }

	foreach x [glob ${_w}/doc/*.n] {
		file copy -force $x ${_d}/share/man/mann
	}
}
