# $Id: Portfile 91184 2012-03-25 08:25:43Z jeremyhu@macports.org $
PortSystem      1.0

name                    blt
version                 2.4z
revision		3
categories              x11
maintainers             markd
description             BLT is an extension to the Tk toolkit, adding new widgets, \
			geometry managers, and miscellaneous commands.
long_description        ${description}
  
homepage                http://blt.sourceforge.net/
platforms               darwin

master_sites            sourceforge
distname		BLT${version}
worksrcdir		blt${version}
checksums               md5 aa2ed73080f3005d9c2a3b5e57ab1eff

depends_build           port:xorg-libX11 \
			port:tcl \
			port:tk

# Project bug
# http://trac.macports.org/ticket/32599
if {${configure.compiler} == "clang"} {
    configure.compiler llvm-gcc-4.2
}

configure.cppflags	"-L${prefix}/lib"
configure.cflags	"-O3 -fno-common"

configure.args		--exec_prefix=${prefix} \
			--bindir=${prefix}/bin \
			--includedir=${prefix}/include \
			--libdir=${prefix}/lib \
			--with-tcllibs=${prefix}/lib \
			--with-tklibs=${prefix}/lib \
			--with-tclincls=${prefix}/include \
			--with-tkincls=${prefix}/include \
                        --with-tcl=${prefix} \
                        --with-tk=${prefix}

patchfiles		patch-configure \
			patch-Makefile.in \
			patch-library-Makefile.in \
			patch-src-Makefile.in \
			patch-src-shared-Makefile.in \
			patch-library-pkgIndex.tcl.in \
			patch-demos-Makefile.in \
			blt-2.4z-tcl8.5-fix.patch \
			blt2.4z-noexactversion.patch \
			blt-x86_64.patch

post-patch {
        reinplace "s|__DESTROOT__|${destroot}|g" \
                ${worksrcpath}/Makefile.in \
		${worksrcpath}/src/Makefile.in \
		${worksrcpath}/src/shared/Makefile.in \
		${worksrcpath}/demos/Makefile.in

	eval reinplace "s|../src/bltwish|${prefix}/bin/bltwish|g" \
                [glob ${worksrcpath}/demos/*.tcl] \
		[glob ${worksrcpath}/demos/scripts/*.tcl]
}

post-destroot {
	system "cd ${destroot}${prefix}/lib && ln -sf libBLT.2.4.dylib libBLT.2.dylib"
	system "cd ${destroot}${prefix}/lib && ln -sf libBLT.2.4.dylib libBLT.dylib"
	system "cd ${destroot}${prefix}/lib && ln -sf libBLTlite.2.4.dylib libBLTlite.2.dylib"
	system "cd ${destroot}${prefix}/lib && ln -sf libBLTlite.2.4.dylib libBLTlite.dylib"
}
