# -*- mode: tcl; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- # vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 92023 2012-04-16 11:52:24Z easieste@macports.org $

PortSystem 1.0

name		sbcl

version		      1.0.56
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 implementation of ANSI \
Common Lisp. It provides an interactive environment including an \
integrated native compiler, interpreter, and debugger. SBCL is quite \
suitable for the creation of long running system services, as the compiler  \
trades the time for a long initial compilation for blazingly fast loading \
of its binary runtime fasl representation..


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

patchfiles	\
                patch-use-mach-exception-handler.diff  \
                patch-posix-tests.diff \
                patch-use-right-gcc.diff

distfiles	${name}-${version}-source${subrevision}${extract.suffix}

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

checksums           sbcl-1.0.56-source.tar.bz2 \
                    rmd160  e3f3ce77e32c9e636359e5b6d586f938a263d84d \
                    sha256  3c50bfa3381f46b87175ab6ecb75bf9c37974ff3f21b1f3c50dbdab1bf870533 \
                    sbcl-1.0.48-x86-darwin-binary.tar.bz2 \
                    md5     5a3fe53829c6c9f589f17db31210e2ce \
                    sha1    c4c6aa31e58767364c36ca509e06cf92c7b2e293 \
                    rmd160  9f7e7a7c3d4ed35540c6c81962052fc13ee2cd9b \
                    md5     5a3fe53829c6c9f589f17db31210e2ce \
                    sha1    c4c6aa31e58767364c36ca509e06cf92c7b2e293 \
                    rmd160  9f7e7a7c3d4ed35540c6c81962052fc13ee2cd9b \
                    md5     5a3fe53829c6c9f589f17db31210e2ce \
                    sha1    c4c6aa31e58767364c36ca509e06cf92c7b2e293 \
                    rmd160  9f7e7a7c3d4ed35540c6c81962052fc13ee2cd9b \
                    md5     5a3fe53829c6c9f589f17db31210e2ce \
                    sha1    c4c6aa31e58767364c36ca509e06cf92c7b2e293 \
                    rmd160  9f7e7a7c3d4ed35540c6c81962052fc13ee2cd9b \
                    md5     5a3fe53829c6c9f589f17db31210e2ce \
                    sha1    c4c6aa31e58767364c36ca509e06cf92c7b2e293 \
                    rmd160  9f7e7a7c3d4ed35540c6c81962052fc13ee2cd9b

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\" "
}

platform darwin 11 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

# ticket #33446
# can be removed when upstream fixes https://bugs.launchpad.net/sbcl/+bug/658414
if {${configure.compiler} == "clang"} {
    configure.compiler llvm-gcc-4.2
}

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} && export CC && CC=${configure.cc} && export CXX && CXX=${configure.cxx} && export CPP && CPP==${configure.cpp} && sh ./make.sh ${make_sh_options} --prefix=${prefix} --xc-host=${host_lisp}"
}

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.
Involves the installation of a TexLive dependency chain, which can dramatically slow down the installation of the SBCL port.} {
    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 using the Mach pthreads interface.} {
    patchfiles-append patch-base-target-features.diff
}

global make_sh_options
set make_sh_options ""

variant fancy conflicts threads description {Configure SBCL compilation with all available compatible options (including threading).} {
    patchfiles-delete                 patch-use-mach-exception-handler.diff
    set                               make_sh_options --fancy
}



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+)+)-
