Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, fetchurl
4, fetchpatch
5, boehmgc
6, buildPackages
7, coverageAnalysis ? null
8, gawk
9, gmp
10, libffi
11, libtool
12, libunistring
13, makeWrapper
14, pkg-config
15, pkgsBuildBuild
16, readline
17}:
18
19let
20 # Do either a coverage analysis build or a standard build.
21 builder = if coverageAnalysis != null
22 then coverageAnalysis
23 else stdenv.mkDerivation;
24in
25builder rec {
26 pname = "guile";
27 version = "2.2.7";
28
29 src = fetchurl {
30 url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz";
31 sha256 = "013mydzhfswqci6xmyc1ajzd59pfbdak15i0b090nhr9bzm7dxyd";
32 };
33
34 outputs = [ "out" "dev" "info" ];
35 setOutputFlags = false; # $dev gets into the library otherwise
36
37 depsBuildBuild = [
38 buildPackages.stdenv.cc
39 ]
40 ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform)
41 pkgsBuildBuild.guile_2_2;
42 nativeBuildInputs = [
43 makeWrapper
44 pkg-config
45 ];
46 buildInputs = [
47 libffi
48 libtool
49 libunistring
50 readline
51 ];
52 propagatedBuildInputs = [
53 boehmgc
54 gmp
55
56 # XXX: These ones aren't normally needed here, but `libguile*.la' has '-l'
57 # flags for them without corresponding '-L' flags. Adding them here will add
58 # the needed `-L' flags. As for why the `.la' file lacks the `-L' flags,
59 # see below.
60 libtool
61 libunistring
62 ];
63
64 # According to Bernhard M. Wiedemann <bwiedemann suse de> on
65 # #reproducible-builds on irc.oftc.net, (2020-01-29): they had to
66 # build Guile without parallel builds to make it reproducible.
67 #
68 # re: https://issues.guix.gnu.org/issue/20272
69 # re: https://build.opensuse.org/request/show/732638
70 enableParallelBuilding = false;
71
72 patches = [
73 # Read the header of the patch to more info
74 ./eai_system.patch
75 ] ++ lib.optional (coverageAnalysis != null) ./gcov-file-name.patch
76 ++ lib.optional stdenv.isDarwin
77 (fetchpatch {
78 url = "https://gitlab.gnome.org/GNOME/gtk-osx/raw/52898977f165777ad9ef169f7d4818f2d4c9b731/patches/guile-clocktime.patch";
79 sha256 = "12wvwdna9j8795x59ldryv9d84c1j3qdk2iskw09306idfsis207";
80 });
81
82 # Explicitly link against libgcc_s, to work around the infamous
83 # "libgcc_s.so.1 must be installed for pthread_cancel to work".
84
85 # don't have "libgcc_s.so.1" on clang
86 LDFLAGS = lib.optionalString
87 (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) "-lgcc_s";
88
89 configureFlags = [
90 "--with-libreadline-prefix=${lib.getDev readline}"
91 ] ++ lib.optionals stdenv.isSunOS [
92 # Make sure the right <gmp.h> is found, and not the incompatible
93 # /usr/include/mp.h from OpenSolaris. See
94 # <https://lists.gnu.org/archive/html/hydra-users/2012-08/msg00000.html>
95 # for details.
96 "--with-libgmp-prefix=${lib.getDev gmp}"
97
98 # Same for these (?).
99 "--with-libunistring-prefix=${libunistring}"
100
101 # See below.
102 "--without-threads"
103 ];
104
105 postInstall = ''
106 wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin"
107 ''
108 # XXX: See http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18903 for
109 # why `--with-libunistring-prefix' and similar options coming from
110 # `AC_LIB_LINKFLAGS_BODY' don't work on NixOS/x86_64.
111 + ''
112 sed -i "$out/lib/pkgconfig/guile"-*.pc \
113 -e "s|-lunistring|-L${libunistring}/lib -lunistring|g ;
114 s|^Cflags:\(.*\)$|Cflags: -I${libunistring.dev}/include \1|g ;
115 s|-lltdl|-L${libtool.lib}/lib -lltdl|g ;
116 s|includedir=$out|includedir=$dev|g
117 "
118 '';
119
120 # make check doesn't work on darwin
121 # On Linuxes+Hydra the tests are flaky; feel free to investigate deeper.
122 doCheck = false;
123 doInstallCheck = doCheck;
124
125 setupHook = ./setup-hook-2.2.sh;
126
127 meta = with lib; {
128 homepage = "https://www.gnu.org/software/guile/";
129 description = "Embeddable Scheme implementation";
130 longDescription = ''
131 GNU Guile is an implementation of the Scheme programming language, with
132 support for many SRFIs, packaged for use in a wide variety of
133 environments. In addition to implementing the R5RS Scheme standard and a
134 large subset of R6RS, Guile includes a module system, full access to POSIX
135 system calls, networking support, multiple threads, dynamic linking, a
136 foreign function call interface, and powerful string processing.
137 '';
138 license = licenses.lgpl3Plus;
139 maintainers = with maintainers; [ ludo lovek323 vrthra ];
140 platforms = platforms.all;
141 };
142}