# $Id: Portfile,v 1.9 2005/07/28 20:54:06 ben Exp $

PortSystem 1.0
name			otcl
version			1.9
categories		lang
maintainers		ben@opendarwin.org
description		MIT Object Tcl
long_description	OTcl, short for MIT Object Tcl, is an extension to \
			Tcl/Tk for object-oriented programming. 
homepage		http://otcl-tclcl.sourceforge.net/otcl/
master_sites		sourceforge:otcl-tclcl:otcl \
			sourceforge:tcl:tcl
set tclmaj		8.4
set tclmin		9
dist_subdir		tcltk
set tclv		${tclmaj}.${tclmin}
distfiles		${name}-${version}.tar.gz:otcl \
			tcl${tclv}-src.tar.gz:tcl
checksums		${name}-${version}.tar.gz md5 d17331ef65912f43c530c57565f85600 \
                        tcl${tclv}-src.tar.gz md5 7e01b409925e4eb59ad44a4c12b9c681

depends_build		port:autoconf \
			port:automake

depends_lib		port:tcl \
			port:tk

patchfiles		conf_configure.in.fns.patch \
			conf_configure.in.Tcl.patch

pre-configure		{
			cd ${worksrcpath}
			system "${prefix}/bin/aclocal && ${prefix}/bin/autoconf"
}

configure.args		--with-Tcl=${prefix} --with-Tcl-ver=${tclmaj} \
			--with-tk=${prefix} --with-tk-ver=${tclmaj} \
			--prefix=${prefix} \
			CPPFLAGS='-I/usr/X11R6/include -I${workpath}/tcl${tclv}/generic/' \
			CFLAGS='-I/usr/X11R6/include -I${workpath}/tcl${tclv}/generic/' \
			LDFLAGS='-L/usr/X11R6/lib' \
			CC=/usr/bin/gcc-3.3 \
			CXX=/usr/bin/g++-3.3

post-configure          {
                        reinplace "s|-ltk8.4|-ltcl8.4 -ltk8.4|g" \
                                ${worksrcpath}/Makefile
                        reinplace "s|-lXext|-L/usr/X11R6/lib -lXext|g" \
                                ${worksrcpath}/Makefile
}

build.target		all

post-build		{
			system "/usr/bin/ranlib ${worksrcpath}/libotcl.a"
}

destroot		{
			cd ${worksrcpath}
			xinstall -m 0755 owish otclsh ${destroot}${prefix}/bin
			xinstall -m 0644 libotcl.a ${destroot}${prefix}/lib
			xinstall -m 0644 otcl.h ${destroot}${prefix}/include
}
