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