1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 libtool,
7 autoconf,
8 automake,
9 texinfo,
10 gmp,
11 mpfr,
12 libffi,
13 makeWrapper,
14 noUnicode ? false,
15 gcc,
16 clang,
17 threadSupport ? true,
18 useBoehmgc ? false,
19 boehmgc,
20}:
21
22let
23 cc = if stdenv.cc.isClang then clang else gcc;
24in
25stdenv.mkDerivation rec {
26 pname = "ecl";
27 version = "24.5.10";
28
29 src = fetchurl {
30 url = "https://common-lisp.net/project/ecl/static/files/release/ecl-${version}.tgz";
31 hash = "sha256-5Opluxhh4OSVOGv6i8ZzvQFOltPPnZHpA4+RQ1y+Yis=";
32 };
33
34 nativeBuildInputs = [
35 libtool
36 autoconf
37 automake
38 texinfo
39 makeWrapper
40 ];
41 propagatedBuildInputs = [
42 libffi
43 gmp
44 mpfr
45 cc
46 # replaces ecl's own gc which other packages can depend on, thus propagated
47 ]
48 ++ lib.optionals useBoehmgc [
49 # replaces ecl's own gc which other packages can depend on, thus propagated
50 boehmgc
51 ];
52
53 patches = [
54 # https://gitlab.com/embeddable-common-lisp/ecl/-/merge_requests/1
55 (fetchpatch {
56 url = "https://raw.githubusercontent.com/sagemath/sage/9.2/build/pkgs/ecl/patches/write_error.patch";
57 sha256 = "0hfxacpgn4919hg0mn4wf4m8r7y592r4gw7aqfnva7sckxi6w089";
58 })
59 ];
60
61 configureFlags = [
62 (if threadSupport then "--enable-threads" else "--disable-threads")
63 "--with-gmp-incdir=${lib.getDev gmp}/include"
64 "--with-gmp-libdir=${lib.getLib gmp}/lib"
65 "--with-libffi-incdir=${lib.getDev libffi}/include"
66 "--with-libffi-libdir=${lib.getLib libffi}/lib"
67 ]
68 ++ lib.optionals useBoehmgc [
69 "--with-libgc-incdir=${lib.getDev boehmgc}/include"
70 "--with-libgc-libdir=${lib.getLib boehmgc}/lib"
71 ]
72 ++ lib.optional (!noUnicode) "--enable-unicode";
73
74 hardeningDisable = [ "format" ];
75
76 # ECL’s ‘make check’ only works after install, making it a de-facto
77 # installCheck.
78 doInstallCheck = true;
79 installCheckTarget = "check";
80
81 postInstall = ''
82 sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config
83 wrapProgram "$out/bin/ecl" --prefix PATH ':' "${
84 lib.makeBinPath [
85 cc # for the C compiler
86 cc.bintools.bintools # for ar
87 ]
88 }"
89 '';
90
91 meta = with lib; {
92 description = "Lisp implementation aiming to be small, fast and easy to embed";
93 homepage = "https://common-lisp.net/project/ecl/";
94 license = licenses.mit;
95 mainProgram = "ecl";
96 teams = [ lib.teams.lisp ];
97 platforms = platforms.unix;
98 changelog = "https://gitlab.com/embeddable-common-lisp/ecl/-/raw/${version}/CHANGELOG";
99 };
100}