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
9, libffcall
10, coreutils
11# build options
12, threadSupport ? (stdenv.isi686 || stdenv.isx86_64)
13, x11Support ? (stdenv.isi686 || stdenv.isx86_64)
14, dllSupport ? true
15, withModules ? [
16 "pcre"
17 "rawsock"
18 ]
19 ++ stdenv.lib.optionals stdenv.isLinux [ "bindings/glibc" "zlib" "wildcard" ]
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 ffcallAvailable = stdenv.isLinux && (libffcall != null);
38
39 buildInputs = [libsigsegv]
40 ++ stdenv.lib.optional (gettext != null) gettext
41 ++ stdenv.lib.optional (ncurses != null) ncurses
42 ++ stdenv.lib.optional (pcre != null) pcre
43 ++ stdenv.lib.optional (zlib != null) zlib
44 ++ stdenv.lib.optional (readline != null) readline
45 ++ stdenv.lib.optional (ffcallAvailable && (libffi != null)) libffi
46 ++ stdenv.lib.optional ffcallAvailable libffcall
47 ++ stdenv.lib.optionals x11Support [
48 libX11 libXau libXt libXpm xproto libXext xextproto
49 ];
50
51 patches = [ ./bits_ipctypes_to_sys_ipc.patch ]; # from Gentoo
52
53 # First, replace port 9090 (rather low, can be used)
54 # with 64237 (much higher, IANA private area, not
55 # anything rememberable).
56 # Also remove reference to a type that disappeared from recent glibc
57 # (seems the correct thing to do, found no reference to any solution)
58 postPatch = ''
59 sed -e 's@9090@64237@g' -i tests/socket.tst
60 sed -i 's@/bin/pwd@${coreutils}&@' src/clisp-link.in
61 find . -type f | xargs sed -e 's/-lICE/-lXau &/' -i
62
63 substituteInPlace modules/bindings/glibc/linux.lisp --replace "(def-c-type __swblk_t)" ""
64 '';
65
66 configureFlags = "builddir"
67 + stdenv.lib.optionalString (!dllSupport) " --without-dynamic-modules"
68 + stdenv.lib.optionalString (readline != null) " --with-readline"
69 # --with-dynamic-ffi can only exist with --with-ffcall - foreign.d does not compile otherwise
70 + stdenv.lib.optionalString (ffcallAvailable && (libffi != null)) " --with-dynamic-ffi"
71 + stdenv.lib.optionalString ffcallAvailable " --with-ffcall"
72 + stdenv.lib.optionalString (!ffcallAvailable) " --without-ffcall"
73 + stdenv.lib.concatMapStrings (x: " --with-module=" + x) withModules
74 + stdenv.lib.optionalString threadSupport " --with-threads=POSIX_THREADS";
75
76 preBuild = ''
77 sed -e '/avcall.h/a\#include "config.h"' -i src/foreign.d
78 cd builddir
79 '';
80
81 postInstall =
82 stdenv.lib.optionalString (withModules != [])
83 (''./clisp-link add "$out"/lib/clisp*/base "$(dirname "$out"/lib/clisp*/base)"/full''
84 + stdenv.lib.concatMapStrings (x: " " + x) withModules);
85
86 NIX_CFLAGS_COMPILE = "-O0 ${stdenv.lib.optionalString (!stdenv.is64bit) "-falign-functions=4"}";
87
88 # TODO : make mod-check fails
89 doCheck = false;
90
91 meta = {
92 description = "ANSI Common Lisp Implementation";
93 homepage = http://clisp.cons.org;
94 maintainers = with stdenv.lib.maintainers; [raskin tohl];
95 # problems on Darwin: https://github.com/NixOS/nixpkgs/issues/20062
96 platforms = stdenv.lib.platforms.linux;
97 };
98}