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