# $Id: Portfile 68509 2010-06-05 08:46:18Z easieste@macports.org $

PortSystem 1.0

name		sbcl
version		1.0.39
revision        0
set subrevision	""
categories	lang
maintainers	gwright waqar easieste
platforms	darwin
description	The Steel Bank Common Lisp system
long_description	\
		Steel Bank Common Lisp (SBCL) is a Open Source		\
		development system for ANSI Common Lisp. It provides an	\
		interactive environment including an integrated native	\
		compiler, interpreter, and debugger. (And it, and its	\
		generated code, can also play nicely with Unix when	\
		running noninteractively.)

homepage	http://www.sbcl.org
master_sites	sourceforge
use_bzip2	yes

patchfiles	patch-use-mach-exception-handler.diff \
                patch-posix-tests.diff
		
distfiles	${name}-${version}-source${subrevision}${extract.suffix}

distname	${name}-${version}-source${subrevision}
worksrcdir	${name}-${version}

checksums           sbcl-${version}-source.tar.bz2 \
                    md5     8dcc98ba36bb0197b7bf12f001ff2bb2 \
                    sha1    027a76d68cf9f9895fea75ba6c7cc055cbd3350d \
                    rmd160  8cbbd21cd0a0872626ad0e031912eb633f7a8dba \
                    sbcl-1.0.30-x86-darwin-binary.tar.bz2 \
                    md5     c15bbff2e7a9083ecd50942edb74cc8c \
                    sha1    069431d0a6e6cfbd7489c3792392926de199a93f \
                    rmd160  266693e337b5369ef6f6ee9c269f9e6a4df03c36

platform powerpc {
		   set bootversion 1.0.22
		   distfiles-append ${name}-${bootversion}-powerpc-darwin-binary${extract.suffix}
		   checksums-append ${name}-${bootversion}-powerpc-darwin-binary${extract.suffix} \
			md5 61179259f7a7cccfa731f652f5edd29c

		   global host_lisp
		   set host_lisp	"\"${workpath}/${name}-${bootversion}-powerpc-darwin/src/runtime/sbcl --core ${workpath}/${name}-${bootversion}-powerpc-darwin/output/sbcl.core --disable-debugger --sysinit /dev/null --userinit /dev/null\" "
}

platform darwin 8 i386     {
		   set bootversion 1.0.30
		   distfiles-append ${name}-${bootversion}-x86-darwin-binary${extract.suffix}
		   checksums-append ${name}-${bootversion}-x86-darwin-binary${extract.suffix} \
                        md5     c15bbff2e7a9083ecd50942edb74cc8c \

		   global host_lisp
		   set host_lisp	"\"${workpath}/${name}-${bootversion}-x86-darwin/src/runtime/sbcl --core ${workpath}/${name}-${bootversion}-x86-darwin/output/sbcl.core --disable-debugger --sysinit /dev/null --userinit /dev/null\" "
}

platform darwin 9 i386     {
		   set bootversion 1.0.30
		   distfiles-append ${name}-${bootversion}-x86-darwin-binary${extract.suffix}
		   checksums-append ${name}-${bootversion}-x86-darwin-binary${extract.suffix} \
                        md5     c15bbff2e7a9083ecd50942edb74cc8c \

		   global host_lisp
		   set host_lisp	"\"${workpath}/${name}-${bootversion}-x86-darwin/src/runtime/sbcl --core ${workpath}/${name}-${bootversion}-x86-darwin/output/sbcl.core --disable-debugger --sysinit /dev/null --userinit /dev/null\" "
}

platform darwin 10 i386     {
		   set bootversion 1.0.30
		   distfiles-append ${name}-${bootversion}-x86-darwin-binary${extract.suffix}
		   checksums-append ${name}-${bootversion}-x86-darwin-binary${extract.suffix} \
                        md5     c15bbff2e7a9083ecd50942edb74cc8c \

		   global host_lisp
		   set host_lisp	"\"${workpath}/${name}-${bootversion}-x86-darwin/src/runtime/sbcl --core ${workpath}/${name}-${bootversion}-x86-darwin/output/sbcl.core --disable-debugger --sysinit /dev/null --userinit /dev/null\" "
}

post-patch	{
	reinplace "s|/usr/local/lib/${name}|${prefix}/lib/${name}|g" \
                            ${worksrcpath}/src/runtime/runtime.c
	reinplace "s|/usr/local/lib/${name}|${prefix}/lib/${name}|g" \
                            ${worksrcpath}/doc/sbcl.1
}

use_configure	no


build		{
	system "ulimit -s 8192"
	system "unset LD_PREBIND && unset LD_PREBIND_ALLOW_OVERLAP && cd ${worksrcpath} && sh make.sh ${host_lisp}"
}

post-build {
	if {[variant_isset html]} {
		system "cd ${worksrcpath}/doc; INSTALL_ROOT=${destroot}${prefix} sh ${worksrcpath}/doc/make-doc.sh"
	}
}

default_variants	+html

variant html description {Builds the SBCL and ASDF documentation as HTML} {} 

variant threads description {enable threaded runtime} {
	patchfiles-append patch-base-target-features.diff
}

test.run	yes
test.dir	${worksrcpath}/tests
test.cmd	sh
test.target	run-tests.sh

destroot	{ system "cd ${worksrcpath}; INSTALL_ROOT=${destroot}/${prefix} sh ${worksrcpath}/install.sh"
}

livecheck.url       http://sourceforge.net/api/file/index/project-id/1373/rss?path=%2F${name}
livecheck.regex     ${name}-(\\d+(\\.\\d+)+)-
