# $Id: Portfile 91510 2012-04-03 21:59:59Z jeremyhu@macports.org $

PortSystem 1.0

name			itcl
version			3.4b1
categories		lang
license			Tcl/Tk
maintainers		nomaintainer
description		Object oriented extension to Tcl.
long_description	${description}
homepage		http://incrtcl.sourceforge.net/
platforms		darwin
master_sites		sourceforge:incrtcl:itcl \
			sourceforge:tcl:tcl
dist_subdir		tcltk
distname                ${name}${version}
# Set tclv and md5 checksum to the current MacPorts Tcl port version, though port doesn't
# break if they aren't in sync.

set tclv		8.5.9

distfiles		${distname}.tar.gz:itcl \
				tcl${tclv}-src.tar.gz:tcl
checksums		${distname}.tar.gz md5 e4c97750c08ab47e960b91911fdd0132 \
				tcl${tclv}-src.tar.gz md5 8512d8db3233041dd68a81476906012a
depends_build           port:tcl port:tk
build.args		CPPFLAGS=-I${prefix}/include
worksrcdir              ${name}3.4

configure.env		TCLROOT=${prefix}
configure.cflags	"-I${workpath}/tcl${tclv}/generic -I${workpath}/tcl${tclv}/unix"
configure.ldflags-append	"-tcl8.5"

configure.args		--with-tcl=${prefix}/lib

configure.universal_args-delete	--disable-dependency-tracking

post-patch {
	reinplace "s|@itcl_LIB_FILE@|${prefix}/lib/libitcl3.4.dylib|g" \
               ${worksrcpath}/itclConfig.sh.in
	reinplace "s|@PACKAGE_VERSION@|3.4|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.4.a"
}

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

	file mkdir ${_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
	}
}
