# $Id: Portfile,v 1.24 2006/06/09 23:18:02 blair Exp $

PortSystem 1.0
name		xemacs
version		21.4.17
revision	3
categories	editors
maintainers	darwinports@opendarwin.org
description	A highly customizable open source text editor.
long_description \
		 XEmacs is a highly customizable open source text editor and \
		 application development system. It is protected under the \
		 GNU Public License and related to other versions of Emacs, \
		 in  particular GNU Emacs.
platforms	darwin
homepage	http://www.xemacs.org
master_sites	ftp://ftp.us.xemacs.org/pub/xemacs/xemacs-21.4/:stable \
		http://ftp.us.xemacs.org/ftp/pub/xemacs/xemacs-21.4/:stable \
		http://mirrors.mix5.com/xemacs/xemacs-21.4/:stable \
		http://www.binarycode.org/xemacs/xemacs-21.4/:stable \
		ftp://ftp.us.xemacs.org/pub/xemacs/xemacs-21.5/:beta \
		http://ftp.us.xemacs.org/ftp/pub/xemacs/xemacs-21.5/:beta \
		http://mirrors.ibiblio.org/pub/mirrors/xemacs/xemacs-21.5/:beta \
		http://mirrors.mix5.com/xemacs/xemacs-21.5/:beta \
		http://www.online-mirror.org/xemacs/xemacs-21.5/:beta \
                http://members.shaw.ca/akochoi-xemacs/diff/:carbonport \
		http://members.shaw.ca/akochoi-xemacs/diff/:toolbarpatch \
		ftp://ftp.us.xemacs.org/pub/xemacs/packages/:sumo \
                http://ftp.us.xemacs.org/ftp/pub/xemacs/packages/:sumo \
                http://mirrors.ibiblio.org/pub/mirrors/xemacs/packages/:sumo \
                http://mirrors.mix5.com/xemacs/packages/:sumo \
                http://www.online-mirror.org/xemacs/packages/:sumo

distfiles       ${name}-${version}-src${extract.suffix}:stable

checksums	${name}-${version}-src${extract.suffix} \
		md5 3a05a0fab0dd9bed9df4a3dceb4da97f

configure.args	--with-dialogs=athena --with-widgets=athena --with-athena=3d \
		--without-postgresql --without-ldap --with-sound=none --pdump \
		--site-prefixes=${prefix} --with-tty

depends_lib	lib:libpng.3:libpng lib:libXaw3d.7:Xaw3d

destroot.args   prefix=${destroot}/${prefix}

set xemacs_lib  ${destroot}${prefix}/lib/xemacs-${version}
set pkg_contents "etc info lisp man pkginfo"

post-destroot {
	ui_info "Installing packages into destroot"

	destroot.keepdirs ${destroot}${prefix}/lib/xemacs
	xinstall -d ${xemacs_lib}/xemacs-packages

	system "tar -cpf - -C ${worksrcpath}/.. ${pkg_contents} | \
		tar -xpf - -C ${xemacs_lib}/xemacs-packages"
}

variant carbon-beta {
	version		21.5.21

	set carbonport_name ${name}-${version}-carbon-b3.diff
	configure.args --without-postgresql --without-ldap \
		--without-x11 --with-sound=none --pdump \
		--site-prefixes=${prefix} --with-tty

	distfiles	${name}-${version}${extract.suffix}:beta \
     			${carbonport_name}.bz2:carbonport
		
	checksums-append ${name}-${version}${extract.suffix} \
	        md5 5941238fe8eda3a120bc5735cc50a94d \
		${carbonport_name}.bz2 md5 6ad58b2b3c77a8030e26b83b6361e39f

	extract.only	${name}-${version}.tar.gz

	if { [variant_isset sumo] } {
		extract.only    ${name}-${version}.tar.gz ${name}-sumo-2006-05-10${extract.suffix}
	}

	post-extract	{
                 system "cp ${distpath}/${name}-${version}-carbon-b3.diff.bz2 ${workpath}"
                 system "cd ${workpath} && bzip2 -d ${name}-${version}-carbon-b3.diff.bz2"
                 system "cd ${workpath} && patch -p1 -d ${distname} <${name}-${version}-carbon-b3.diff"
	}

	set worksrcpath	${workpath}/${name}-${version}

	depends_lib	
	configure	{}

	build.cmd	cd ${worksrcpath}/carbon/ && sh ./build-app.sh
	build.args	{}

	destroot.args	{}

	set xemacs_lib	${destroot}/Applications/DarwinPorts/XEmacs.app/Contents/Resources/lib/xemacs/

	post-destroot	{
		system "cp -Rp ${worksrcpath}/carbon/XEmacs.app ${destroot}/Applications/DarwinPorts/"
	}
}

variant sumo {
	set sumo_dist		${name}-sumo-2006-05-10${extract.suffix}

	distfiles-append	${sumo_dist}:sumo
	checksums-append	${sumo_dist} \
				 md5 51f9ca6843dae22aec78e6f1033e16b5

	post-destroot {
		ui_info "Installing sumo distribution into destroot"
		system "cp -Rp ${worksrcpath}/../xemacs-packages ${xemacs_lib}"
	}
}
