# $Id: Portfile 55984 2009-08-22 20:48:48Z jmr@macports.org $

PortSystem 1.0

name            clisp
version         2.47
categories      lang
maintainers     waqar
platforms       darwin
description     The Clisp Common Lisp Implementation
long_description        \
                CLISP is a Common Lisp implementation by Bruno Haible, \
                formerly of Karlsruhe University, and Michael Stoll, \
                formerly of Munich University, both in Germany. \
                It mostly supports the Lisp described in the \
                ANSI Common Lisp standard. \
                CLISP includes an interpreter, a compiler, almost all \
                of CLOS, a foreign language interface and a socket interface. \
                An X11 interface is available through CLX and Garnet. \
                Command line editing is provided by readline.

homepage        http://clisp.cons.org/
master_sites    gnu:clisp/release/${version}    \
                sourceforge

checksums	md5     8fa89bb13e865fc7c7150b82682f35af \
		sha1    63749bf07409cee134c195547e6d911554b619d6 \
		rmd160  d376b0b16694bbaf60e61fc3465bfcdf5770e093

use_bzip2       yes

depends_lib     port:readline   \
                port:gettext    \
                port:libsigsegv

build.dir       ${worksrcpath}/src

variant dynffi {
    ui_msg "enabling dynamic foreign function interface"
    depends_lib-append   port:ffcall
}

variant nolibsigsegv {
    depends_lib-delete      port:libsigsegv
    configure.args-append   --ignore-absence-of-libsigsegv
}

platform darwin {
    # placeholder for use with variant_isset
}

platform darwin 7 {
    depends_lib-delete      port:libsigsegv
    configure.args-append   --ignore-absence-of-libsigsegv
}

configure.cflags
configure.args --prefix=${prefix} --with-libreadline-prefix=${prefix} \
               --with-libsigsegv-prefix=${prefix} --with-libiconv-prefix=${prefix}

configure {
    set cmdstring "CFLAGS='[join ${configure.cflags}]' \
                         CC='${configure.cc}' \
                        ./configure [join ${configure.args}]"
    ui_debug "EXECUTING: $cmdstring"
    system "cd ${configure.dir} && $cmdstring"
}

post-configure {
    if {[variant_isset darwin]} {
        if {[variant_isset dynffi]} {
            set ffi_switch "--with-dynamic-ffi"
        } else {
            set ffi_switch "--without-dynamic-ffi"
        }
        set cmdstring "                                     \
                CFLAGS=[join ${configure.cflags}]           \
                    ./makemake [join ${configure.args}]     \
                               --with-unicode               \
                               --with-readline              \
                               ${ffi_switch}                \
                               --with-export-syscalls       \
                               --with-gettext > Makefile && \
                make config.lisp"
        ui_debug "EXECUTING: $cmdstring"
        system "cd ${build.dir} && $cmdstring"
    }
}

build {
    set cmdstring "cd ${build.dir} && ulimit -s 16384 && \
                   unset LD_PREBIND LD_PREBIND_ALLOW_OVERLAP && \
                   make"
    ui_debug "EXECUTING: $cmdstring"
    system $cmdstring
    set cmdstring "$cmdstring check"
    ui_debug "EXECUTING: $cmdstring"
    system $cmdstring
}

livecheck.check regex
livecheck.url   http://ftp.gnu.org/gnu/${name}/release/?C=M&O=D
livecheck.regex >(\[0-9.\]+)/<
