Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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{ lib, stdenv, fetchhg, libsigsegv, gettext, ncurses, readline, libX11
7, libXau, libXt, pcre, zlib, libXpm, xorgproto, libXext
8, libffi, libffcall, automake
9, coreutils
10# build options
11, threadSupport ? stdenv.hostPlatform.isx86
12, x11Support ? stdenv.hostPlatform.isx86
13, dllSupport ? true
14, withModules ? [
15 "pcre"
16 "rawsock"
17 ]
18 ++ lib.optionals stdenv.isLinux [ "bindings/glibc" "zlib" ]
19 ++ lib.optional x11Support "clx/new-clx"
20}:
21
22assert x11Support -> (libX11 != null && libXau != null && libXt != null
23 && libXpm != null && xorgproto != null && libXext != null);
24
25stdenv.mkDerivation rec {
26 version = "2.50pre20171114";
27 pname = "clisp";
28
29 src = fetchhg {
30 url = "http://hg.code.sf.net/p/clisp/clisp";
31 rev = "36df6dc59b8f";
32 sha256 = "1pidiv1m55lvc4ln8vx0ylnnhlj95y6hrfdq96nrj14f4v8fkvmr";
33 };
34
35 inherit libsigsegv gettext coreutils;
36
37 ffcallAvailable = stdenv.isLinux && (libffcall != null);
38
39 nativeBuildInputs = [ automake ]; # sometimes fails otherwise
40 buildInputs = [libsigsegv]
41 ++ lib.optional (gettext != null) gettext
42 ++ lib.optional (ncurses != null) ncurses
43 ++ lib.optional (pcre != null) pcre
44 ++ lib.optional (zlib != null) zlib
45 ++ lib.optional (readline != null) readline
46 ++ lib.optional (ffcallAvailable && (libffi != null)) libffi
47 ++ lib.optional ffcallAvailable libffcall
48 ++ lib.optionals x11Support [
49 libX11 libXau libXt libXpm xorgproto libXext
50 ];
51
52 # First, replace port 9090 (rather low, can be used)
53 # with 64237 (much higher, IANA private area, not
54 # anything rememberable).
55 # Also remove reference to a type that disappeared from recent glibc
56 # (seems the correct thing to do, found no reference to any solution)
57 postPatch = ''
58 sed -e 's@9090@64237@g' -i tests/socket.tst
59 sed -i 's@/bin/pwd@${coreutils}&@' src/clisp-link.in
60 find . -type f | xargs sed -e 's/-lICE/-lXau &/' -i
61
62 substituteInPlace modules/bindings/glibc/linux.lisp --replace "(def-c-type __swblk_t)" ""
63 '';
64
65 configureFlags = [ "builddir" ]
66 ++ lib.optional (!dllSupport) "--without-dynamic-modules"
67 ++ lib.optional (readline != null) "--with-readline"
68 # --with-dynamic-ffi can only exist with --with-ffcall - foreign.d does not compile otherwise
69 ++ lib.optional (ffcallAvailable && (libffi != null)) "--with-dynamic-ffi"
70 ++ lib.optional ffcallAvailable "--with-ffcall"
71 ++ lib.optional (!ffcallAvailable) "--without-ffcall"
72 ++ builtins.map (x: " --with-module=" + x) withModules
73 ++ lib.optional threadSupport "--with-threads=POSIX_THREADS";
74
75 preBuild = ''
76 sed -e '/avcall.h/a\#include "config.h"' -i src/foreign.d
77 sed -i -re '/ cfree /d' -i modules/bindings/glibc/linux.lisp
78 cd builddir
79 '';
80
81 postInstall =
82 lib.optionalString (withModules != [])
83 (''./clisp-link add "$out"/lib/clisp*/base "$(dirname "$out"/lib/clisp*/base)"/full''
84 + lib.concatMapStrings (x: " " + x) withModules);
85
86 env.NIX_CFLAGS_COMPILE = "-O0 ${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 = lib.teams.lisp.members;
95 # problems on Darwin: https://github.com/NixOS/nixpkgs/issues/20062
96 platforms = lib.platforms.linux;
97 };
98}