# $Id: Portfile,v 1.7 2005/08/25 19:16:01 gwright Exp $

PortSystem		1.0
name			squeak
version			3.8
categories		lang squeak
maintainers		darwinports@opendarwin.org
description		Full, portable, Smalltalk-80 system
long_description	\
 	Squeak is a full-featured implementation of the Smalltalk programming \
	language and environment based on (and largely compatible with) the \
	original Smalltalk-80 system.  Squeak has very powerful 2- and 3-D \
	graphics, sound, video, MIDI, animation and other multimedia \
	capabilities -- and one of the most impressive development \
	environments ever created.  It also includes a customisable framework \
	for creating dynamic HTTP servers and interactively extensible Web \
	sites.  The entire Squeak system is open source software, distributed \
	freely with a liberal license. 
platforms		darwin
homepage		http://www.squeak.org

master_sites		ftp://st.cs.uiuc.edu/Smalltalk/Squeak/${version}/ \
			ftp://st.cs.uiuc.edu/pub/Smalltalk/Squeak/3.8/unix-linux/:unix

set squeak_version	3.7-7
set squeak_img_version	3.8
set squeak_patch_no	6665
set squeak_src		SqueakV3.sources
set squeak_img		Squeak${squeak_img_version}-${squeak_patch_no}.image
set squeak_img_changes	Squeak${squeak_img_version}-${squeak_patch_no}.changes
set squeak_img_src	Squeak${squeak_img_version}-${squeak_patch_no}-basic.zip

distname		Squeak-${squeak_version}
distfiles		${distname}.src.tar.gz:unix ${squeak_src}.gz ${squeak_img_src}

checksums		${distname}.src.tar.gz md5 c6b051b745080516c550cab0db1882fc \
			${squeak_src}.gz md5 7dc6b3840e6bc1e5f81e3717fb46d2c3 \
			${squeak_img_src} md5 b41d6fa4fefb35fff3db37d9732af061

default_variants	+quartz

extract.only		${distname}.src.tar.gz
post-extract		{ file mkdir ${worksrcpath}/build }

configure.cmd		../platforms/unix/config/configure
configure.dir		${worksrcpath}/build
configure.args		--libdir=${prefix}/share --without-quartz --without-x

build.dir		${worksrcpath}/build
build.type		gnu

destroot.destdir	 ROOT=${destroot}

post-destroot {
	set unzip	"[binaryInPath "unzip"] -o"
	set gzip	"[binaryInPath "gzip"] -f"
	
	# Have inisqueak look for a specific version image
	reinplace	"s|IMAGE=squeak|IMAGE=squeak.${squeak_img_version}-${squeak_patch_no}|g" ${worksrcpath}/build/inisqueak
	reinplace	"s|CHANGES=squeak|CHANGES=squeak.${squeak_img_version}-${squeak_patch_no}|g" ${worksrcpath}/build/inisqueak

	# Install it
	xinstall	-m 755 ${worksrcpath}/build/inisqueak \
				${destroot}${prefix}/bin/
	
	# Now extract the image
	file		copy ${distpath}/${squeak_img_src} ${worksrcpath}
	file		copy ${distpath}/${squeak_src}.gz ${worksrcpath}
	system 		"cd ${worksrcpath} && ${unzip} ${squeak_img_src}"
	system 		"cd ${worksrcpath} && ${gzip} -d ${squeak_src}.gz"

	# And install the image
	xinstall 	-d ${destroot}${prefix}/share/squeak
	xinstall 	-m 644 ${worksrcpath}/${squeak_img} \
				${destroot}${prefix}/share/squeak/
	xinstall 	-m 644 ${worksrcpath}/${squeak_img_changes} \
				${destroot}${prefix}/share/squeak/
	xinstall	-m 644 ${worksrcpath}/${squeak_src} \
				${destroot}${prefix}/share/squeak/

	# And compress the image
	system		"cd ${destroot}${prefix}/share/squeak && ${gzip} ${squeak_img}"
	system		"cd ${destroot}${prefix}/share/squeak && ${gzip} ${squeak_img_changes}"

}

variant quartz	{ 
	configure.args-delete	--without-quartz 
	configure.args-append	--with-quartz
}

variant x11 	{ 
	depends_lib-append	lib:libX11:XFree86
	configure.args-delete	--without-x
	configure.args-append	--with-x 
}

