summary refs log tree commit diff
path: root/pkgs/development/interpreters/clisp/default.nix
blob: c3d289d2a8d48ecae0b191ac72af43ce95f3b85f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# there are the following linking sets:
# - boot (not installed): without modules, only used when building clisp
# - base (default): contains readline and i18n, regexp and syscalls modules
#   by default
# - full: contains base plus modules in withModules
{ stdenv, fetchurl, libsigsegv, gettext, ncurses, readline, libX11
, libXau, libXt, pcre, zlib, libXpm, xproto, libXext, xextproto
, libffi, libffcall, coreutils
# build options
, threadSupport ? (stdenv.isi686 || stdenv.isx86_64)
, x11Support ? (stdenv.isi686 || stdenv.isx86_64)
, dllSupport ? true
, withModules ? [
    "bindings/glibc"
    "pcre"
    "rawsock"
    "wildcard"
    "zlib"
  ]
  ++ stdenv.lib.optional x11Support "clx/new-clx"
}:

assert x11Support -> (libX11 != null && libXau != null && libXt != null
  && libXpm != null && xproto != null && libXext != null && xextproto != null);

stdenv.mkDerivation rec {
  v = "2.49";
  name = "clisp-${v}";
  
  src = fetchurl {
    url = "mirror://gnu/clisp/release/${v}/${name}.tar.bz2";
    sha256 = "8132ff353afaa70e6b19367a25ae3d5a43627279c25647c220641fed00f8e890";
  };

  inherit libsigsegv gettext coreutils;
  
  buildInputs = [libsigsegv]
  ++ stdenv.lib.optional (gettext != null) gettext
  ++ stdenv.lib.optional (ncurses != null) ncurses
  ++ stdenv.lib.optional (pcre != null) pcre
  ++ stdenv.lib.optional (zlib != null) zlib
  ++ stdenv.lib.optional (readline != null) readline
  ++ stdenv.lib.optional (libffi != null) libffi
  ++ stdenv.lib.optional (libffcall != null) libffcall
  ++ stdenv.lib.optionals x11Support [
    libX11 libXau libXt libXpm xproto libXext xextproto
  ];

  patches = [ ./bits_ipctypes_to_sys_ipc.patch ]; # from Gentoo

  # First, replace port 9090 (rather low, can be used)
  # with 64237 (much higher, IANA private area, not
  # anything rememberable).
  # Also remove reference to a type that disappeared from recent glibc
  # (seems the correct thing to do, found no reference to any solution)
  postPatch = ''
    sed -e 's@9090@64237@g' -i tests/socket.tst
    sed -i 's@/bin/pwd@${coreutils}&@' src/clisp-link.in
    find . -type f | xargs sed -e 's/-lICE/-lXau &/' -i

    substituteInPlace modules/bindings/glibc/linux.lisp --replace "(def-c-type __swblk_t)" ""
  '';

  configureFlags = "builddir"
  + stdenv.lib.optionalString (!dllSupport) " --without-dynamic-modules"
  + stdenv.lib.optionalString (readline != null) " --with-readline"
  + stdenv.lib.optionalString (libffi != null) " --with-dynamic-ffi"
  + stdenv.lib.optionalString (libffcall != null) " --with-ffcall"
  + stdenv.lib.concatMapStrings (x: " --with-module=" + x) withModules
  + stdenv.lib.optionalString threadSupport " --with-threads=POSIX_THREADS";

  preBuild = ''
    sed -e '/avcall.h/a\#include "config.h"' -i src/foreign.d
    cd builddir
  '';

  postInstall =
    stdenv.lib.optionalString (withModules != [])
      (''./clisp-link add "$out"/lib/clisp*/base "$(dirname "$out"/lib/clisp*/base)"/full''
      + stdenv.lib.concatMapStrings (x: " " + x) withModules);

  NIX_CFLAGS_COMPILE = "-O0 ${stdenv.lib.optionalString (!stdenv.is64bit) "-falign-functions=4"}";

  # TODO : make mod-check fails
  doCheck = false;

  meta = {
    description = "ANSI Common Lisp Implementation";
    homepage = http://clisp.cons.org;
    maintainers = with stdenv.lib.maintainers; [raskin tohl];
    platforms = stdenv.lib.platforms.linux;
  };
}