gnu: libdvdcss: Update to 1.4.3.
[jackhill/guix/guix.git] / gnu / packages / base.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
2073b55e 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
28317d49 3;;; Copyright © 2014, 2019 Andreas Enge <andreas@enge.fr>
233e7676 4;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
4e50f1f2 5;;; Copyright © 2014, 2015, 2016, 2018 Mark H Weaver <mhw@netris.org>
4c8425b7 6;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
21a8fe1b 7;;; Copyright © 2014, 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
6e98e9ca 8;;; Copyright © 2016, 2017, 2019, 2020, 2021 Efraim Flashner <efraim@flashner.co.il>
1339a03b 9;;; Copyright © 2016, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
ad3c9f18 10;;; Copyright © 2016, 2018 Alex Vong <alexvong1995@gmail.com>
b81d11e5 11;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
02043f36 12;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
3e3a37b2 13;;; Copyright © 2017, 2018, 2020 Marius Bakke <mbakke@fastmail.com>
acc2dab7 14;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
c04e5116 15;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
0845999a 16;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
2eb39cd2 17;;; Copyright © 2020 Vitaliy Shatrov <D0dyBo0D0dyBo0@protonmail.com>
6e98e9ca
LLB
18;;; Copyright © 2020 Chris Marusich <cmmarusich@gmail.com>
19;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
e3ce5d70 20;;;
233e7676 21;;; This file is part of GNU Guix.
e3ce5d70 22;;;
233e7676 23;;; GNU Guix is free software; you can redistribute it and/or modify it
e3ce5d70
LC
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;;;
233e7676 28;;; GNU Guix is distributed in the hope that it will be useful, but
e3ce5d70
LC
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
233e7676 34;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
e3ce5d70 35
1ffa7090 36(define-module (gnu packages base)
c6d7e299 37 #:use-module ((guix licenses)
7309045c 38 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
59a43334 39 #:use-module (gnu packages)
1ffa7090 40 #:use-module (gnu packages acl)
28317d49 41 #:use-module (gnu packages algebra)
1ffa7090 42 #:use-module (gnu packages bash)
5e8cb5e6 43 #:use-module (gnu packages bison)
b5ef82e0 44 #:use-module (gnu packages ed)
28317d49 45 #:use-module (gnu packages gcc)
1ffa7090
LC
46 #:use-module (gnu packages guile)
47 #:use-module (gnu packages multiprecision)
c9505f3f 48 #:use-module (gnu packages compression)
1ffa7090
LC
49 #:use-module (gnu packages perl)
50 #:use-module (gnu packages linux)
20bf5fce 51 #:use-module (gnu packages pcre)
8fd6487e 52 #:use-module (gnu packages texinfo)
21a8fe1b 53 #:use-module (gnu packages hurd)
aa6b0d6b 54 #:use-module (gnu packages pkg-config)
5f3f7039 55 #:use-module (gnu packages python)
a635ed5c 56 #:use-module (gnu packages gettext)
0d3f2716 57 #:use-module (guix i18n)
aee6180c 58 #:use-module (guix utils)
e3ce5d70 59 #:use-module (guix packages)
87f5d366 60 #:use-module (guix download)
21a8fe1b 61 #:use-module (guix git-download)
c9505f3f 62 #:use-module (guix build-system gnu)
b09617da 63 #:use-module (guix build-system trivial)
0d3f2716 64 #:use-module (ice-9 format)
b09617da 65 #:use-module (ice-9 match)
0d3f2716 66 #:use-module (ice-9 optargs)
28317d49
EF
67 #:use-module (srfi srfi-1)
68 #:use-module (srfi srfi-26)
4dab8c59
JN
69 #:export (glibc
70 libiconv-if-needed))
e3ce5d70
LC
71
72;;; Commentary:
73;;;
1722d680 74;;; Base packages of the Guix-based GNU user-land software distribution.
e3ce5d70
LC
75;;;
76;;; Code:
77
78(define-public hello
79 (package
17d8e33f
ML
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
a22dc0c4
LC
93serves as an example of standard GNU coding practices. As such, it supports
94command-line arguments, multiple languages, and so on.")
6fd52309 95 (home-page "https://www.gnu.org/software/hello/")
17d8e33f 96 (license gpl3+)))
d7672884 97
6794b278
LC
98(define-public grep
99 (package
100 (name "grep")
e8b79cd9 101 (version "3.4")
6794b278 102 (source (origin
87f5d366 103 (method url-fetch)
0db342a5 104 (uri (string-append "mirror://gnu/grep/grep-"
6794b278
LC
105 version ".tar.xz"))
106 (sha256
107 (base32
e8b79cd9 108 "1yy33kiwrxrwj2nxa4fg15bvmwyghqbs8qwkdvy5phm784f7brjq"))
63adf0fd 109 (patches (search-patches "grep-timing-sensitive-test.patch"))))
6794b278 110 (build-system gnu-build-system)
304e4f51 111 (native-inputs `(("perl" ,perl))) ;some of the tests require it
20bf5fce 112 (inputs `(("pcre" ,pcre)))
1063d325
MW
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))))))
f50d2669 127 (synopsis "Print lines matching a pattern")
d45122f5 128 (description
12bcf94a 129 "grep is a tool for finding text inside files. Text is found by
a22dc0c4 130matching a pattern provided by the user in one or many files. The pattern
79c311b8
LC
131may be provided as a basic or extended regular expression, or as fixed
132strings. By default, the matching text is simply printed to the screen,
133however the output can be greatly customized to include, for example, line
134numbers. GNU grep offers many extensions over the standard utility,
135including, for example, recursive directory searching.")
4a44e743 136 (license gpl3+)
6fd52309 137 (home-page "https://www.gnu.org/software/grep/")))
6794b278 138
8dcad9aa
LC
139(define-public sed
140 (package
141 (name "sed")
aded68b3 142 (version "4.8")
8dcad9aa 143 (source (origin
87f5d366 144 (method url-fetch)
0db342a5 145 (uri (string-append "mirror://gnu/sed/sed-" version
aded68b3 146 ".tar.gz"))
8dcad9aa
LC
147 (sha256
148 (base32
aded68b3 149 "0alqagh0nliymz23kfjg6g9w3cr086k0sfni56gi8fhzqwa3xksk"))))
8dcad9aa 150 (build-system gnu-build-system)
65c46e79
CM
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 '())))
f50d2669 167 (synopsis "Stream editor")
301a4249
LC
168 (native-inputs
169 `(("perl" ,perl))) ;for tests
d45122f5 170 (description
a22dc0c4
LC
171 "Sed is a non-interactive, text stream editor. It receives a text
172input from a file or from standard input and it then applies a series of text
173editing commands to the stream and prints its output to standard output. It
79c311b8
LC
174is often used for substituting text patterns in a stream. The GNU
175implementation offers several extensions over the standard utility.")
4a44e743 176 (license gpl3+)
7d7ea947 177 (home-page "https://www.gnu.org/software/sed/")))
8dcad9aa 178
85240322
LC
179(define-public tar
180 (package
181 (name "tar")
218eb6e6 182 (version "1.32")
85240322 183 (source (origin
87f5d366 184 (method url-fetch)
0db342a5 185 (uri (string-append "mirror://gnu/tar/tar-"
d6535cf1 186 version ".tar.xz"))
85240322
LC
187 (sha256
188 (base32
218eb6e6 189 "1n7xy657ii0sa42zx6944v2m4v9qrh6sqgmw17l3nch3y43sxlyh"))
45413064
MW
190 (patches (search-patches "tar-skip-unreliable-tests.patch"
191 "tar-remove-wholesparse-check.patch"))))
85240322 192 (build-system gnu-build-system)
74d63739
LC
193 ;; Note: test suite requires ~1GiB of disk space.
194 (arguments
4e0059be
JN
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
74d63739
LC
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")))
218eb6e6 218 #t))))))
bbe03294
LC
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
f50d2669 226 (synopsis "Managing tar archives")
d45122f5 227 (description
a22dc0c4
LC
228 "Tar provides the ability to create tar archives, as well as the
229ability to extract, update or list files in an existing archive. It is
230useful for combining many files into one larger file, while maintaining
231directory structure and file information such as permissions and
79c311b8
LC
232creation/modification dates. GNU tar offers many extensions over the
233standard utility.")
4a44e743 234 (license gpl3+)
6fd52309 235 (home-page "https://www.gnu.org/software/tar/")))
85240322 236
fbeec3d9
LC
237(define-public patch
238 (package
239 (name "patch")
ec07ba1f 240 (version "2.7.6")
f6408bc5
LC
241 (source (origin
242 (method url-fetch)
243 (uri (string-append "mirror://gnu/patch/patch-"
244 version ".tar.xz"))
245 (sha256
246 (base32
ec07ba1f 247 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
fc1adab1 248 (patches (search-patches "patch-hurd-path-max.patch"))))
fbeec3d9 249 (build-system gnu-build-system)
d3878d3d
LC
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 '()))
b3546174 256 (native-inputs `(("ed" ,ed)))
f50d2669 257 (synopsis "Apply differences to originals, with optional backups")
d45122f5 258 (description
a22dc0c4 259 "Patch is a program that applies changes to files based on differences
79c311b8 260laid out as by the program \"diff\". The changes may be applied to one or more
a22dc0c4
LC
261files depending on the contents of the diff file. It accepts several
262different diff formats. It may also be used to revert previously applied
263differences.")
4a44e743 264 (license gpl3+)
6fd52309 265 (home-page "https://savannah.gnu.org/projects/patch/")))
fbeec3d9 266
04a32ee5
LC
267(define-public diffutils
268 (package
269 (name "diffutils")
e992d566 270 (version "3.7")
04a32ee5 271 (source (origin
87f5d366 272 (method url-fetch)
0db342a5 273 (uri (string-append "mirror://gnu/diffutils/diffutils-"
04a32ee5
LC
274 version ".tar.xz"))
275 (sha256
276 (base32
e992d566 277 "09isrg0isjinv8c535nxsi1s86wfdfzml80dbw41dj9x3hiad9xk"))))
04a32ee5 278 (build-system gnu-build-system)
e992d566 279 (native-inputs `(("perl" ,perl)))
f50d2669 280 (synopsis "Comparing and merging files")
d45122f5 281 (description
79c311b8
LC
282 "GNU Diffutils is a package containing tools for finding the
283differences between files. The \"diff\" command is used to show how two files
e881752c 284differ, while \"cmp\" shows the offsets and line numbers where they differ.
79c311b8 285\"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
a22dc0c4 286interactive means to merge two files.")
4a44e743 287 (license gpl3+)
6fd52309 288 (home-page "https://www.gnu.org/software/diffutils/")))
04a32ee5 289
af5521ca
LC
290(define-public findutils
291 (package
292 (name "findutils")
717867a6 293 (version "4.7.0")
af5521ca 294 (source (origin
87f5d366 295 (method url-fetch)
0db342a5 296 (uri (string-append "mirror://gnu/findutils/findutils-"
717867a6 297 version ".tar.xz"))
af5521ca
LC
298 (sha256
299 (base32
717867a6 300 "16kqz9yz98dasmj70jwf5py7jk558w96w0vgp3zf9xsqk3gzpzn5"))
f87b68a1
MB
301 (patches (search-patches "findutils-localstatedir.patch"
302 "findutils-test-rwlock-threads.patch"))))
af5521ca 303 (build-system gnu-build-system)
af5521ca 304 (arguments
67dfa198
LC
305 `(#:configure-flags (list
306 ;; Tell 'updatedb' to write to /var.
717867a6
MB
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)))))
f50d2669 316 (synopsis "Operating on files matching given criteria")
d45122f5 317 (description
a22dc0c4
LC
318 "Findutils supplies the basic file directory searching utilities of the
319GNU system. It consists of two primary searching utilities: \"find\"
320recursively 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
79c311b8
LC
322are included: \"updatedb\" updates the file name database and \"xargs\" may be
323used to apply commands with arbitrarily long arguments.")
4a44e743 324 (license gpl3+)
6fd52309 325 (home-page "https://www.gnu.org/software/findutils/")))
2c957cd2
LC
326
327(define-public coreutils
328 (package
329 (name "coreutils")
d7ca0f73 330 (version "8.32")
2c957cd2 331 (source (origin
87f5d366 332 (method url-fetch)
0db342a5 333 (uri (string-append "mirror://gnu/coreutils/coreutils-"
2c957cd2
LC
334 version ".tar.xz"))
335 (sha256
336 (base32
02043f36
MO
337 "1yjcrh5hw70c0yn8zw55pd6j51dj90anpq8mmg649ps9g3gdhn24"))
338 (patches (search-patches "coreutils-ls.patch"))))
2c957cd2 339 (build-system gnu-build-system)
de59af4d 340 (inputs `(("acl" ,acl) ; TODO: add SELinux
09cc7729 341 ("gmp" ,gmp) ;bignums in 'expr', yay!
62ea8865 342
11a5ffba
JN
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))
1808e64d
JN
346 (member (%current-system)
347 (package-supported-systems libcap)))
9e1f5a26 348 `(("libcap" ,libcap-2.31)) ;capability support in 'ls', etc.
11a5ffba 349 '())))
2c1dea85
LC
350 (native-inputs
351 ;; Perl is needed to run tests in native builds, and to run the bundled
7f31c71c
LC
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.
1cbd63f2
LC
355 (if (%current-target-system)
356 '()
357 `(("perl" ,perl))))
9bf62d9b 358 (outputs '("out" "debug"))
2c957cd2 359 (arguments
8ba8aeb7 360 `(#:parallel-build? #f ; help2man may be called too early
2c7ea189
JN
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"
413c31dc 366 " tests/misc/pwd-long.sh"
2c7ea189
JN
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 '())
656a5ba0
EF
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"))
b47b2b52 382
656a5ba0
EF
383 (substitute* (find-files "gnulib-tests" "\\.c$")
384 (("/bin/sh") (which "sh")))
385 (substitute* (find-files "tests" "\\.sh$")
a8dcf6ce 386 (("#!/bin/sh") (string-append "#!" (which "sh"))))
c0056419
JN
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 '()))))
f50d2669 396 (synopsis "Core GNU utilities (file, text, shell)")
d45122f5 397 (description
2eb39cd2
VS
398 "GNU Coreutils package includes all of the basic command-line tools that
399are expected in a POSIX system, excluding shell. This package is the union of
400the GNU fileutils, sh-utils, and textutils packages. Most of these tools
401offer extended functionality beyond that which is outlined in the POSIX
402standard.")
4a44e743 403 (license gpl3+)
6fd52309 404 (home-page "https://www.gnu.org/software/coreutils/")))
af5521ca 405
d0f74308 406(define-public coreutils-minimal
28cbc587
LC
407 ;; Coreutils without its optional dependencies.
408 (package
409 (inherit coreutils)
d0f74308 410 (name "coreutils-minimal")
28cbc587
LC
411 (outputs '("out"))
412 (inputs '())))
413
cef0e08c
LC
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
ab776865
LC
442(define-public gnu-make
443 (package
444 (name "make")
cdba9148 445 (version "4.3")
ab776865 446 (source (origin
87f5d366 447 (method url-fetch)
0db342a5 448 (uri (string-append "mirror://gnu/make/make-" version
cdba9148 449 ".tar.gz"))
ab776865
LC
450 (sha256
451 (base32
cdba9148
MB
452 "06cfqzpqsvdnsxbysl5p2fgdgxgl9y4p7scpnrfa8z2zgkjdspz0"))
453 (patches (search-patches "make-impure-dirs.patch"))))
ab776865 454 (build-system gnu-build-system)
b3546174 455 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
cdba9148 456 (inputs `(("guile" ,guile-3.0)))
9bf62d9b 457 (outputs '("out" "debug"))
ea8fbbf2 458 (arguments
846f5da1
JN
459 `(,@(if (hurd-target?)
460 '(#:configure-flags '("CFLAGS=-D__alloca=alloca"
461 "ac_cv_func_posix_spawn=no"))
462 '())
e9b9ea1e 463 #:phases
6cc83b68
EF
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")))
cdba9148 469 (substitute* "src/job.c"
6cc83b68 470 (("default_shell =.*$")
60f3ad8c 471 (format #f "default_shell = \"~a/bin/sh\";\n"
759ad069
MB
472 bash)))
473 #t))))))
f50d2669 474 (synopsis "Remake files automatically")
d45122f5 475 (description
a22dc0c4
LC
476 "Make is a program that is used to control the production of
477executables or other files from their source files. The process is
478controlled from a Makefile, in which the developer specifies how each file is
479generated from its source. It has powerful dependency resolution and the
480ability to determine when files have to be regenerated after their sources
79c311b8 481change. GNU make offers many powerful extensions over the standard utility.")
4a44e743 482 (license gpl3+)
6fd52309 483 (home-page "https://www.gnu.org/software/make/")))
ab776865 484
5fd0c288
MB
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
8f6201a3
LC
510(define-public binutils
511 (package
512 (name "binutils")
3e3a37b2 513 (version "2.34")
8f6201a3 514 (source (origin
87f5d366 515 (method url-fetch)
0db342a5 516 (uri (string-append "mirror://gnu/binutils/binutils-"
8f6201a3
LC
517 version ".tar.bz2"))
518 (sha256
519 (base32
3e3a37b2 520 "1rin1f5c7wm4n3piky6xilcrpf2s0n3dd5vqq8irrxkcic3i1w49"))
ff19532f 521 (patches (search-patches "binutils-loongson-workaround.patch"))))
8f6201a3
LC
522 (build-system gnu-build-system)
523
524 ;; TODO: Add dependency on zlib + those for Gold.
8f6201a3 525 (arguments
de80b504 526 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
01d45404
LC
527 ;; on GCC when bootstrapping.
528 "LDFLAGS=-static-libgcc"
8f6201a3 529
ff19532f
MB
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
01d45404 536 ;; Don't search under /usr/lib & co.
444c64b0
LC
537 "--with-lib-path=/no-ld-lib-path"
538
6c95f363
LC
539 ;; Install BFD. It ends up in a hidden directory,
540 ;; but it's here.
cc0a1282
LC
541 "--enable-install-libbfd"
542
543 ;; Make sure 'ar' and 'ranlib' produce archives in a
544 ;; deterministic fashion.
3e3a37b2
MB
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)))
8f6201a3 556
f50d2669 557 (synopsis "Binary utilities: bfd gas gprof ld")
d45122f5 558 (description
a22dc0c4 559 "GNU Binutils is a collection of tools for working with binary files.
c5779c93
LC
560Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
561Other tools include programs to display binary profiling information, list
562the strings in a binary file, and utilities for working with archives. The
563\"bfd\" library for working with executable and object formats is also
564included.")
4a44e743 565 (license gpl3+)
6fd52309 566 (home-page "https://www.gnu.org/software/binutils/")))
8f6201a3 567
3e3a37b2
MB
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
a493a526
MB
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
70cbab44
MB
584 (package
585 (inherit binutils)
a493a526
MB
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
28317d49 599(define-public binutils-gold
eca649d0 600 (package/inherit binutils+documentation
28317d49
EF
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
7941e059 623 `(("gcc:lib" ,(canonical-package gcc) "lib")))))
28317d49 624
5bde4503
LC
625(define* (make-ld-wrapper name #:key
626 (target (const #f))
627 binutils
1b709954 628 (guile (canonical-package guile-3.0))
5bde4503 629 (bash (canonical-package bash))
8fdd4101
LC
630 (guile-for-build guile))
631 "Return a package called NAME that contains a wrapper for the 'ld' program
5bde4503
LC
632of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
633wrapper uses GUILE and BASH.
634
635TARGET must be a one-argument procedure that, given a system type, returns a
636cross-compilation target triplet or #f. When the result is not #f, make a
637wrapper 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.
8fdd4101
LC
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
c8bfa5b4 650 "gnu/packages/ld-wrapper.in"))))
8fdd4101 651 (arguments
5bde4503
LC
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))
8fdd4101 658
5bde4503
LC
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")))
8fdd4101 665
d8f78f54
LC
666 (setvbuf (current-output-port)
667 (cond-expand (guile-2.0 _IOLBF)
668 (else 'line)))
5bde4503
LC
669 (format #t "building ~s/bin/ld wrapper in ~s~%"
670 (assoc-ref %build-inputs "binutils")
671 out)
8fdd4101 672
5bde4503
LC
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)
e3cfef22
MW
691 (compile-file ld #:output-file go)
692 #t)))))
8fdd4101
LC
693 (synopsis "The linker wrapper")
694 (description
36a4366d
EF
695 "The linker wrapper (or @code{ld-wrapper}) wraps the linker to add any
696missing @code{-rpath} flags, and to detect any misuse of libraries outside of
697the store.")
6fd52309 698 (home-page "https://www.gnu.org/software/guix//")
8fdd4101
LC
699 (license gpl3+)))
700
701(export make-ld-wrapper)
702
2d546858
LC
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.
7cdeac02
LC
706 (package
707 (name "glibc")
a33eac03 708 (version "2.31")
7cdeac02 709 (source (origin
87f5d366 710 (method url-fetch)
5e8cb5e6 711 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
7cdeac02
LC
712 (sha256
713 (base32
a33eac03 714 "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
13990c73
LC
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.
6cbee49d
MW
719 '(begin
720 (substitute* "sysdeps/unix/sysv/linux/configure"
721 (("use_ldconfig=yes")
722 "use_ldconfig=no"))
723 #t))
1faca892 724 (modules '((guix build utils)))
c3052d6b 725 (patches (search-patches "glibc-ldd-x86_64.patch"
5e8cb5e6 726 "glibc-hidden-visibility-ldconfig.patch"
c3052d6b 727 "glibc-versioned-locpath.patch"
6422bde9 728 "glibc-allow-kernel-2.6.32.patch"
1b9fb043 729 "glibc-reinstate-prlimit64-fallback.patch"
974c42a7
JN
730 "glibc-supported-locales.patch"
731 "glibc-hurd-clock_t_centiseconds.patch"
096a8e35
JN
732 "glibc-hurd-clock_gettime_monotonic.patch"
733 "glibc-hurd-signal-sa-siginfo.patch"))))
7cdeac02 734 (build-system gnu-build-system)
0a3da5b7
LC
735
736 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
2d546858
LC
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))))
0a3da5b7 744
6dff905e
LC
745 (outputs '("out" "debug"
746 "static")) ;9 MiB of .a files
7f614e49 747
7cdeac02 748 (arguments
8197c978 749 `(#:out-of-source? #t
211db2f6 750
112da588 751 ;; The libraries have an empty RUNPATH, but some, such as the versioned
67fcf235 752 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
112da588
LC
753 ;; these libraries are always going to be found anyway, just skip
754 ;; RUNPATH checks.
755 #:validate-runpath? #f
756
6dff905e
LC
757 #:modules ((ice-9 ftw)
758 (srfi srfi-26)
759 (guix build utils)
760 (guix build gnu-build-system))
761
7cdeac02 762 #:configure-flags
5e8cb5e6 763 (list "--sysconfdir=/etc"
7f614e49 764
97e11209
LC
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
9f58fe3d 772 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
46bd6edd
LC
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>.
97e11209 777 ;;
7f614e49
LC
778 ;; `--localedir' is not honored, so work around it.
779 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
9f58fe3d 780 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
c6bc8e22 781 ,(version-major+minor version))
7f614e49 782
7cdeac02 783 (string-append "--with-headers="
28dc10a4
LC
784 (assoc-ref ,(if (%current-target-system)
785 '%build-target-inputs
786 '%build-inputs)
aeafff53 787 "kernel-headers")
7cdeac02 788 "/include")
5f456680 789
67d527e3 790 ;; This is the default for most architectures as of GNU libc 2.26,
39ccbfad
MW
791 ;; but we specify it explicitly for clarity and consistency. See
792 ;; "kernel-features.h" in the GNU libc for details.
67d527e3 793 "--enable-kernel=3.2.0"
5f456680 794
6e32f6c0 795 ;; Use our Bash instead of /bin/sh.
8cd8e97c 796 (string-append "BASH_SHELL="
6e32f6c0 797 (assoc-ref %build-inputs "bash")
2d546858
LC
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 '()))
6e32f6c0 805
7cdeac02 806 #:tests? #f ; XXX
57f65bcc
LC
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"))))
57f65bcc
LC
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")
11b66876 842 (string-append bash "/bin/sh")))
57f65bcc 843
d56f8d5e
LC
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 \""
e4831391 849 bash "/bin/sh\"\n")))
d56f8d5e 850
c5b65f7e
LC
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
57f65bcc
LC
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@")
ab6e5690
MW
868 "exec perl"))
869
870 #t)))
6dff905e
LC
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)))
2d546858
LC
909 #t)))
910
6e98e9ca
LLB
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 '())
2d546858
LC
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 '()))))
7f614e49 929
90d891fc 930 (inputs `(("static-bash" ,static-bash)))
8fd6487e 931
6162b95d
LC
932 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
933 ;; install the message catalogs, with 'msgfmt'.
8fd6487e 934 (native-inputs `(("texinfo" ,texinfo)
6162b95d 935 ("perl" ,perl)
5e8cb5e6 936 ("bison" ,bison)
2d546858 937 ("gettext" ,gettext-minimal)
5f3f7039 938 ("python" ,python-minimal)
2d546858 939
6e98e9ca
LLB
940 ,@(if (target-powerpc?)
941 `(("powerpc64le-patch" ,@(search-patches
942 "glibc-ldd-powerpc.patch")))
943 '())
2d546858
LC
944 ,@(if (hurd-target?)
945 `(("mig" ,mig)
ef582109 946 ("perl" ,perl))
2d546858 947 '())))
8fd6487e 948
d6718df4
LC
949 (native-search-paths
950 ;; Search path for packages that provide locale data. This is useful
85e57214
LC
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.
d6718df4 954 (list (search-path-specification
fbb909ac 955 (variable "GUIX_LOCPATH")
f211b2af 956 (files '("lib/locale")))))
d6718df4 957
d45122f5
LC
958 (synopsis "The GNU C Library")
959 (description
7cdeac02
LC
960 "Any Unix-like operating system needs a C library: the library which
961defines the \"system calls\" and other basic facilities such as open, malloc,
962printf, exit...
963
964The GNU C library is used as the C library in the GNU system and most systems
965with the Linux kernel.")
4a44e743 966 (license lgpl2.0+)
6fd52309 967 (home-page "https://www.gnu.org/software/libc/")))
7cdeac02 968
e13b5474
MB
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
a33eac03
MB
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
0b3df5c9
MB
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"
a33eac03 1008 "glibc-2.29-supported-locales.patch"))))))
0b3df5c9 1009
5f3f7039
MB
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
e13b5474 1029(define-public glibc-2.27
ae66fdaf
MB
1030 (package
1031 (inherit glibc)
e13b5474 1032 (version "2.27")
ae66fdaf
MB
1033 (source (origin
1034 (inherit (package-source glibc))
1035 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
1036 (sha256
1037 (base32
e13b5474
MB
1038 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
1039 (patches (search-patches "glibc-ldd-x86_64.patch"
1040 "glibc-2.27-git-fixes.patch"
ae66fdaf 1041 "glibc-hidden-visibility-ldconfig.patch"
e13b5474
MB
1042 "glibc-versioned-locpath.patch"
1043 "glibc-allow-kernel-2.6.32.patch"
1b9fb043 1044 "glibc-reinstate-prlimit64-fallback.patch"
ca3757e1 1045 "glibc-2.27-supported-locales.patch"
c86b5f1b
EF
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
19ac2ba8 1049
6869b663 1050(define-public (make-gcc-libc base-gcc libc)
3ed497d4
CD
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
2073b55e
LC
1057 (ensure-keyword-arguments (package-arguments base-gcc)
1058 '(#:implicit-inputs? #f)))
3ed497d4 1059 (native-inputs
2b1d7082
CD
1060 `(,@(package-native-inputs base-gcc)
1061 ,@(append (fold alist-delete (%final-inputs) '("libc" "libc:static")))
1062 ("libc" ,libc)
1063 ("libc:static" ,libc "static")))))
3ed497d4 1064
0845999a 1065(define-public (make-glibc-locales glibc)
aee6180c
LC
1066 (package
1067 (inherit glibc)
1068 (name "glibc-locales")
1069 (source (origin (inherit (package-source glibc))
d4137d84
KK
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"))
aee6180c
LC
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,
36a4366d
EF
1082more than 400 in total. To use them set the @code{LOCPATH} environment variable
1083to the @code{share/locale} sub-directory of this package.")
aee6180c 1084 (outputs '("out")) ;110+ MiB
605217be 1085 (native-search-paths '())
aee6180c
LC
1086 (arguments
1087 (let ((args `(#:tests? #f #:strip-binaries? #f
1088 ,@(package-arguments glibc))))
1089 (substitute-keyword-arguments args
0e6cee21
LC
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))
aee6180c 1098 ((#:phases phases)
2320d4f0
EF
1099 `(modify-phases ,phases
1100 (replace 'build
1101 (lambda _
bf8e8a74
MW
1102 (invoke "make" "localedata/install-locales"
1103 "-j" (number->string (parallel-job-count)))))
0e6cee21
LC
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)))
2bbd674b
MB
1131 (delete 'install)
1132 (delete 'move-static-libs)))
aee6180c
LC
1133 ((#:configure-flags flags)
1134 `(append ,flags
85e57214 1135 ;; Use $(libdir)/locale/X.Y as is the case by default.
85860fdf 1136 (list (string-append "libc_cv_complocaledir="
aee6180c 1137 (assoc-ref %outputs "out")
f2d7bbb5 1138 "/lib/locale/"
c6bc8e22
MB
1139 ,(version-major+minor
1140 (package-version glibc)))))))))))
aee6180c 1141
0d3f2716
MÁAV
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))
c9505f3f 1150 (package
0d3f2716 1151 (name name)
c9505f3f
LC
1152 (version (package-version glibc))
1153 (source #f)
1154 (build-system trivial-build-system)
1155 (arguments
f2d7bbb5 1156 `(#:modules ((guix build utils))
c9505f3f 1157 #:builder (begin
44161fe1 1158 (use-modules (guix build utils))
c9505f3f
LC
1159
1160 (let* ((libc (assoc-ref %build-inputs "glibc"))
1161 (gzip (assoc-ref %build-inputs "gzip"))
1162 (out (assoc-ref %outputs "out"))
f2d7bbb5 1163 (localedir (string-append out "/lib/locale/"
c6bc8e22 1164 ,(version-major+minor version))))
c9505f3f
LC
1165 ;; 'localedef' needs 'gzip'.
1166 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1167
1168 (mkdir-p localedir)
44161fe1
MW
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")))
0d3f2716 1185 ',locales)
44161fe1 1186 #t))))
58a75996
MO
1187 (native-inputs `(("glibc" ,glibc)
1188 ("gzip" ,gzip)))
0d3f2716
MÁAV
1189 (synopsis (if default-locales?
1190 (P_ "Small sample of UTF-8 locales")
1191 (P_ "Customized sample of UTF-8 locales")))
c9505f3f 1192 (description
0d3f2716
MÁAV
1193 (if default-locales?
1194 (P_ "This package provides a small sample of UTF-8 locales mostly useful in
c9505f3f 1195test environments.")
0d3f2716
MÁAV
1196 (format #f (P_ "This package provides the following UTF-8 locales:
1197@itemize
1198~{@item ~a~%~}
1199@end itemize~%")
1200 locales)))
c9505f3f
LC
1201 (home-page (package-home-page glibc))
1202 (license (package-license glibc))))
aee6180c 1203
0845999a
RW
1204(define-public glibc-locales
1205 (make-glibc-locales glibc))
1206(define-public glibc-utf8-locales
1207 (make-glibc-utf8-locales glibc))
1208
f77993bb 1209;; Packages provided to ease use of binaries linked against the previous libc.
8176ef86
MB
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")))
0845999a 1216
ce0614dd
LC
1217(define-public which
1218 (package
1219 (name "which")
70ca2e94 1220 (version "2.21")
ce0614dd
LC
1221 (source (origin
1222 (method url-fetch)
1223 (uri (string-append "mirror://gnu/which/which-"
1224 version ".tar.gz"))
1225 (sha256
1226 (base32
70ca2e94 1227 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
ce0614dd
LC
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
1233variety of options. It is an alternative to the shell \"type\" built-in
1234command.")
1235 (license gpl3+))) ; some files are under GPLv2+
1236
21a8fe1b 1237(define-public glibc/hurd-headers
2d546858 1238 (package (inherit glibc)
21a8fe1b
MR
1239 (name "glibc-hurd-headers")
1240 (outputs '("out"))
1241 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1242 ("hurd-headers" ,hurd-headers)))
1339a03b
JN
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)))
21a8fe1b 1252 (arguments
2d546858 1253 (substitute-keyword-arguments (package-arguments glibc)
21a8fe1b
MR
1254 ;; We just pass the flags really needed to build the headers.
1255 ((#:configure-flags _)
1256 `(list "--enable-add-ons"
2d546858 1257 "--host=i586-pc-gnu"))
21a8fe1b 1258 ((#:phases _)
c04e5116
TGR
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
b4c4f339
MW
1270 (string-append out "/include/gnu/stubs.h"))))
1271 #t))
2d546858 1272 (delete 'build))))))) ; nothing to build
21a8fe1b 1273
e789d9a8
LC
1274(define-public tzdata
1275 (package
1276 (name "tzdata")
078dbd22
VL
1277 ;; This package should be kept in sync with python-pytz in (gnu packages
1278 ;; time).
1279 (version "2021a")
e789d9a8
LC
1280 (source (origin
1281 (method url-fetch)
1282 (uri (string-append
27b3568b 1283 "https://data.iana.org/time-zones/releases/tzdata"
e789d9a8
LC
1284 version ".tar.gz"))
1285 (sha256
1286 (base32
078dbd22 1287 "022fn6gkmp7pamlgab04x0dm5hnyn2m2fcnyr3pvm36612xd5rrr"))))
e789d9a8
LC
1288 (build-system gnu-build-system)
1289 (arguments
fce5ce77 1290 `(#:tests? #f
e789d9a8
LC
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")
62868f12
LF
1295 (string-append "TZDEFAULT=" out
1296 "/share/zoneinfo/localtime")
e789d9a8
LC
1297
1298 ;; Likewise for the C library routines.
1299 (string-append "LIBDIR=" tmp "/lib")
1300 (string-append "MANDIR=" tmp "/man")
1301
fce5ce77
MB
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
e789d9a8
LC
1312 "AWK=awk"
1313 "CC=gcc"))
1314 #:modules ((guix build utils)
1315 (guix build gnu-build-system)
1316 (srfi srfi-1))
1317 #:phases
c8f35458
JD
1318 (modify-phases %standard-phases
1319 (replace 'unpack
1320 (lambda* (#:key source inputs #:allow-other-keys)
408fcff6
MW
1321 (invoke "tar" "xvf" source)
1322 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
c8f35458
JD
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")))
62868f12
LF
1327 ;; Discard zic, dump, and tzselect, already
1328 ;; provided by glibc.
1329 (delete-file-recursively (string-append out "/usr"))
c8f35458
JD
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
408fcff6
MW
1337 (string-append out "/share/zoneinfo-leaps"))
1338 #t)))
c8f35458 1339 (delete 'configure))))
e789d9a8
LC
1340 (inputs `(("tzcode" ,(origin
1341 (method url-fetch)
1342 (uri (string-append
27b3568b 1343 "https://data.iana.org/time-zones/releases/tzcode"
e789d9a8
LC
1344 version ".tar.gz"))
1345 (sha256
1346 (base32
078dbd22 1347 "1l02b0jiwp3fl0xd6227i69d26rmx3yrnq0ssq9vvdmm4jhvyipb"))))))
80b63e67 1348 (home-page "https://www.iana.org/time-zones")
e789d9a8
LC
1349 (synopsis "Database of current and historical time zones")
1350 (description "The Time Zone Database (often called tz or zoneinfo)
1351contains code and data that represent the history of local time for many
35b9e423 1352representative locations around the globe. It is updated periodically to
e789d9a8
LC
1353reflect changes made by political bodies to time zone boundaries, UTC offsets,
1354and daylight-saving rules.")
1355 (license public-domain)))
1356
75aea16f
LF
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.
f9c3bd2e 1362(define-public tzdata-for-tests
cd50b9f0
MB
1363 (hidden-package
1364 (package
a5cd5c91 1365 (inherit tzdata)
9edb3f66 1366 (version "2019c")
a5cd5c91
MB
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
9edb3f66 1374 "0z7w1yv37cfk8yhix2cillam091vgp1j4g8fv84261q9mdnq1ivr"))))
a5cd5c91
MB
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
9edb3f66 1383 "1m3y2rnf1nggxxhxplab5zdd5whvar3ijyrv7lifvm82irkd7szn")))))))))
3ffaec13 1384
7309045c
JN
1385(define-public libiconv
1386 (package
1387 (name "libiconv")
a55fbab7 1388 (version "1.15")
7309045c
JN
1389 (source (origin
1390 (method url-fetch)
1391 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1392 version ".tar.gz"))
1393 (sha256
1394 (base32
5c6b6827 1395 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
7309045c
JN
1396 (modules '((guix build utils)))
1397 (snippet
1398 ;; Work around "declared gets" error on glibc systems (fixed by
1399 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
6cbee49d
MW
1400 '(begin
1401 (substitute* "srclib/stdio.in.h"
1402 (("^#undef gets") "")
1403 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1404 #t))))
7309045c
JN
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
1409that lack it. iconv is used to convert between character encodings in a
1410program. It supports a wide variety of different encodings.")
6fd52309 1411 (home-page "https://www.gnu.org/software/libiconv/")
7309045c
JN
1412 (license lgpl3+)))
1413
4dab8c59
JN
1414(define* (libiconv-if-needed #:optional (target (%current-target-system)))
1415 "Return either a libiconv package specification to include in a dependency
1416list for platforms that have an incomplete libc, or the empty list. If a
1417package 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
bdb36958
LC
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)))
571aa6cd 1429
fb77c614
LC
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
1722d680 1436;;; base.scm ends here