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 [
43 libffi
44 gmp
45 mpfr
46 cc
47 # replaces ecl's own gc which other packages can depend on, thus propagated
48 ]
49 ++ lib.optionals useBoehmgc [
50 # replaces ecl's own gc which other packages can depend on, thus propagated
51 boehmgc
52 ];
53
54 patches = [
55 # https://gitlab.com/embeddable-common-lisp/ecl/-/merge_requests/1
56 (fetchpatch {
57 url = "https://raw.githubusercontent.com/sagemath/sage/9.2/build/pkgs/ecl/patches/write_error.patch";
58 sha256 = "0hfxacpgn4919hg0mn4wf4m8r7y592r4gw7aqfnva7sckxi6w089";
59 })
60 ];
61
62 configureFlags =
63 [
64 (if threadSupport then "--enable-threads" else "--disable-threads")
65 "--with-gmp-incdir=${lib.getDev gmp}/include"
66 "--with-gmp-libdir=${lib.getLib gmp}/lib"
67 "--with-libffi-incdir=${lib.getDev libffi}/include"
68 "--with-libffi-libdir=${lib.getLib libffi}/lib"
69 ]
70 ++ lib.optionals useBoehmgc [
71 "--with-libgc-incdir=${lib.getDev boehmgc}/include"
72 "--with-libgc-libdir=${lib.getLib boehmgc}/lib"
73 ]
74 ++ lib.optional (!noUnicode) "--enable-unicode";
75
76 hardeningDisable = [ "format" ];
77
78 # ECL’s ‘make check’ only works after install, making it a de-facto
79 # installCheck.
80 doInstallCheck = true;
81 installCheckTarget = "check";
82
83 postInstall = ''
84 sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config
85 wrapProgram "$out/bin/ecl" --prefix PATH ':' "${
86 lib.makeBinPath [
87 cc # for the C compiler
88 cc.bintools.bintools # for ar
89 ]
90 }"
91 '';
92
93 meta = with lib; {
94 description = "Lisp implementation aiming to be small, fast and easy to embed";
95 homepage = "https://common-lisp.net/project/ecl/";
96 license = licenses.mit;
97 mainProgram = "ecl";
98 teams = [ lib.teams.lisp ];
99 platforms = platforms.unix;
100 changelog = "https://gitlab.com/embeddable-common-lisp/ecl/-/raw/${version}/CHANGELOG";
101 };
102}