# $Id: Portfile,v 1.21 2006/02/23 21:49:02 gwright Exp $

PortSystem 1.0
name		clisp
version		2.38
revision	1
categories	lang
maintainers	gwright@opendarwin.org
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

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

checksums	md5 f23f6015631f7eb31af9dcda5ec195bd

patchfiles	patch-socket.d

build.dir	${worksrcpath}/src

configure.env	CPPFLAGS=-I${prefix}/include	\
		LDFLAGS=-L${prefix}/lib

variant dynffi	{
		ui_msg "enabling dynamic foreign function interface"
		}

variant nolibsigsegv {
		depends_lib-delete	port:libsigsegv
		configure.args-append	--ignore-absence-of-libsigsegv
		}
		
platform darwin i386 {
		ui_msg "clisp is not supported on OS X i386 yet"
		exit 1
		}

platform darwin 6 {
		ui_msg "clisp is not supported on Jaguar (OS X 10.2.x)"
		exit 1
		}

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

		if { [variant_isset dynffi] } {
			post-configure	{ cd ${build.dir}
				system "./makemake --prefix=${prefix}	\
					   	--with-unicode		\
					   	--with-readline		\
					   	--with-dynamic-ffi	\
					   	--with-export-syscalls	\
					   	--with-gettext > Makefile && \
					make config.lisp"

				reinplace "s|CLFLAGS =|CLFLAGS = -L${prefix}/lib|g" Makefile
			}
		} else {
			post-configure	{ cd ${build.dir}
				system "./makemake --prefix=${prefix}	\
						--with-unicode		\
						--with-readline		\
						--without-dynamic-ffi	\
						--with-export-syscalls	\
						--with-gettext > Makefile && \
					make config.lisp"

				reinplace "s|CLFLAGS =|CLFLAGS = -L${prefix}/lib|g" Makefile
			}
		}
	}

platform darwin 8 {
		if { [variant_isset dynffi] } {
			post-configure	{ cd ${build.dir}
				system "./makemake --prefix=${prefix}	\
					   	--with-unicode		\
					   	--with-readline		\
					   	--with-dynamic-ffi	\
					   	--with-export-syscalls	\
					   	--with-gettext > Makefile && \
					make config.lisp"

				reinplace "s|CLFLAGS =|CLFLAGS = -L${prefix}/lib|g" Makefile
			}
		} else {
			post-configure	{ cd ${build.dir}
				system "./makemake --prefix=${prefix}	\
						--with-unicode		\
						--with-readline		\
						--without-dynamic-ffi	\
						--with-export-syscalls	\
						--with-gettext > Makefile && \
					make config.lisp"

				reinplace "s|CLFLAGS =|CLFLAGS = -L${prefix}/lib|g" Makefile
			}
		}
	}

#
# The repetition of the CPPFLAGS and LDFLAGS is necessary because of clisp's
# hand written (and very fragile) configuration process, as is the clearing
# of the configuration cache.
#
build		{ system "ulimit -s 8192 && cd ${build.dir}"
		  system "rm ./config.cache"
		  system "CPPFLAGS=-I${prefix}/include LDFLAGS=-L${prefix}/lib make"
		  system "CPPFLAGS=-I${prefix}/include LDFLAGS=-L${prefix}/lib make check"
		}

pre-destroot	{ cd ${build.dir} }


