# $Id: Portfile 30204 2007-10-22 21:05:01Z jmpp@macports.org $

PortSystem 1.0

name	   amsn
version	   0.94
revision   3
categories	net
platforms	darwin
maintainers	jmpp openmaintainer

description	Alvaro's Messenger, or Another MSN messenger clone.
long_description	Multiplatform TCL/TK based clone of the original MSN Messenger client, \
			having the same look and feel. Additional features exist, such as \
			on event alarms, history, skins, etc.

set	release 0_94
set	TclTkVers 8.4.9
set	TlsVers 1.5.0
set	TlsRelease 1.5

homepage	http://amsn.sourceforge.net
master_sites	sourceforge \
		http://www.opendarwin.org/~jmpp/miscellaneous/:plugins
distname	${name}-${release}
distfiles	${distname}${extract.suffix} \
		${distname}_plugins${extract.suffix}:plugins		
checksums	${distname}${extract.suffix} md5 7b7db9225342bb6c59b873ec90882e22 \
		${distname}_plugins${extract.suffix} md5 82d91b516b4dbe19eb3168de4a481c5f

depends_lib	port:tk port:tcl-tls

use_configure	no

build		{}

destroot	{
		file copy ${worksrcpath} ${destroot}${prefix}/share
		foreach dir [glob -directory ${workpath}/${distname}_plugins -type d *] {
			file copy $dir ${destroot}${prefix}/share/${distname}/plugins
		}
		system "ln -s ${prefix}/share/${distname}/amsn ${destroot}${prefix}/bin/amsn"
}


variant	aqua	{
		distfiles-append	tcl${TclTkVers}-src${extract.suffix}:tcl \
					tk${TclTkVers}-src${extract.suffix}:tk \
					tls${TlsVers}-src${extract.suffix}:tls

		master_sites-append	sourceforge:tcl:tcl \
					sourceforge:tcl:tk \
					sourceforge:tls:tls

		checksums-append	tcl${TclTkVers}-src${extract.suffix} md5 7e01b409925e4eb59ad44a4c12b9c681 \
					tk${TclTkVers}-src${extract.suffix} md5 1b64258abaf258e9a86f331d8de17a71 \
					tls${TlsVers}-src${extract.suffix} md5 9eeab472475773b3810acc808ebec759

		depends_lib-append	port:openssl
		
		worksrcdir	tls${TlsRelease}

		patchfiles	patch-Makefile.in.diff

		use_configure	yes
		configure.args	--with-ssl-dir=${prefix}

		build {
		      system "${build.cmd} -C ${workpath}/tls${TlsRelease} all"
		      system "${build.cmd} -C ${workpath}/tls${TlsRelease} install DESTDIR=${destroot.destdir}"
		      system "${build.cmd} -C ${workpath}/tcl${TclTkVers}/macosx embedded"
		      system "${build.cmd} -C ${workpath}/tk${TclTkVers}/macosx embedded"
		      system "${build.cmd} -C ${workpath}/tcl${TclTkVers}/macosx install-embedded \
		      INSTALL_ROOT=${workpath}/embedded"
		      system "${build.cmd} -C ${workpath}/tk${TclTkVers}/macosx install-embedded \
		      INSTALL_ROOT=${workpath}/embedded"
		}

destroot {
	xinstall -d -m 755 ${destroot}/Applications/MacPorts
	file rename "${workpath}/embedded/Applications/Utilities/Wish\ Shell.app" \
	"${destroot}/Applications/MacPorts/aMSN.app"
	file rename ${workpath}/${distname} \
	${destroot}/Applications/MacPorts/aMSN.app/Contents/Resources/Scripts
	foreach dir [glob -directory ${workpath}/${distname}_plugins -type d *] {
		file copy $dir ${destroot}/Applications/MacPorts/aMSN.app/Contents/Resources/Scripts/plugins
	}
	xinstall -d -m 755 \
	${destroot}/Applications/MacPorts/aMSN.app/Contents/Resources/Scripts/plugins/tls${TlsRelease}0
	xinstall -m 644 ${worksrcpath}/DESTDIR\=${destroot}${prefix}/lib/libtls${TlsRelease}0.dylib \
	${destroot}/Applications/MacPorts/aMSN.app/Contents/Resources/Scripts/plugins
	xinstall -m 644 -v -W ${worksrcpath}/DESTDIR\=${destroot}${prefix}/lib/tls${TlsRelease}0 pkgIndex.tcl tls.tcl \
	${destroot}/Applications/MacPorts/aMSN.app/Contents/Resources/Scripts/plugins/tls${TlsRelease}0
	file copy -force ${filespath}/Info.plist ${destroot}/Applications/MacPorts/aMSN.app/Contents/
	file copy -force ${filespath}/Wish.icns ${destroot}/Applications/MacPorts/aMSN.app/Contents/Resources/
	}

## The "extras" variant of the Growl port is not yet in place, therefore this is commented out until then.
#post-activate	{
#		ui_msg "\nPlease install the Growl port with the \"extras\" variant
#in order to have a working Growl aMSN plugin"
#		}

}
