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