gnu: linux-libre-headers: Update to 4.19.56.
[jackhill/guix/guix.git] / gnu / packages / base.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
0e6cee21 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
28317d49 3;;; Copyright © 2014, 2019 Andreas Enge <andreas@enge.fr>
233e7676 4;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
4e50f1f2 5;;; Copyright © 2014, 2015, 2016, 2018 Mark H Weaver <mhw@netris.org>
4c8425b7 6;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
21a8fe1b 7;;; Copyright © 2014, 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
17f43346 8;;; Copyright © 2016, 2017, 2019 Efraim Flashner <efraim@flashner.co.il>
7309045c 9;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
ad3c9f18 10;;; Copyright © 2016, 2018 Alex Vong <alexvong1995@gmail.com>
b81d11e5 11;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
da8e256a 12;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
cd50b9f0 13;;; Copyright © 2017, 2018 Marius Bakke <mbakke@fastmail.com>
acc2dab7 14;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
c04e5116 15;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
0845999a 16;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
e3ce5d70 17;;;
233e7676 18;;; This file is part of GNU Guix.
e3ce5d70 19;;;
233e7676 20;;; GNU Guix is free software; you can redistribute it and/or modify it
e3ce5d70
LC
21;;; under the terms of the GNU General Public License as published by
22;;; the Free Software Foundation; either version 3 of the License, or (at
23;;; your option) any later version.
24;;;
233e7676 25;;; GNU Guix is distributed in the hope that it will be useful, but
e3ce5d70
LC
26;;; WITHOUT ANY WARRANTY; without even the implied warranty of
27;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28;;; GNU General Public License for more details.
29;;;
30;;; You should have received a copy of the GNU General Public License
233e7676 31;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
e3ce5d70 32
1ffa7090 33(define-module (gnu packages base)
c6d7e299 34 #:use-module ((guix licenses)
7309045c 35 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
59a43334 36 #:use-module (gnu packages)
1ffa7090 37 #:use-module (gnu packages acl)
28317d49 38 #:use-module (gnu packages algebra)
1ffa7090 39 #:use-module (gnu packages bash)
5e8cb5e6 40 #:use-module (gnu packages bison)
b5ef82e0 41 #:use-module (gnu packages ed)
28317d49 42 #:use-module (gnu packages gcc)
1ffa7090
LC
43 #:use-module (gnu packages guile)
44 #:use-module (gnu packages multiprecision)
c9505f3f 45 #:use-module (gnu packages compression)
1ffa7090
LC
46 #:use-module (gnu packages perl)
47 #:use-module (gnu packages linux)
20bf5fce 48 #:use-module (gnu packages pcre)
8fd6487e 49 #:use-module (gnu packages texinfo)
21a8fe1b 50 #:use-module (gnu packages hurd)
aa6b0d6b 51 #:use-module (gnu packages pkg-config)
a635ed5c 52 #:use-module (gnu packages gettext)
aee6180c 53 #:use-module (guix utils)
e3ce5d70 54 #:use-module (guix packages)
87f5d366 55 #:use-module (guix download)
21a8fe1b 56 #:use-module (guix git-download)
c9505f3f 57 #:use-module (guix build-system gnu)
b09617da
MR
58 #:use-module (guix build-system trivial)
59 #:use-module (ice-9 match)
28317d49
EF
60 #:use-module (srfi srfi-1)
61 #:use-module (srfi srfi-26)
4dab8c59
JN
62 #:export (glibc
63 libiconv-if-needed))
e3ce5d70
LC
64
65;;; Commentary:
66;;;
1722d680 67;;; Base packages of the Guix-based GNU user-land software distribution.
e3ce5d70
LC
68;;;
69;;; Code:
70
71(define-public hello
72 (package
17d8e33f
ML
73 (name "hello")
74 (version "2.10")
75 (source (origin
76 (method url-fetch)
77 (uri (string-append "mirror://gnu/hello/hello-" version
78 ".tar.gz"))
79 (sha256
80 (base32
81 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
82 (build-system gnu-build-system)
83 (synopsis "Hello, GNU world: An example GNU package")
84 (description
85 "GNU Hello prints the message \"Hello, world!\" and then exits. It
a22dc0c4
LC
86serves as an example of standard GNU coding practices. As such, it supports
87command-line arguments, multiple languages, and so on.")
6fd52309 88 (home-page "https://www.gnu.org/software/hello/")
17d8e33f 89 (license gpl3+)))
d7672884 90
6794b278
LC
91(define-public grep
92 (package
93 (name "grep")
b659e97a 94 (version "3.3")
6794b278 95 (source (origin
87f5d366 96 (method url-fetch)
0db342a5 97 (uri (string-append "mirror://gnu/grep/grep-"
6794b278
LC
98 version ".tar.xz"))
99 (sha256
100 (base32
b659e97a 101 "055mqp6vrd0brkygmygb2673qwz409a7kyp1mzbfy6cn94f58q5r"))
63adf0fd 102 (patches (search-patches "grep-timing-sensitive-test.patch"))))
6794b278 103 (build-system gnu-build-system)
304e4f51 104 (native-inputs `(("perl" ,perl))) ;some of the tests require it
20bf5fce 105 (inputs `(("pcre" ,pcre)))
1063d325
MW
106 (arguments
107 `(#:phases
108 (modify-phases %standard-phases
109 (add-after 'install 'fix-egrep-and-fgrep
110 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
111 ;; absolute file name instead of searching for it in $PATH.
112 (lambda* (#:key outputs #:allow-other-keys)
113 (let* ((out (assoc-ref outputs "out"))
114 (bin (string-append out "/bin")))
115 (substitute* (list (string-append bin "/egrep")
116 (string-append bin "/fgrep"))
117 (("^exec grep")
118 (string-append "exec " bin "/grep")))
119 #t))))))
f50d2669 120 (synopsis "Print lines matching a pattern")
d45122f5 121 (description
12bcf94a 122 "grep is a tool for finding text inside files. Text is found by
a22dc0c4 123matching a pattern provided by the user in one or many files. The pattern
79c311b8
LC
124may be provided as a basic or extended regular expression, or as fixed
125strings. By default, the matching text is simply printed to the screen,
126however the output can be greatly customized to include, for example, line
127numbers. GNU grep offers many extensions over the standard utility,
128including, for example, recursive directory searching.")
4a44e743 129 (license gpl3+)
6fd52309 130 (home-page "https://www.gnu.org/software/grep/")))
6794b278 131
8dcad9aa
LC
132(define-public sed
133 (package
134 (name "sed")
dad2e7dc 135 (version "4.7")
8dcad9aa 136 (source (origin
87f5d366 137 (method url-fetch)
0db342a5 138 (uri (string-append "mirror://gnu/sed/sed-" version
7d7ea947 139 ".tar.xz"))
8dcad9aa
LC
140 (sha256
141 (base32
dad2e7dc 142 "0smxcx66vx29djzb542nxcynl7qnzxqa5032ibazi7x2s267d198"))))
8dcad9aa 143 (build-system gnu-build-system)
f50d2669 144 (synopsis "Stream editor")
301a4249
LC
145 (native-inputs
146 `(("perl" ,perl))) ;for tests
d45122f5 147 (description
a22dc0c4
LC
148 "Sed is a non-interactive, text stream editor. It receives a text
149input from a file or from standard input and it then applies a series of text
150editing commands to the stream and prints its output to standard output. It
79c311b8
LC
151is often used for substituting text patterns in a stream. The GNU
152implementation offers several extensions over the standard utility.")
4a44e743 153 (license gpl3+)
7d7ea947 154 (home-page "https://www.gnu.org/software/sed/")))
8dcad9aa 155
85240322
LC
156(define-public tar
157 (package
158 (name "tar")
218eb6e6 159 (version "1.32")
85240322 160 (source (origin
87f5d366 161 (method url-fetch)
0db342a5 162 (uri (string-append "mirror://gnu/tar/tar-"
d6535cf1 163 version ".tar.xz"))
85240322
LC
164 (sha256
165 (base32
218eb6e6 166 "1n7xy657ii0sa42zx6944v2m4v9qrh6sqgmw17l3nch3y43sxlyh"))
45413064
MW
167 (patches (search-patches "tar-skip-unreliable-tests.patch"
168 "tar-remove-wholesparse-check.patch"))))
85240322 169 (build-system gnu-build-system)
74d63739
LC
170 ;; Note: test suite requires ~1GiB of disk space.
171 (arguments
c77835db 172 `(#:phases (modify-phases %standard-phases
74d63739
LC
173 (add-before 'build 'set-shell-file-name
174 (lambda* (#:key inputs #:allow-other-keys)
175 ;; Do not use "/bin/sh" to run programs.
176 (let ((bash (assoc-ref inputs "bash")))
177 (substitute* "src/system.c"
178 (("/bin/sh")
179 (string-append bash "/bin/sh")))
218eb6e6 180 #t))))))
bbe03294
LC
181
182 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
183 ;; to refer to the target Bash.
184 (inputs (if (%current-target-system)
185 `(("bash" ,bash))
186 '()))
187
f50d2669 188 (synopsis "Managing tar archives")
d45122f5 189 (description
a22dc0c4
LC
190 "Tar provides the ability to create tar archives, as well as the
191ability to extract, update or list files in an existing archive. It is
192useful for combining many files into one larger file, while maintaining
193directory structure and file information such as permissions and
79c311b8
LC
194creation/modification dates. GNU tar offers many extensions over the
195standard utility.")
4a44e743 196 (license gpl3+)
6fd52309 197 (home-page "https://www.gnu.org/software/tar/")))
85240322 198
fbeec3d9
LC
199(define-public patch
200 (package
201 (name "patch")
ec07ba1f 202 (version "2.7.6")
f6408bc5
LC
203 (source (origin
204 (method url-fetch)
205 (uri (string-append "mirror://gnu/patch/patch-"
206 version ".tar.xz"))
207 (sha256
208 (base32
ec07ba1f 209 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
fc1adab1 210 (patches (search-patches "patch-hurd-path-max.patch"))))
fbeec3d9 211 (build-system gnu-build-system)
d3878d3d
LC
212 (arguments
213 ;; Work around a cross-compilation bug whereby libpatch.a would provide
214 ;; '__mktime_internal', which conflicts with the one in libc.a.
215 (if (%current-target-system)
216 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
217 '()))
b3546174 218 (native-inputs `(("ed" ,ed)))
f50d2669 219 (synopsis "Apply differences to originals, with optional backups")
d45122f5 220 (description
a22dc0c4 221 "Patch is a program that applies changes to files based on differences
79c311b8 222laid out as by the program \"diff\". The changes may be applied to one or more
a22dc0c4
LC
223files depending on the contents of the diff file. It accepts several
224different diff formats. It may also be used to revert previously applied
225differences.")
4a44e743 226 (license gpl3+)
6fd52309 227 (home-page "https://savannah.gnu.org/projects/patch/")))
fbeec3d9 228
04a32ee5
LC
229(define-public diffutils
230 (package
231 (name "diffutils")
e992d566 232 (version "3.7")
04a32ee5 233 (source (origin
87f5d366 234 (method url-fetch)
0db342a5 235 (uri (string-append "mirror://gnu/diffutils/diffutils-"
04a32ee5
LC
236 version ".tar.xz"))
237 (sha256
238 (base32
e992d566 239 "09isrg0isjinv8c535nxsi1s86wfdfzml80dbw41dj9x3hiad9xk"))))
04a32ee5 240 (build-system gnu-build-system)
e992d566 241 (native-inputs `(("perl" ,perl)))
f50d2669 242 (synopsis "Comparing and merging files")
d45122f5 243 (description
79c311b8
LC
244 "GNU Diffutils is a package containing tools for finding the
245differences between files. The \"diff\" command is used to show how two files
e881752c 246differ, while \"cmp\" shows the offsets and line numbers where they differ.
79c311b8 247\"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
a22dc0c4 248interactive means to merge two files.")
4a44e743 249 (license gpl3+)
6fd52309 250 (home-page "https://www.gnu.org/software/diffutils/")))
04a32ee5 251
af5521ca
LC
252(define-public findutils
253 (package
254 (name "findutils")
e80d2555 255 (version "4.6.0")
af5521ca 256 (source (origin
87f5d366 257 (method url-fetch)
0db342a5 258 (uri (string-append "mirror://gnu/findutils/findutils-"
af5521ca
LC
259 version ".tar.gz"))
260 (sha256
261 (base32
e80d2555 262 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
da8e256a 263 (patches (search-patches
2fa4066c 264 "findutils-gnulib-libio.patch"
da8e256a 265 "findutils-localstatedir.patch"
2fa4066c 266 "findutils-makedev.patch"
acc2dab7
EB
267 "findutils-test-xargs.patch"))
268 (modules '((guix build utils)))
269 (snippet
270 '(begin
271 ;; The gnulib test-lock test is prone to writer starvation
272 ;; with our glibc@2.25, which prefers readers, so disable it.
273 ;; The gnulib commit b20e8afb0b2 should fix this once
274 ;; incorporated here.
275 (substitute* "tests/Makefile.in"
276 (("test-lock\\$\\(EXEEXT\\) ") ""))
277 #t))))
af5521ca 278 (build-system gnu-build-system)
af5521ca 279 (arguments
67dfa198
LC
280 `(#:configure-flags (list
281 ;; Tell 'updatedb' to write to /var.
282 "--localstatedir=/var"
283
284 ;; Work around cross-compilation failure. See
285 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
286 ,@(if (%current-target-system)
287 '("gl_cv_func_wcwidth_works=yes")
288 '()))))
f50d2669 289 (synopsis "Operating on files matching given criteria")
d45122f5 290 (description
a22dc0c4
LC
291 "Findutils supplies the basic file directory searching utilities of the
292GNU system. It consists of two primary searching utilities: \"find\"
293recursively searches for files in a directory according to given criteria and
294\"locate\" lists files in a database that match a query. Two auxiliary tools
79c311b8
LC
295are included: \"updatedb\" updates the file name database and \"xargs\" may be
296used to apply commands with arbitrarily long arguments.")
4a44e743 297 (license gpl3+)
6fd52309 298 (home-page "https://www.gnu.org/software/findutils/")))
2c957cd2
LC
299
300(define-public coreutils
301 (package
302 (name "coreutils")
cf826436 303 (version "8.31")
2c957cd2 304 (source (origin
87f5d366 305 (method url-fetch)
0db342a5 306 (uri (string-append "mirror://gnu/coreutils/coreutils-"
2c957cd2
LC
307 version ".tar.xz"))
308 (sha256
309 (base32
cf826436 310 "1zg9m79x1i2nifj4kb0waf9x3i5h6ydkypkjnbsb9rnwis8rqypz"))))
2c957cd2 311 (build-system gnu-build-system)
de59af4d 312 (inputs `(("acl" ,acl) ; TODO: add SELinux
09cc7729 313 ("gmp" ,gmp) ;bignums in 'expr', yay!
62ea8865
LC
314
315 ;; Drop the dependency on libcap when cross-compiling since it's
316 ;; not quite cross-compilable.
317 ,@(if (%current-target-system)
318 '()
319 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
2c1dea85
LC
320 (native-inputs
321 ;; Perl is needed to run tests in native builds, and to run the bundled
7f31c71c
LC
322 ;; copy of help2man. However, don't pass it when cross-compiling since
323 ;; that would lead it to try to run programs to get their '--help' output
324 ;; for help2man.
1cbd63f2
LC
325 (if (%current-target-system)
326 '()
327 `(("perl" ,perl))))
9bf62d9b 328 (outputs '("out" "debug"))
2c957cd2 329 (arguments
8ba8aeb7 330 `(#:parallel-build? #f ; help2man may be called too early
656a5ba0
EF
331 #:phases (modify-phases %standard-phases
332 (add-before 'build 'patch-shell-references
333 (lambda _
334 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
335 ;; that tests pass, since /bin/sh isn't in the chroot.
336 (setenv "SHELL" (which "sh"))
b47b2b52 337
656a5ba0
EF
338 (substitute* (find-files "gnulib-tests" "\\.c$")
339 (("/bin/sh") (which "sh")))
340 (substitute* (find-files "tests" "\\.sh$")
a8dcf6ce
MB
341 (("#!/bin/sh") (string-append "#!" (which "sh"))))
342 #t))
343 (add-before 'check 'disable-broken-test
344 (lambda _
345 ;; This test hits the 127 character shebang limit in the build
346 ;; environment due to the way "env -S" splits arguments into
347 ;; shebangs. Note that "env-S-script.sh" works around this
348 ;; specific issue, but "env-S.pl" is not adjusted for build
349 ;; environments with long prefixes (/tmp/guix-build-...).
350 (substitute* "Makefile"
351 (("^.*tests/misc/env-S.pl.*$") ""))
cf826436 352 #t)))))
f50d2669 353 (synopsis "Core GNU utilities (file, text, shell)")
d45122f5 354 (description
79c311b8 355 "GNU Coreutils includes all of the basic command-line tools that are
a22dc0c4
LC
356expected in a POSIX system. These provide the basic file, shell and text
357manipulation functions of the GNU system. Most of these tools offer extended
358functionality beyond that which is outlined in the POSIX standard.")
4a44e743 359 (license gpl3+)
6fd52309 360 (home-page "https://www.gnu.org/software/coreutils/")))
af5521ca 361
d0f74308 362(define-public coreutils-minimal
28cbc587
LC
363 ;; Coreutils without its optional dependencies.
364 (package
365 (inherit coreutils)
d0f74308 366 (name "coreutils-minimal")
28cbc587
LC
367 (outputs '("out"))
368 (inputs '())))
369
ab776865
LC
370(define-public gnu-make
371 (package
372 (name "make")
6d2b94f2 373 (version "4.2.1")
ab776865 374 (source (origin
87f5d366 375 (method url-fetch)
0db342a5 376 (uri (string-append "mirror://gnu/make/make-" version
ab776865
LC
377 ".tar.bz2"))
378 (sha256
379 (base32
6d2b94f2 380 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
e9b9ea1e
MB
381 (patches (search-patches "make-impure-dirs.patch"
382 "make-glibc-compat.patch"))))
ab776865 383 (build-system gnu-build-system)
b3546174 384 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
ed41d48e 385 (inputs `(("guile" ,guile-2.0)))
9bf62d9b 386 (outputs '("out" "debug"))
ea8fbbf2 387 (arguments
e9b9ea1e
MB
388 '(;; Work around faulty glob detection with glibc 2.27. See
389 ;; <https://lists.nongnu.org/archive/html/bug-make/2017-11/msg00027.html>.
390 #:configure-flags '("make_cv_sys_gnu_glob=yes")
391 #:phases
6cc83b68
EF
392 (modify-phases %standard-phases
393 (add-before 'build 'set-default-shell
394 (lambda* (#:key inputs #:allow-other-keys)
395 ;; Change the default shell from /bin/sh.
396 (let ((bash (assoc-ref inputs "bash")))
397 (substitute* "job.c"
398 (("default_shell =.*$")
60f3ad8c 399 (format #f "default_shell = \"~a/bin/sh\";\n"
759ad069
MB
400 bash)))
401 #t))))))
f50d2669 402 (synopsis "Remake files automatically")
d45122f5 403 (description
a22dc0c4
LC
404 "Make is a program that is used to control the production of
405executables or other files from their source files. The process is
406controlled from a Makefile, in which the developer specifies how each file is
407generated from its source. It has powerful dependency resolution and the
408ability to determine when files have to be regenerated after their sources
79c311b8 409change. GNU make offers many powerful extensions over the standard utility.")
4a44e743 410 (license gpl3+)
6fd52309 411 (home-page "https://www.gnu.org/software/make/")))
ab776865 412
8f6201a3
LC
413(define-public binutils
414 (package
415 (name "binutils")
dfc941a9 416 (version "2.32")
8f6201a3 417 (source (origin
87f5d366 418 (method url-fetch)
0db342a5 419 (uri (string-append "mirror://gnu/binutils/binutils-"
8f6201a3
LC
420 version ".tar.bz2"))
421 (sha256
422 (base32
dfc941a9 423 "0b8767nyal1bc4cyzg5h9iis8kpkln1i3wkamig75cifj1fb2f6y"))
ff19532f 424 (patches (search-patches "binutils-loongson-workaround.patch"))))
8f6201a3
LC
425 (build-system gnu-build-system)
426
427 ;; TODO: Add dependency on zlib + those for Gold.
8f6201a3 428 (arguments
de80b504 429 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
01d45404
LC
430 ;; on GCC when bootstrapping.
431 "LDFLAGS=-static-libgcc"
8f6201a3 432
ff19532f
MB
433 ;; Turn on --enable-new-dtags by default to make the
434 ;; linker set RUNPATH instead of RPATH on binaries.
435 ;; This is important because RUNPATH can be overriden
436 ;; using LD_LIBRARY_PATH at runtime.
437 "--enable-new-dtags"
438
01d45404 439 ;; Don't search under /usr/lib & co.
444c64b0
LC
440 "--with-lib-path=/no-ld-lib-path"
441
6c95f363
LC
442 ;; Install BFD. It ends up in a hidden directory,
443 ;; but it's here.
cc0a1282
LC
444 "--enable-install-libbfd"
445
446 ;; Make sure 'ar' and 'ranlib' produce archives in a
447 ;; deterministic fashion.
448 "--enable-deterministic-archives")))
8f6201a3 449
f50d2669 450 (synopsis "Binary utilities: bfd gas gprof ld")
d45122f5 451 (description
a22dc0c4 452 "GNU Binutils is a collection of tools for working with binary files.
c5779c93
LC
453Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
454Other tools include programs to display binary profiling information, list
455the strings in a binary file, and utilities for working with archives. The
456\"bfd\" library for working with executable and object formats is also
457included.")
4a44e743 458 (license gpl3+)
6fd52309 459 (home-page "https://www.gnu.org/software/binutils/")))
8f6201a3 460
28317d49
EF
461(define-public binutils-gold
462 (package
463 (inherit binutils)
464 (name "binutils-gold")
465 (arguments
466 `(#:phases
467 (modify-phases %standard-phases
468 (add-after 'patch-source-shebangs 'patch-more-shebangs
469 (lambda _
470 (substitute* "gold/Makefile.in"
471 (("/bin/sh") (which "sh")))
472 #t)))
473 ,@(substitute-keyword-arguments (package-arguments binutils)
474 ; Upstream is aware of unrelocatable test failures on arm*.
475 ((#:tests? _ #f)
476 (if (any (cute string-prefix? <> (or (%current-target-system)
477 (%current-system)))
478 '("i686" "x86_64"))
479 '#t '#f))
480 ((#:configure-flags flags)
481 `(cons* "--enable-gold=default"
482 (delete "LDFLAGS=-static-libgcc" ,flags))))))
483 (native-inputs
484 `(("bc" ,bc)))
485 (inputs
486 `(("gcc:lib" ,gcc "lib")))))
487
5bde4503
LC
488(define* (make-ld-wrapper name #:key
489 (target (const #f))
490 binutils
78dea6f1 491 (guile (canonical-package guile-2.2))
5bde4503 492 (bash (canonical-package bash))
8fdd4101
LC
493 (guile-for-build guile))
494 "Return a package called NAME that contains a wrapper for the 'ld' program
5bde4503
LC
495of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
496wrapper uses GUILE and BASH.
497
498TARGET must be a one-argument procedure that, given a system type, returns a
499cross-compilation target triplet or #f. When the result is not #f, make a
500wrapper for the cross-linker for that target, called 'TARGET-ld'."
501 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
502 ;; its result can be delayed until the 'arguments' field is evaluated, thus
503 ;; in a context where '%current-system' is accurate.
8fdd4101
LC
504 (package
505 (name name)
506 (version "0")
507 (source #f)
508 (build-system trivial-build-system)
509 (inputs `(("binutils" ,binutils)
510 ("guile" ,guile)
511 ("bash" ,bash)
512 ("wrapper" ,(search-path %load-path
c8bfa5b4 513 "gnu/packages/ld-wrapper.in"))))
8fdd4101 514 (arguments
5bde4503
LC
515 (let ((target (target (%current-system))))
516 `(#:guile ,guile-for-build
517 #:modules ((guix build utils))
518 #:builder (begin
519 (use-modules (guix build utils)
520 (system base compile))
8fdd4101 521
5bde4503
LC
522 (let* ((out (assoc-ref %outputs "out"))
523 (bin (string-append out "/bin"))
524 (ld ,(if target
525 `(string-append bin "/" ,target "-ld")
526 '(string-append bin "/ld")))
527 (go (string-append ld ".go")))
8fdd4101 528
5bde4503
LC
529 (setvbuf (current-output-port) _IOLBF)
530 (format #t "building ~s/bin/ld wrapper in ~s~%"
531 (assoc-ref %build-inputs "binutils")
532 out)
8fdd4101 533
5bde4503
LC
534 (mkdir-p bin)
535 (copy-file (assoc-ref %build-inputs "wrapper") ld)
536 (substitute* ld
537 (("@SELF@")
538 ld)
539 (("@GUILE@")
540 (string-append (assoc-ref %build-inputs "guile")
541 "/bin/guile"))
542 (("@BASH@")
543 (string-append (assoc-ref %build-inputs "bash")
544 "/bin/bash"))
545 (("@LD@")
546 (string-append (assoc-ref %build-inputs "binutils")
547 ,(if target
548 (string-append "/bin/"
549 target "-ld")
550 "/bin/ld"))))
551 (chmod ld #o555)
e3cfef22
MW
552 (compile-file ld #:output-file go)
553 #t)))))
8fdd4101
LC
554 (synopsis "The linker wrapper")
555 (description
36a4366d
EF
556 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
557missing @code{-rpath} flags, and to detect any misuse of libraries outside of
558the store.")
6fd52309 559 (home-page "https://www.gnu.org/software/guix//")
8fdd4101
LC
560 (license gpl3+)))
561
562(export make-ld-wrapper)
563
2d546858
LC
564(define-public glibc
565 ;; This is the GNU C Library, used on GNU/Linux and GNU/Hurd. Prior to
566 ;; version 2.28, GNU/Hurd used a different glibc branch.
7cdeac02
LC
567 (package
568 (name "glibc")
c6bc8e22
MB
569 ;; Note: Always use a dot after the minor version since various places rely
570 ;; on "version-major+minor" to determine where locales are found.
e13b5474 571 (version "2.28")
7cdeac02 572 (source (origin
87f5d366 573 (method url-fetch)
5e8cb5e6 574 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
7cdeac02
LC
575 (sha256
576 (base32
e13b5474 577 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
13990c73
LC
578 (snippet
579 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
580 ;; required on LFS distros to avoid loading the distro's libc.so
581 ;; instead of ours.
6cbee49d
MW
582 '(begin
583 (substitute* "sysdeps/unix/sysv/linux/configure"
584 (("use_ldconfig=yes")
585 "use_ldconfig=no"))
586 #t))
1faca892 587 (modules '((guix build utils)))
c3052d6b 588 (patches (search-patches "glibc-ldd-x86_64.patch"
e13b5474 589 "glibc-2.28-git-fixes.patch"
5e8cb5e6 590 "glibc-hidden-visibility-ldconfig.patch"
c3052d6b 591 "glibc-versioned-locpath.patch"
6422bde9 592 "glibc-allow-kernel-2.6.32.patch"
1b9fb043 593 "glibc-reinstate-prlimit64-fallback.patch"
ef582109 594 "glibc-hurd-magic-pid.patch"
1b9fb043 595 "glibc-supported-locales.patch"))))
7cdeac02 596 (build-system gnu-build-system)
0a3da5b7
LC
597
598 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
2d546858
LC
599 ;; users should automatically pull Linux headers as well. On GNU/Hurd,
600 ;; libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
601 ;; so both should be propagated.
602 (propagated-inputs
603 (if (hurd-target?)
604 `(("hurd-core-headers" ,hurd-core-headers))
605 `(("kernel-headers" ,linux-libre-headers))))
0a3da5b7 606
6dff905e
LC
607 (outputs '("out" "debug"
608 "static")) ;9 MiB of .a files
7f614e49 609
7cdeac02 610 (arguments
8197c978 611 `(#:out-of-source? #t
211db2f6 612
112da588 613 ;; The libraries have an empty RUNPATH, but some, such as the versioned
67fcf235 614 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
112da588
LC
615 ;; these libraries are always going to be found anyway, just skip
616 ;; RUNPATH checks.
617 #:validate-runpath? #f
618
6dff905e
LC
619 #:modules ((ice-9 ftw)
620 (srfi srfi-26)
621 (guix build utils)
622 (guix build gnu-build-system))
623
7cdeac02 624 #:configure-flags
5e8cb5e6 625 (list "--sysconfdir=/etc"
7f614e49 626
97e11209
LC
627 ;; Installing a locale archive with all the locales is to
628 ;; expensive (~100 MiB), so we rely on users to install the
629 ;; locales they really want.
630 ;;
631 ;; Set the default locale path. In practice, $LOCPATH may be
632 ;; defined to point whatever locales users want. However, setuid
633 ;; binaries don't honor $LOCPATH, so they'll instead look into
9f58fe3d 634 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
46bd6edd
LC
635 ;; with the idea that it is going to be populated by the sysadmin.
636 ;; The "X.Y" sub-directory is because locale data formats are
637 ;; incompatible across libc versions; see
638 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
97e11209 639 ;;
7f614e49
LC
640 ;; `--localedir' is not honored, so work around it.
641 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
9f58fe3d 642 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
c6bc8e22 643 ,(version-major+minor version))
7f614e49 644
7cdeac02 645 (string-append "--with-headers="
28dc10a4
LC
646 (assoc-ref ,(if (%current-target-system)
647 '%build-target-inputs
648 '%build-inputs)
aeafff53 649 "kernel-headers")
7cdeac02 650 "/include")
5f456680 651
67d527e3 652 ;; This is the default for most architectures as of GNU libc 2.26,
39ccbfad
MW
653 ;; but we specify it explicitly for clarity and consistency. See
654 ;; "kernel-features.h" in the GNU libc for details.
67d527e3 655 "--enable-kernel=3.2.0"
5f456680 656
6e32f6c0 657 ;; Use our Bash instead of /bin/sh.
8cd8e97c 658 (string-append "BASH_SHELL="
6e32f6c0 659 (assoc-ref %build-inputs "bash")
2d546858
LC
660 "/bin/bash")
661
662 ;; On GNU/Hurd we get discarded-qualifiers warnings for
663 ;; 'device_write_inband' among other things. Ignore them.
664 ,@(if (hurd-target?)
665 '("--disable-werror")
666 '()))
6e32f6c0 667
7cdeac02 668 #:tests? #f ; XXX
57f65bcc
LC
669 #:phases (modify-phases %standard-phases
670 (add-before
671 'configure 'pre-configure
672 (lambda* (#:key inputs native-inputs outputs
673 #:allow-other-keys)
674 (let* ((out (assoc-ref outputs "out"))
675 (bin (string-append out "/bin"))
676 ;; FIXME: Normally we would look it up only in INPUTS
677 ;; but cross-base uses it as a native input.
678 (bash (or (assoc-ref inputs "static-bash")
679 (assoc-ref native-inputs "static-bash"))))
57f65bcc
LC
680 ;; Install the rpc data base file under `$out/etc/rpc'.
681 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
682 (substitute* "sunrpc/Makefile"
683 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
684 (string-append out "/etc/rpc" suffix "\n"))
685 (("^install-others =.*$")
686 (string-append "install-others = " out "/etc/rpc\n")))
687
688 (substitute* "Makeconfig"
689 ;; According to
690 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
691 ;; linking against libgcc_s is not needed with GCC
692 ;; 4.7.1.
693 ((" -lgcc_s") ""))
694
695 ;; Have `system' use that Bash.
696 (substitute* "sysdeps/posix/system.c"
697 (("#define[[:blank:]]+SHELL_PATH.*$")
698 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
699 bash)))
700
701 ;; Same for `popen'.
702 (substitute* "libio/iopopen.c"
703 (("/bin/sh")
11b66876 704 (string-append bash "/bin/sh")))
57f65bcc 705
d56f8d5e
LC
706 ;; Same for the shell used by the 'exec' functions for
707 ;; scripts that lack a shebang.
708 (substitute* (find-files "." "^paths\\.h$")
709 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
710 (string-append "#define _PATH_BSHELL \""
e4831391 711 bash "/bin/sh\"\n")))
d56f8d5e 712
c5b65f7e
LC
713 ;; Nscd uses __DATE__ and __TIME__ to create a string to
714 ;; make sure the client and server come from the same
715 ;; libc. Use something deterministic instead.
716 (substitute* "nscd/nscd_stat.c"
717 (("static const char compilation\\[21\\] =.*$")
718 (string-append
719 "static const char compilation[21] = \""
720 (string-take (basename out) 20) "\";\n")))
721
57f65bcc
LC
722 ;; Make sure we don't retain a reference to the
723 ;; bootstrap Perl.
724 (substitute* "malloc/mtrace.pl"
725 (("^#!.*")
726 ;; The shebang can be omitted, because there's the
727 ;; "bilingual" eval/exec magic at the top of the file.
728 "")
729 (("exec @PERL@")
ab6e5690
MW
730 "exec perl"))
731
732 #t)))
6dff905e
LC
733
734 (add-after 'install 'move-static-libs
735 (lambda* (#:key outputs #:allow-other-keys)
736 ;; Move static libraries to the "static" output.
737 (define (static-library? file)
738 ;; Return true if FILE is a static library. The
739 ;; "_nonshared.a" files are referred to by libc.so,
740 ;; libpthread.so, etc., which are in fact linker
741 ;; scripts.
742 (and (string-suffix? ".a" file)
743 (not (string-contains file "_nonshared"))))
744
745 (define (linker-script? file)
746 ;; Guess whether FILE, a ".a" file, is actually a
747 ;; linker script.
748 (and (not (ar-file? file))
749 (not (elf-file? file))))
750
751 (let* ((out (assoc-ref outputs "out"))
752 (lib (string-append out "/lib"))
753 (files (scandir lib static-library?))
754 (static (assoc-ref outputs "static"))
755 (slib (string-append static "/lib")))
756 (mkdir-p slib)
757 (for-each (lambda (base)
758 (rename-file (string-append lib "/" base)
759 (string-append slib "/" base)))
760 files)
761
762 ;; Usually libm.a is a linker script so we need to
763 ;; change the file names in there to refer to STATIC
764 ;; instead of OUT.
765 (for-each (lambda (ld-script)
766 (substitute* ld-script
767 ((out) static)))
768 (filter linker-script?
769 (map (cut string-append slib "/" <>)
770 files)))
2d546858
LC
771 #t)))
772
773 ,@(if (hurd-target?)
774 '((add-after 'install 'augment-libc.so
775 (lambda* (#:key outputs #:allow-other-keys)
776 (let* ((out (assoc-ref outputs "out")))
777 (substitute* (string-append out "/lib/libc.so")
778 (("/[^ ]+/lib/libc.so.0.3")
779 (string-append out "/lib/libc.so.0.3"
780 " libmachuser.so libhurduser.so"))))
781 #t)))
782 '()))))
7f614e49 783
90d891fc 784 (inputs `(("static-bash" ,static-bash)))
8fd6487e 785
6162b95d
LC
786 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
787 ;; install the message catalogs, with 'msgfmt'.
8fd6487e 788 (native-inputs `(("texinfo" ,texinfo)
6162b95d 789 ("perl" ,perl)
5e8cb5e6 790 ("bison" ,bison)
2d546858
LC
791 ("gettext" ,gettext-minimal)
792
793 ,@(if (hurd-target?)
794 `(("mig" ,mig)
ef582109 795 ("perl" ,perl))
2d546858 796 '())))
8fd6487e 797
d6718df4
LC
798 (native-search-paths
799 ;; Search path for packages that provide locale data. This is useful
85e57214
LC
800 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
801 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
802 ;; distros.
d6718df4 803 (list (search-path-specification
fbb909ac 804 (variable "GUIX_LOCPATH")
f211b2af 805 (files '("lib/locale")))))
d6718df4 806
d45122f5
LC
807 (synopsis "The GNU C Library")
808 (description
7cdeac02
LC
809 "Any Unix-like operating system needs a C library: the library which
810defines the \"system calls\" and other basic facilities such as open, malloc,
811printf, exit...
812
813The GNU C library is used as the C library in the GNU system and most systems
814with the Linux kernel.")
4a44e743 815 (license lgpl2.0+)
6fd52309 816 (home-page "https://www.gnu.org/software/libc/")))
7cdeac02 817
e13b5474
MB
818;; Below are old libc versions, which we use mostly to build locale data in
819;; the old format (which the new libc cannot cope with.)
820
821(define-public glibc-2.27
ae66fdaf
MB
822 (package
823 (inherit glibc)
e13b5474 824 (version "2.27")
ae66fdaf
MB
825 (source (origin
826 (inherit (package-source glibc))
827 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
828 (sha256
829 (base32
e13b5474
MB
830 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
831 (patches (search-patches "glibc-ldd-x86_64.patch"
832 "glibc-2.27-git-fixes.patch"
ae66fdaf 833 "glibc-hidden-visibility-ldconfig.patch"
e13b5474
MB
834 "glibc-versioned-locpath.patch"
835 "glibc-allow-kernel-2.6.32.patch"
1b9fb043 836 "glibc-reinstate-prlimit64-fallback.patch"
90123647 837 "glibc-supported-locales.patch"
c86b5f1b
EF
838 "glibc-CVE-2018-11236.patch"
839 "glibc-CVE-2018-11237.patch"))))
840 (properties `((lint-hidden-cve . ("CVE-2017-18269")))))) ; glibc-2.27-git-fixes
19ac2ba8 841
5e8cb5e6
MB
842(define-public glibc-2.26
843 (package
844 (inherit glibc)
845 ;; This version number corresponds to the output of `git describe` and the
846 ;; archive can be generated by checking out the commit ID and running:
847 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
848 ;; See <https://bugs.gnu.org/29406> for why this was necessary.
849 (version "2.26.105-g0890d5379c")
850 (source (origin
851 (inherit (package-source glibc))
852 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
853 "glibc-" (version-major+minor version) "-"
854 (caddr (string-split version #\.)) ".tar.xz"))
855 (sha256
856 (base32
857 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
858 (patches (search-patches "glibc-ldd-x86_64.patch"
859 "glibc-versioned-locpath.patch"
860 "glibc-allow-kernel-2.6.32.patch"))))))
861
67d527e3
MB
862(define-public glibc-2.25
863 (package
864 (inherit glibc)
865 (version "2.25")
866 (source (origin
867 (inherit (package-source glibc))
868 (uri (string-append "mirror://gnu/glibc/glibc-"
869 version ".tar.xz"))
870 (sha256
871 (base32
872 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
873 (patches (search-patches "glibc-ldd-x86_64.patch"
874 "glibc-versioned-locpath.patch"
67d527e3 875 "glibc-vectorized-strcspn-guards.patch"
67d527e3
MB
876 "glibc-CVE-2017-1000366-pt1.patch"
877 "glibc-CVE-2017-1000366-pt2.patch"
878 "glibc-CVE-2017-1000366-pt3.patch"))))))
879
7ca72ec4
EF
880(define-public glibc-2.24
881 (package
882 (inherit glibc)
883 (version "2.24")
884 (source (origin
885 (inherit (package-source glibc))
886 (uri (string-append "mirror://gnu/glibc/glibc-"
887 version ".tar.xz"))
888 (sha256
889 (base32
665d6a59
EF
890 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
891 (patches (search-patches "glibc-ldd-x86_64.patch"
892 "glibc-versioned-locpath.patch"
ffc015be 893 "glibc-vectorized-strcspn-guards.patch"
575e5e4e 894 "glibc-CVE-2015-5180.patch"
665d6a59
EF
895 "glibc-CVE-2017-1000366-pt1.patch"
896 "glibc-CVE-2017-1000366-pt2.patch"
897 "glibc-CVE-2017-1000366-pt3.patch"))))))
7ca72ec4 898
19ac2ba8
LC
899(define-public glibc-2.23
900 (package
901 (inherit glibc)
902 (version "2.23")
903 (source (origin
904 (inherit (package-source glibc))
905 (uri (string-append "mirror://gnu/glibc/glibc-"
906 version ".tar.xz"))
907 (sha256
908 (base32
665d6a59
EF
909 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
910 (patches (search-patches "glibc-ldd-x86_64.patch"
911 "glibc-versioned-locpath.patch"
ffc015be 912 "glibc-vectorized-strcspn-guards.patch"
a0ae64a3
EF
913 "glibc-CVE-2015-5180.patch"
914 "glibc-CVE-2016-3075.patch"
915 "glibc-CVE-2016-3706.patch"
916 "glibc-CVE-2016-4429.patch"
665d6a59
EF
917 "glibc-CVE-2017-1000366-pt1.patch"
918 "glibc-CVE-2017-1000366-pt2.patch"
919 "glibc-CVE-2017-1000366-pt3.patch"))))))
19ac2ba8 920
c2c54ebd 921(define-public glibc-2.22
455859a5 922 (package
0832787e 923 (inherit glibc)
c2c54ebd 924 (version "2.22")
137d957e
LC
925 (source (origin
926 (inherit (package-source glibc))
927 (uri (string-append "mirror://gnu/glibc/glibc-"
928 version ".tar.xz"))
929 (sha256
930 (base32
c2c54ebd 931 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
665d6a59 932 (patches (search-patches "glibc-ldd-x86_64.patch"
ca331eb8 933 "glibc-o-largefile.patch"
ffc015be 934 "glibc-vectorized-strcspn-guards.patch"
edd08fb7
EF
935 "glibc-CVE-2015-5180.patch"
936 "glibc-CVE-2015-7547.patch"
937 "glibc-CVE-2016-3075.patch"
938 "glibc-CVE-2016-3706.patch"
939 "glibc-CVE-2016-4429.patch"
665d6a59
EF
940 "glibc-CVE-2017-1000366-pt1.patch"
941 "glibc-CVE-2017-1000366-pt2.patch"
942 "glibc-CVE-2017-1000366-pt3.patch"))))
38e9373b
EF
943 (arguments
944 (substitute-keyword-arguments (package-arguments glibc)
945 ((#:phases phases)
946 `(modify-phases ,phases
947 (add-before 'configure 'fix-pwd
948 (lambda _
6d833b13 949 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
38e9373b 950 (substitute* "configure"
56ed97c8
MW
951 (("/bin/pwd") "pwd"))
952 #t))))))))
137d957e 953
3ed497d4
CD
954(define (make-gcc-libc base-gcc libc)
955 "Return a GCC that targets LIBC."
956 (package (inherit base-gcc)
957 (name (string-append (package-name base-gcc) "-"
958 (package-name libc) "-"
959 (package-version libc)))
960 (arguments
961 (substitute-keyword-arguments
962 (ensure-keyword-arguments (package-arguments base-gcc)
963 '(#:implicit-inputs? #f))
964 ((#:make-flags flags)
965 `(let ((libc (assoc-ref %build-inputs "libc")))
966 ;; FLAGS_FOR_TARGET are needed for the target libraries to receive
967 ;; the -Bxxx for the startfiles.
968 (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
969 ,flags)))))
970 (native-inputs
971 `(("libc" ,libc)
972 ("libc:static" ,libc "static")
973 ,@(append (package-inputs base-gcc)
974 (fold alist-delete (%final-inputs) '("libc" "libc:static")))))
975 (inputs '())))
976
0845999a 977(define-public (make-glibc-locales glibc)
aee6180c
LC
978 (package
979 (inherit glibc)
980 (name "glibc-locales")
981 (source (origin (inherit (package-source glibc))
982 (patches (cons (search-patch "glibc-locales.patch")
983 (origin-patches (package-source glibc))))))
984 (synopsis "All the locales supported by the GNU C Library")
985 (description
986 "This package provides all the locales supported by the GNU C Library,
36a4366d
EF
987more than 400 in total. To use them set the @code{LOCPATH} environment variable
988to the @code{share/locale} sub-directory of this package.")
aee6180c 989 (outputs '("out")) ;110+ MiB
605217be 990 (native-search-paths '())
aee6180c
LC
991 (arguments
992 (let ((args `(#:tests? #f #:strip-binaries? #f
993 ,@(package-arguments glibc))))
994 (substitute-keyword-arguments args
0e6cee21
LC
995 ((#:modules modules '((guix build utils)
996 (guix build gnu-build-system)))
997 `((srfi srfi-11)
998 (gnu build locale)
999 ,@modules))
1000 ((#:imported-modules modules '())
1001 `((gnu build locale)
1002 ,@%gnu-build-system-modules))
aee6180c 1003 ((#:phases phases)
2320d4f0
EF
1004 `(modify-phases ,phases
1005 (replace 'build
1006 (lambda _
bf8e8a74
MW
1007 (invoke "make" "localedata/install-locales"
1008 "-j" (number->string (parallel-job-count)))))
0e6cee21
LC
1009 (add-after 'build 'symlink-normalized-codesets
1010 (lambda* (#:key outputs #:allow-other-keys)
1011 ;; The above phase does not install locales with names using
1012 ;; the "normalized codeset." Thus, create symlinks like:
1013 ;; en_US.utf8 -> en_US.UTF-8
1014 (define (locale-directory? file stat)
1015 (and (file-is-directory? file)
1016 (string-index (basename file) #\_)
1017 (string-rindex (basename file) #\.)))
1018
1019 (let* ((out (assoc-ref outputs "out"))
1020 (locales (find-files out locale-directory?
1021 #:directories? #t)))
1022 (for-each (lambda (directory)
1023 (let*-values (((base)
1024 (basename directory))
1025 ((name codeset)
1026 (locale->name+codeset base))
1027 ((normalized)
1028 (normalize-codeset codeset)))
1029 (unless (string=? codeset normalized)
1030 (symlink base
1031 (string-append (dirname directory)
1032 "/" name "."
1033 normalized)))))
1034 locales)
1035 #t)))
2bbd674b
MB
1036 (delete 'install)
1037 (delete 'move-static-libs)))
aee6180c
LC
1038 ((#:configure-flags flags)
1039 `(append ,flags
85e57214 1040 ;; Use $(libdir)/locale/X.Y as is the case by default.
85860fdf 1041 (list (string-append "libc_cv_complocaledir="
aee6180c 1042 (assoc-ref %outputs "out")
f2d7bbb5 1043 "/lib/locale/"
c6bc8e22
MB
1044 ,(version-major+minor
1045 (package-version glibc)))))))))))
aee6180c 1046
0845999a 1047(define-public (make-glibc-utf8-locales glibc)
c9505f3f
LC
1048 (package
1049 (name "glibc-utf8-locales")
1050 (version (package-version glibc))
1051 (source #f)
1052 (build-system trivial-build-system)
1053 (arguments
f2d7bbb5 1054 `(#:modules ((guix build utils))
c9505f3f 1055 #:builder (begin
44161fe1 1056 (use-modules (guix build utils))
c9505f3f
LC
1057
1058 (let* ((libc (assoc-ref %build-inputs "glibc"))
1059 (gzip (assoc-ref %build-inputs "gzip"))
1060 (out (assoc-ref %outputs "out"))
f2d7bbb5 1061 (localedir (string-append out "/lib/locale/"
c6bc8e22 1062 ,(version-major+minor version))))
c9505f3f
LC
1063 ;; 'localedef' needs 'gzip'.
1064 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1065
1066 (mkdir-p localedir)
44161fe1
MW
1067 (for-each (lambda (locale)
1068 (define file
1069 ;; Use the "normalized codeset" by
1070 ;; default--e.g., "en_US.utf8".
1071 (string-append localedir "/" locale ".utf8"))
1072
1073 (invoke "localedef" "--no-archive"
1074 "--prefix" localedir
1075 "-i" locale
1076 "-f" "UTF-8" file)
1077
1078 ;; For backward compatibility with Guix
1079 ;; <= 0.8.3, add "xx_YY.UTF-8".
1080 (symlink (string-append locale ".utf8")
1081 (string-append localedir "/"
1082 locale ".UTF-8")))
1083
1084 ;; These are the locales commonly used for
1085 ;; tests---e.g., in Guile's i18n tests.
1086 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1087 #t))))
c9505f3f
LC
1088 (inputs `(("glibc" ,glibc)
1089 ("gzip" ,gzip)))
1090 (synopsis "Small sample of UTF-8 locales")
1091 (description
1092 "This package provides a small sample of UTF-8 locales mostly useful in
1093test environments.")
1094 (home-page (package-home-page glibc))
1095 (license (package-license glibc))))
aee6180c 1096
0845999a
RW
1097(define-public glibc-locales
1098 (make-glibc-locales glibc))
1099(define-public glibc-utf8-locales
1100 (make-glibc-utf8-locales glibc))
1101
1102(define-public glibc-locales-2.27
1103 (package (inherit (make-glibc-locales glibc-2.27))
1104 (name "glibc-locales-2.27")))
1105(define-public glibc-utf8-locales-2.27
1106 (package (inherit (make-glibc-utf8-locales glibc-2.27))
1107 (name "glibc-utf8-locales-2.27")))
1108
ce0614dd
LC
1109(define-public which
1110 (package
1111 (name "which")
70ca2e94 1112 (version "2.21")
ce0614dd
LC
1113 (source (origin
1114 (method url-fetch)
1115 (uri (string-append "mirror://gnu/which/which-"
1116 version ".tar.gz"))
1117 (sha256
1118 (base32
70ca2e94 1119 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
ce0614dd
LC
1120 (build-system gnu-build-system)
1121 (home-page "https://gnu.org/software/which/")
1122 (synopsis "Find full path of shell commands")
1123 (description
1124 "The which program finds the location of executables in PATH, with a
1125variety of options. It is an alternative to the shell \"type\" built-in
1126command.")
1127 (license gpl3+))) ; some files are under GPLv2+
1128
21a8fe1b 1129(define-public glibc/hurd-headers
2d546858 1130 (package (inherit glibc)
21a8fe1b
MR
1131 (name "glibc-hurd-headers")
1132 (outputs '("out"))
1133 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1134 ("hurd-headers" ,hurd-headers)))
1135 (arguments
2d546858 1136 (substitute-keyword-arguments (package-arguments glibc)
21a8fe1b
MR
1137 ;; We just pass the flags really needed to build the headers.
1138 ((#:configure-flags _)
1139 `(list "--enable-add-ons"
2d546858 1140 "--host=i586-pc-gnu"))
21a8fe1b 1141 ((#:phases _)
c04e5116
TGR
1142 '(modify-phases %standard-phases
1143 (replace 'install
1144 (lambda* (#:key outputs #:allow-other-keys)
1145 (invoke "make" "install-headers")
1146
1147 ;; Make an empty stubs.h to work around not being able to
1148 ;; produce a valid stubs.h and causing the build to fail. See
1149 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1150 (let ((out (assoc-ref outputs "out")))
1151 (close-port
1152 (open-output-file
b4c4f339
MW
1153 (string-append out "/include/gnu/stubs.h"))))
1154 #t))
2d546858 1155 (delete 'build))))))) ; nothing to build
21a8fe1b 1156
e789d9a8
LC
1157(define-public tzdata
1158 (package
1159 (name "tzdata")
41af23db 1160 (version "2019a")
e789d9a8
LC
1161 (source (origin
1162 (method url-fetch)
1163 (uri (string-append
80b63e67 1164 "https://www.iana.org/time-zones/repository/releases/tzdata"
e789d9a8
LC
1165 version ".tar.gz"))
1166 (sha256
1167 (base32
41af23db 1168 "0wlpqm4asvi0waaz24xj20iq40gqfypmb4nldjhkfgm09bgnsdlh"))))
e789d9a8
LC
1169 (build-system gnu-build-system)
1170 (arguments
1171 '(#:tests? #f
1172 #:make-flags (let ((out (assoc-ref %outputs "out"))
1173 (tmp (getenv "TMPDIR")))
1174 (list (string-append "TOPDIR=" out)
1175 (string-append "TZDIR=" out "/share/zoneinfo")
62868f12
LF
1176 (string-append "TZDEFAULT=" out
1177 "/share/zoneinfo/localtime")
e789d9a8
LC
1178
1179 ;; Likewise for the C library routines.
1180 (string-append "LIBDIR=" tmp "/lib")
1181 (string-append "MANDIR=" tmp "/man")
1182
1183 "AWK=awk"
1184 "CC=gcc"))
1185 #:modules ((guix build utils)
1186 (guix build gnu-build-system)
1187 (srfi srfi-1))
1188 #:phases
c8f35458
JD
1189 (modify-phases %standard-phases
1190 (replace 'unpack
1191 (lambda* (#:key source inputs #:allow-other-keys)
408fcff6
MW
1192 (invoke "tar" "xvf" source)
1193 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
c8f35458
JD
1194 (add-after 'install 'post-install
1195 (lambda* (#:key outputs #:allow-other-keys)
1196 ;; Move data in the right place.
1197 (let ((out (assoc-ref outputs "out")))
62868f12
LF
1198 ;; Discard zic, dump, and tzselect, already
1199 ;; provided by glibc.
1200 (delete-file-recursively (string-append out "/usr"))
c8f35458
JD
1201 (symlink (string-append out "/share/zoneinfo")
1202 (string-append out "/share/zoneinfo/posix"))
1203 (delete-file-recursively
1204 (string-append out "/share/zoneinfo-posix"))
1205 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1206 (string-append out "/share/zoneinfo/right"))
1207 (delete-file-recursively
408fcff6
MW
1208 (string-append out "/share/zoneinfo-leaps"))
1209 #t)))
c8f35458 1210 (delete 'configure))))
e789d9a8
LC
1211 (inputs `(("tzcode" ,(origin
1212 (method url-fetch)
1213 (uri (string-append
1214 "http://www.iana.org/time-zones/repository/releases/tzcode"
1215 version ".tar.gz"))
1216 (sha256
1217 (base32
41af23db 1218 "1x9z8fpgnhzlsnps0hamb54ymaskjab7ys9m4i4gpk9hpiig2fc7"))))))
80b63e67 1219 (home-page "https://www.iana.org/time-zones")
e789d9a8
LC
1220 (synopsis "Database of current and historical time zones")
1221 (description "The Time Zone Database (often called tz or zoneinfo)
1222contains code and data that represent the history of local time for many
35b9e423 1223representative locations around the globe. It is updated periodically to
e789d9a8
LC
1224reflect changes made by political bodies to time zone boundaries, UTC offsets,
1225and daylight-saving rules.")
1226 (license public-domain)))
1227
75aea16f
LF
1228;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1229;;; and a few other places. We can update this whenever we are able to rebuild
1230;;; thousands of packages (for example, in a core-updates rebuild). This package
1231;;; will typically be obsolete and should never be referred to by a built
1232;;; package.
f9c3bd2e 1233(define-public tzdata-for-tests
cd50b9f0
MB
1234 (hidden-package
1235 (package
1236 (inherit tzdata)
1bb9969f 1237 (version "2018g")
cd50b9f0 1238 (source (origin
1bb9969f
LF
1239 (method url-fetch)
1240 (uri (string-append
1241 "https://www.iana.org/time-zones/repository/releases/tzdata"
1242 version ".tar.gz"))
1243 (sha256
1244 (base32
1245 "05kayi3w9pvhj6ljx1hvwd0r8mxfzn436fjmwhx53xkj919xxpq2"))))
1246 (inputs
1247 `(("tzcode" ,(origin
1248 (method url-fetch)
1249 (uri (string-append
1250 "http://www.iana.org/time-zones/repository/releases/tzcode"
1251 version ".tar.gz"))
1252 (sha256
1253 (base32
1254 "09y44fzcdq3c06saa8iqqa0a59cyw6ni3p31ps0j1w3hcpxz8lxa")))))))))
3ffaec13 1255
7309045c
JN
1256(define-public libiconv
1257 (package
1258 (name "libiconv")
a55fbab7 1259 (version "1.15")
7309045c
JN
1260 (source (origin
1261 (method url-fetch)
1262 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1263 version ".tar.gz"))
1264 (sha256
1265 (base32
5c6b6827 1266 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
7309045c
JN
1267 (modules '((guix build utils)))
1268 (snippet
1269 ;; Work around "declared gets" error on glibc systems (fixed by
1270 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
6cbee49d
MW
1271 '(begin
1272 (substitute* "srclib/stdio.in.h"
1273 (("^#undef gets") "")
1274 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1275 #t))))
7309045c
JN
1276 (build-system gnu-build-system)
1277 (synopsis "Character set conversion library")
1278 (description
1279 "libiconv provides an implementation of the iconv function for systems
1280that lack it. iconv is used to convert between character encodings in a
1281program. It supports a wide variety of different encodings.")
6fd52309 1282 (home-page "https://www.gnu.org/software/libiconv/")
7309045c
JN
1283 (license lgpl3+)))
1284
4dab8c59
JN
1285(define* (libiconv-if-needed #:optional (target (%current-target-system)))
1286 "Return either a libiconv package specification to include in a dependency
1287list for platforms that have an incomplete libc, or the empty list. If a
1288package needs iconv ,@(libiconv-if-needed) should be added."
1289 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1290 ;; without iconv, such as MinGW, must return the then clause.
1291 (if (target-mingw? target)
1292 `(("libiconv" ,libiconv))
1293 '()))
1294
bdb36958
LC
1295(define-public (canonical-package package)
1296 ;; Avoid circular dependency by lazily resolving 'commencement'.
1297 (let* ((iface (resolve-interface '(gnu packages commencement)))
1298 (proc (module-ref iface 'canonical-package)))
1299 (proc package)))
571aa6cd 1300
fb77c614
LC
1301(define-public (%final-inputs)
1302 "Return the list of \"final inputs\"."
1303 ;; Avoid circular dependency by lazily resolving 'commencement'.
1304 (let ((iface (resolve-interface '(gnu packages commencement))))
1305 (module-ref iface '%final-inputs)))
1306
1722d680 1307;;; base.scm ends here