# -*- coding: utf-8; mode: tcl; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 80550 2011-07-14 17:55:48Z easieste@macports.org $

PortSystem 1.0

name		sbcl
version		1.0.50
revision        0
set subrevision	""
categories	lang
maintainers	openmaintainer easieste gwright waqar 
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     74ce9b24516885d066ec4287cde52e8c \
                    sha1    4d0a7ae81d0c82b93a46efb1bc4a697c885b5e06 \
                    rmd160  dbe601bfd2eec193f47df6be72eaac2b6f68d8bf 

platform powerpc {
		   set bootversion 1.0.47
		   distfiles-append ${name}-${bootversion}-powerpc-darwin-binary${extract.suffix}
		   checksums-append ${name}-${bootversion}-powerpc-darwin-binary${extract.suffix} \
                        md5     02747afc7631a7ccdeede4b52b78072d \
                        sha1    93df00b3120810a086d37666c1ccdeabc8daeb49 \
                        rmd160  85c76296a1c62db5affdff7e72e61e558bb5c819

		   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.48
		   distfiles-append ${name}-${bootversion}-x86-darwin-binary${extract.suffix}
		   checksums-append ${name}-${bootversion}-x86-darwin-binary${extract.suffix} \
                        md5     5a3fe53829c6c9f589f17db31210e2ce \
                        sha1    c4c6aa31e58767364c36ca509e06cf92c7b2e293 \
                        rmd160  9f7e7a7c3d4ed35540c6c81962052fc13ee2cd9b

		   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.48
		   distfiles-append ${name}-${bootversion}-x86-darwin-binary${extract.suffix}
		   checksums-append ${name}-${bootversion}-x86-darwin-binary${extract.suffix} \
                        md5     5a3fe53829c6c9f589f17db31210e2ce \
                        sha1    c4c6aa31e58767364c36ca509e06cf92c7b2e293 \
                        rmd160  9f7e7a7c3d4ed35540c6c81962052fc13ee2cd9b

		   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.48
		   distfiles-append ${name}-${bootversion}-x86-darwin-binary${extract.suffix}
		   checksums-append ${name}-${bootversion}-x86-darwin-binary${extract.suffix} \
                        md5     5a3fe53829c6c9f589f17db31210e2ce \
                        sha1    c4c6aa31e58767364c36ca509e06cf92c7b2e293 \
                        rmd160  9f7e7a7c3d4ed35540c6c81962052fc13ee2cd9b

		   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}/doc/sbcl.1
}

use_configure	no

build		{
    reinplace s|CC=gcc|CC=${configure.cc}| ${worksrcpath}/contrib/asdf-module.mk
    system "ulimit -s 8192 && unset LD_PREBIND && unset LD_PREBIND_ALLOW_OVERLAP && cd ${worksrcpath} && CC=${configure.cc} CXX=${configure.cxx} CPP=${configure.cpp} sh make.sh ${host_lisp} --prefix=${prefix}"
}

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

variant html conflicts pdf description {Installs documentation in HTML and Info formats} {
    patchfiles-append patch-make-doc.diff
    depends_build-append bin:texi2dvi:texinfo
    depends_build-append bin:makeinfo:texinfo
} 

variant pdf conflicts html description {Installs documentation in PDF, HTML and Info formats} {
    patchfiles-delete patch-make-doc.diff
    depends_build-append bin:dvips:texlive
    depends_build-append bin:texi2dvi:texinfo
    depends_build-append bin:makeinfo:texinfo
} 

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

test.run	yes
test.dir	${worksrcpath}/tests
test.cmd	CC=${configure.cc} CXX=${configure.cxx} CPP=${configure.cpp} 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+)+)-
