1# there are the following linking sets:
2# - boot (not installed): without modules, only used when building clisp
3# - base (default): contains readline and i18n, regexp and syscalls modules
4# by default
5# - full: contains base plus modules in withModules
6{ stdenv, fetchurl, libsigsegv, gettext, ncurses, readline, libX11
7, libXau, libXt, pcre, zlib, libXpm, xproto, libXext, xextproto
8, libffi, libffcall, coreutils
9# build options
10, threadSupport ? (stdenv.isi686 || stdenv.isx86_64)
11, x11Support ? (stdenv.isi686 || stdenv.isx86_64)
12, dllSupport ? true
13, withModules ? [
14 "bindings/glibc"
15 "pcre"
16 "rawsock"
17 "wildcard"
18 "zlib"
19 ]
20 ++ stdenv.lib.optional x11Support "clx/new-clx"
21}:
22
23assert x11Support -> (libX11 != null && libXau != null && libXt != null
24 && libXpm != null && xproto != null && libXext != null && xextproto != null);
25
26stdenv.mkDerivation rec {
27 v = "2.49";
28 name = "clisp-${v}";
29
30 src = fetchurl {
31 url = "mirror://gnu/clisp/release/${v}/${name}.tar.bz2";
32 sha256 = "8132ff353afaa70e6b19367a25ae3d5a43627279c25647c220641fed00f8e890";
33 };
34
35 inherit libsigsegv gettext coreutils;
36
37 buildInputs = [libsigsegv]
38 ++ stdenv.lib.optional (gettext != null) gettext
39 ++ stdenv.lib.optional (ncurses != null) ncurses
40 ++ stdenv.lib.optional (pcre != null) pcre
41 ++ stdenv.lib.optional (zlib != null) zlib
42 ++ stdenv.lib.optional (readline != null) readline
43 ++ stdenv.lib.optional (libffi != null) libffi
44 ++ stdenv.lib.optional (libffcall != null) libffcall
45 ++ stdenv.lib.optionals x11Support [
46 libX11 libXau libXt libXpm xproto libXext xextproto
47 ];
48
49 patches = [ ./bits_ipctypes_to_sys_ipc.patch ]; # from Gentoo
50
51 # First, replace port 9090 (rather low, can be used)
52 # with 64237 (much higher, IANA private area, not
53 # anything rememberable).
54 # Also remove reference to a type that disappeared from recent glibc
55 # (seems the correct thing to do, found no reference to any solution)
56 postPatch = ''
57 sed -e 's@9090@64237@g' -i tests/socket.tst
58 sed -i 's@/bin/pwd@${coreutils}&@' src/clisp-link.in
59 find . -type f | xargs sed -e 's/-lICE/-lXau &/' -i
60
61 substituteInPlace modules/bindings/glibc/linux.lisp --replace "(def-c-type __swblk_t)" ""
62 '';
63
64 configureFlags = "builddir"
65 + stdenv.lib.optionalString (!dllSupport) " --without-dynamic-modules"
66 + stdenv.lib.optionalString (readline != null) " --with-readline"
67 + stdenv.lib.optionalString (libffi != null) " --with-dynamic-ffi"
68 + stdenv.lib.optionalString (libffcall != null) " --with-ffcall"
69 + stdenv.lib.concatMapStrings (x: " --with-module=" + x) withModules
70 + stdenv.lib.optionalString threadSupport " --with-threads=POSIX_THREADS";
71
72 preBuild = ''
73 sed -e '/avcall.h/a\#include "config.h"' -i src/foreign.d
74 cd builddir
75 '';
76
77 postInstall =
78 stdenv.lib.optionalString (withModules != [])
79 (''./clisp-link add "$out"/lib/clisp*/base "$(dirname "$out"/lib/clisp*/base)"/full''
80 + stdenv.lib.concatMapStrings (x: " " + x) withModules);
81
82 NIX_CFLAGS_COMPILE = "-O0 ${stdenv.lib.optionalString (!stdenv.is64bit) "-falign-functions=4"}";
83
84 # TODO : make mod-check fails
85 doCheck = false;
86
87 meta = {
88 description = "ANSI Common Lisp Implementation";
89 homepage = http://clisp.cons.org;
90 maintainers = with stdenv.lib.maintainers; [raskin tohl];
91 platforms = stdenv.lib.platforms.linux;
92 };
93}