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