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, fetchurl, libsigsegv, gettext, ncurses, readline, libX11
7, libXau, libXt, pcre, zlib, libXpm, xorgproto, libXext
8, libffi
9, libffcall
10, coreutils
11# build options
12, threadSupport ? stdenv.hostPlatform.isx86
13, x11Support ? stdenv.hostPlatform.isx86
14, dllSupport ? true
15, withModules ? [
16 "pcre"
17 "rawsock"
18 ]
19 ++ lib.optionals stdenv.isLinux [ "bindings/glibc" "zlib" "wildcard" ]
20 ++ lib.optional x11Support "clx/new-clx"
21}:
22
23assert x11Support -> (libX11 != null && libXau != null && libXt != null
24 && libXpm != null && xorgproto != null && libXext != null);
25
26stdenv.mkDerivation rec {
27 version = "2.49";
28 pname = "clisp";
29
30 src = fetchurl {
31 url = "mirror://gnu/clisp/release/${version}/clisp-${version}.tar.bz2";
32 sha256 = "8132ff353afaa70e6b19367a25ae3d5a43627279c25647c220641fed00f8e890";
33 };
34
35 inherit libsigsegv gettext coreutils;
36
37 ffcallAvailable = stdenv.isLinux && (libffcall != null);
38
39 buildInputs = [libsigsegv]
40 ++ lib.optional (gettext != null) gettext
41 ++ lib.optional (ncurses != null) ncurses
42 ++ lib.optional (pcre != null) pcre
43 ++ lib.optional (zlib != null) zlib
44 ++ lib.optional (readline != null) readline
45 ++ lib.optional (ffcallAvailable && (libffi != null)) libffi
46 ++ lib.optional ffcallAvailable libffcall
47 ++ lib.optionals x11Support [
48 libX11 libXau libXt libXpm xorgproto libXext
49 ];
50
51 patches = [
52 ./bits_ipctypes_to_sys_ipc.patch # from Gentoo
53 # The cfree alias no longer exists since glibc 2.26
54 ./remove-cfree-binding.patch
55 ];
56
57 # First, replace port 9090 (rather low, can be used)
58 # with 64237 (much higher, IANA private area, not
59 # anything rememberable).
60 # Also remove reference to a type that disappeared from recent glibc
61 # (seems the correct thing to do, found no reference to any solution)
62 postPatch = ''
63 sed -e 's@9090@64237@g' -i tests/socket.tst
64 sed -i 's@/bin/pwd@${coreutils}&@' src/clisp-link.in
65 find . -type f | xargs sed -e 's/-lICE/-lXau &/' -i
66
67 substituteInPlace modules/bindings/glibc/linux.lisp --replace "(def-c-type __swblk_t)" ""
68 '';
69
70 configureFlags = [ "builddir" ]
71 ++ lib.optional (!dllSupport) "--without-dynamic-modules"
72 ++ lib.optional (readline != null) "--with-readline"
73 # --with-dynamic-ffi can only exist with --with-ffcall - foreign.d does not compile otherwise
74 ++ lib.optional (ffcallAvailable && (libffi != null)) "--with-dynamic-ffi"
75 ++ lib.optional ffcallAvailable "--with-ffcall"
76 ++ lib.optional (!ffcallAvailable) "--without-ffcall"
77 ++ builtins.map (x: "--with-module=" + x) withModules
78 ++ lib.optional threadSupport "--with-threads=POSIX_THREADS";
79
80 preBuild = ''
81 sed -e '/avcall.h/a\#include "config.h"' -i src/foreign.d
82 cd builddir
83 '';
84
85 # Fails to build in parallel due to missing gnulib header dependency used in charstrg.d:
86 # ../src/charstrg.d:319:10: fatal error: uniwidth.h: No such file or directory
87 enableParallelBuilding = false;
88
89 postInstall =
90 lib.optionalString (withModules != [])
91 (''./clisp-link add "$out"/lib/clisp*/base "$(dirname "$out"/lib/clisp*/base)"/full''
92 + lib.concatMapStrings (x: " " + x) withModules);
93
94 env.NIX_CFLAGS_COMPILE = "-O0 ${lib.optionalString (!stdenv.is64bit) "-falign-functions=4"}";
95
96 # TODO : make mod-check fails
97 doCheck = false;
98
99 meta = {
100 description = "ANSI Common Lisp Implementation";
101 homepage = "http://clisp.cons.org";
102 maintainers = lib.teams.lisp.members;
103 platforms = lib.platforms.unix;
104 # problems on Darwin: https://github.com/NixOS/nixpkgs/issues/20062
105 broken = stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isAarch64;
106 license = lib.licenses.gpl2;
107 };
108}