gnu: gambit-c: Update to 4.9.0.
[jackhill/guix/guix.git] / gnu / packages / base.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
5 ;;; Copyright © 2014, 2015, 2016, 2018 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
7 ;;; Copyright © 2014, 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
8 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
10 ;;; Copyright © 2016, 2018 Alex Vong <alexvong1995@gmail.com>
11 ;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
12 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
13 ;;; Copyright © 2017, 2018 Marius Bakke <mbakke@fastmail.com>
14 ;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
15 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
16 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
17 ;;;
18 ;;; This file is part of GNU Guix.
19 ;;;
20 ;;; GNU Guix is free software; you can redistribute it and/or modify it
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 ;;;
25 ;;; GNU Guix is distributed in the hope that it will be useful, but
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
31 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
32
33 (define-module (gnu packages base)
34 #:use-module ((guix licenses)
35 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
36 #:use-module (gnu packages)
37 #:use-module (gnu packages acl)
38 #:use-module (gnu packages bash)
39 #:use-module (gnu packages bison)
40 #:use-module (gnu packages ed)
41 #:use-module (gnu packages guile)
42 #:use-module (gnu packages multiprecision)
43 #:use-module (gnu packages compression)
44 #:use-module (gnu packages perl)
45 #:use-module (gnu packages linux)
46 #:use-module (gnu packages pcre)
47 #:use-module (gnu packages texinfo)
48 #:use-module (gnu packages hurd)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages gettext)
51 #:use-module (guix utils)
52 #:use-module (guix packages)
53 #:use-module (guix download)
54 #:use-module (guix git-download)
55 #:use-module (guix build-system gnu)
56 #:use-module (guix build-system trivial)
57 #:use-module (ice-9 match)
58 #:export (glibc
59 libiconv-if-needed))
60
61 ;;; Commentary:
62 ;;;
63 ;;; Base packages of the Guix-based GNU user-land software distribution.
64 ;;;
65 ;;; Code:
66
67 (define-public hello
68 (package
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
82 serves as an example of standard GNU coding practices. As such, it supports
83 command-line arguments, multiple languages, and so on.")
84 (home-page "https://www.gnu.org/software/hello/")
85 (license gpl3+)))
86
87 (define-public grep
88 (package
89 (name "grep")
90 (version "3.1")
91 (source (origin
92 (method url-fetch)
93 (uri (string-append "mirror://gnu/grep/grep-"
94 version ".tar.xz"))
95 (sha256
96 (base32
97 "0zm0ywmyz9g8vn1plw14mn8kj74yipx5qsljndbyfgmvndx5qqnv"))
98 (patches (search-patches "grep-timing-sensitive-test.patch"))))
99 (build-system gnu-build-system)
100 (native-inputs `(("perl" ,perl))) ;some of the tests require it
101 (inputs `(("pcre" ,pcre)))
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))))))
116 (synopsis "Print lines matching a pattern")
117 (description
118 "grep is a tool for finding text inside files. Text is found by
119 matching a pattern provided by the user in one or many files. The pattern
120 may be provided as a basic or extended regular expression, or as fixed
121 strings. By default, the matching text is simply printed to the screen,
122 however the output can be greatly customized to include, for example, line
123 numbers. GNU grep offers many extensions over the standard utility,
124 including, for example, recursive directory searching.")
125 (license gpl3+)
126 (home-page "https://www.gnu.org/software/grep/")))
127
128 (define-public sed
129 (package
130 (name "sed")
131 (version "4.5")
132 (source (origin
133 (method url-fetch)
134 (uri (string-append "mirror://gnu/sed/sed-" version
135 ".tar.xz"))
136 (sha256
137 (base32
138 "0h3b2jfj57wmz680vkbyavlsrkak556qhvs7m7fdlawwhg477bbs"))))
139 (build-system gnu-build-system)
140 (synopsis "Stream editor")
141 (arguments
142 `(#:phases
143 (modify-phases %standard-phases
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"))
152 #t)))))
153 (native-inputs
154 `(("perl" ,perl))) ;for tests
155 (description
156 "Sed is a non-interactive, text stream editor. It receives a text
157 input from a file or from standard input and it then applies a series of text
158 editing commands to the stream and prints its output to standard output. It
159 is often used for substituting text patterns in a stream. The GNU
160 implementation offers several extensions over the standard utility.")
161 (license gpl3+)
162 (home-page "https://www.gnu.org/software/sed/")))
163
164 (define-public tar
165 (package
166 (name "tar")
167 (version "1.30")
168 (source (origin
169 (method url-fetch)
170 (uri (string-append "mirror://gnu/tar/tar-"
171 version ".tar.xz"))
172 (sha256
173 (base32
174 "1lyjyk8z8hdddsxw0ikchrsfg3i0x3fsh7l63a8jgaz1n7dr5gzi"))
175 (patches (search-patches "tar-skip-unreliable-tests.patch"
176 "tar-remove-wholesparse-check.patch"))))
177 (build-system gnu-build-system)
178 ;; Note: test suite requires ~1GiB of disk space.
179 (arguments
180 `(#:phases (modify-phases %standard-phases
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")))
188 #t))))
189
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
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.
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'"))))
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
216 (synopsis "Managing tar archives")
217 (description
218 "Tar provides the ability to create tar archives, as well as the
219 ability to extract, update or list files in an existing archive. It is
220 useful for combining many files into one larger file, while maintaining
221 directory structure and file information such as permissions and
222 creation/modification dates. GNU tar offers many extensions over the
223 standard utility.")
224 (license gpl3+)
225 (home-page "https://www.gnu.org/software/tar/")))
226
227 (define-public patch
228 (package
229 (name "patch")
230 (version "2.7.6")
231 (source (origin
232 (method url-fetch)
233 (uri (string-append "mirror://gnu/patch/patch-"
234 version ".tar.xz"))
235 (sha256
236 (base32
237 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
238 (patches (search-patches "patch-hurd-path-max.patch"))))
239 (build-system gnu-build-system)
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 '()))
246 (native-inputs `(("ed" ,ed)))
247 (synopsis "Apply differences to originals, with optional backups")
248 (description
249 "Patch is a program that applies changes to files based on differences
250 laid out as by the program \"diff\". The changes may be applied to one or more
251 files depending on the contents of the diff file. It accepts several
252 different diff formats. It may also be used to revert previously applied
253 differences.")
254 (license gpl3+)
255 (home-page "https://savannah.gnu.org/projects/patch/")))
256
257 (define-public diffutils
258 (package
259 (name "diffutils")
260 (version "3.6")
261 (source (origin
262 (method url-fetch)
263 (uri (string-append "mirror://gnu/diffutils/diffutils-"
264 version ".tar.xz"))
265 (sha256
266 (base32
267 "1mivg0fy3a6fcn535ln8nkgfj6vxh5hsxxs5h6692wxmsjyyh8fn"))
268 (patches (search-patches "diffutils-getopt.patch"))))
269 (build-system gnu-build-system)
270 (synopsis "Comparing and merging files")
271 (description
272 "GNU Diffutils is a package containing tools for finding the
273 differences between files. The \"diff\" command is used to show how two files
274 differ, while \"cmp\" shows the offsets and line numbers where they differ.
275 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
276 interactive means to merge two files.")
277 (license gpl3+)
278 (home-page "https://www.gnu.org/software/diffutils/")))
279
280 (define-public findutils
281 (package
282 (name "findutils")
283 (version "4.6.0")
284 (source (origin
285 (method url-fetch)
286 (uri (string-append "mirror://gnu/findutils/findutils-"
287 version ".tar.gz"))
288 (sha256
289 (base32
290 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
291 (patches (search-patches
292 "findutils-localstatedir.patch"
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))))
304 (build-system gnu-build-system)
305 (arguments
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 '()))))
315 (synopsis "Operating on files matching given criteria")
316 (description
317 "Findutils supplies the basic file directory searching utilities of the
318 GNU system. It consists of two primary searching utilities: \"find\"
319 recursively 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
321 are included: \"updatedb\" updates the file name database and \"xargs\" may be
322 used to apply commands with arbitrarily long arguments.")
323 (license gpl3+)
324 (home-page "https://www.gnu.org/software/findutils/")))
325
326 (define-public coreutils
327 (package
328 (name "coreutils")
329 (version "8.29")
330 (source (origin
331 (method url-fetch)
332 (uri (string-append "mirror://gnu/coreutils/coreutils-"
333 version ".tar.xz"))
334 (sha256
335 (base32
336 "0plm1zs9il6bb5mk881qvbghq4glc8ybbgakk2lfzb0w64fgml4j"))))
337 (build-system gnu-build-system)
338 (inputs `(("acl" ,acl) ; TODO: add SELinux
339 ("gmp" ,gmp) ;bignums in 'expr', yay!
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.
346 (native-inputs
347 ;; Perl is needed to run tests in native builds, and to run the bundled
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.
351 (if (%current-target-system)
352 '()
353 `(("perl" ,perl))))
354 (outputs '("out" "debug"))
355 (arguments
356 `(#:parallel-build? #f ; help2man may be called too early
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"))
363
364 (substitute* (find-files "gnulib-tests" "\\.c$")
365 (("/bin/sh") (which "sh")))
366 (substitute* (find-files "tests" "\\.sh$")
367 (("#!/bin/sh") (which "sh")))
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 '())))
375 (synopsis "Core GNU utilities (file, text, shell)")
376 (description
377 "GNU Coreutils includes all of the basic command-line tools that are
378 expected in a POSIX system. These provide the basic file, shell and text
379 manipulation functions of the GNU system. Most of these tools offer extended
380 functionality beyond that which is outlined in the POSIX standard.")
381 (license gpl3+)
382 (home-page "https://www.gnu.org/software/coreutils/")))
383
384 (define-public coreutils-minimal
385 ;; Coreutils without its optional dependencies.
386 (package
387 (inherit coreutils)
388 (name "coreutils-minimal")
389 (outputs '("out"))
390 (inputs '())))
391
392 (define-public gnu-make
393 (package
394 (name "make")
395 (version "4.2.1")
396 (source (origin
397 (method url-fetch)
398 (uri (string-append "mirror://gnu/make/make-" version
399 ".tar.bz2"))
400 (sha256
401 (base32
402 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
403 (patches (search-patches "make-impure-dirs.patch"
404 "make-glibc-compat.patch"))))
405 (build-system gnu-build-system)
406 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
407 (inputs `(("guile" ,guile-2.0)))
408 (outputs '("out" "debug"))
409 (arguments
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
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 =.*$")
421 (format #f "default_shell = \"~a/bin/sh\";\n"
422 bash)))
423 #t))))))
424 (synopsis "Remake files automatically")
425 (description
426 "Make is a program that is used to control the production of
427 executables or other files from their source files. The process is
428 controlled from a Makefile, in which the developer specifies how each file is
429 generated from its source. It has powerful dependency resolution and the
430 ability to determine when files have to be regenerated after their sources
431 change. GNU make offers many powerful extensions over the standard utility.")
432 (license gpl3+)
433 (home-page "https://www.gnu.org/software/make/")))
434
435 (define-public binutils
436 (package
437 (name "binutils")
438 (version "2.30")
439 (source (origin
440 (method url-fetch)
441 (uri (string-append "mirror://gnu/binutils/binutils-"
442 version ".tar.bz2"))
443 (sha256
444 (base32
445 "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg"))
446 (patches (search-patches "binutils-loongson-workaround.patch"))))
447 (build-system gnu-build-system)
448
449 ;; TODO: Add dependency on zlib + those for Gold.
450 (arguments
451 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
452 ;; on GCC when bootstrapping.
453 "LDFLAGS=-static-libgcc"
454
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
461 ;; Don't search under /usr/lib & co.
462 "--with-lib-path=/no-ld-lib-path"
463
464 ;; Install BFD. It ends up in a hidden directory,
465 ;; but it's here.
466 "--enable-install-libbfd"
467
468 ;; Make sure 'ar' and 'ranlib' produce archives in a
469 ;; deterministic fashion.
470 "--enable-deterministic-archives")))
471
472 (synopsis "Binary utilities: bfd gas gprof ld")
473 (description
474 "GNU Binutils is a collection of tools for working with binary files.
475 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
476 Other tools include programs to display binary profiling information, list
477 the strings in a binary file, and utilities for working with archives. The
478 \"bfd\" library for working with executable and object formats is also
479 included.")
480 (license gpl3+)
481 (home-page "https://www.gnu.org/software/binutils/")))
482
483 (define-public binutils/fixed
484 ;; TODO: Incorporate this in binutils during the next rebuild cycle.
485 (hidden-package
486 (package
487 (inherit binutils)
488 (source (origin
489 (inherit (package-source binutils))
490 (patches (append (origin-patches (package-source binutils))
491 (search-patches
492 "binutils-aarch64-symbol-relocation.patch"))))))))
493
494 (define* (make-ld-wrapper name #:key
495 (target (const #f))
496 binutils
497 (guile (canonical-package guile-2.2))
498 (bash (canonical-package bash))
499 (guile-for-build guile))
500 "Return a package called NAME that contains a wrapper for the 'ld' program
501 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
502 wrapper uses GUILE and BASH.
503
504 TARGET must be a one-argument procedure that, given a system type, returns a
505 cross-compilation target triplet or #f. When the result is not #f, make a
506 wrapper for the cross-linker for that target, called 'TARGET-ld'."
507 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
508 ;; its result can be delayed until the 'arguments' field is evaluated, thus
509 ;; in a context where '%current-system' is accurate.
510 (package
511 (name name)
512 (version "0")
513 (source #f)
514 (build-system trivial-build-system)
515 (inputs `(("binutils" ,binutils)
516 ("guile" ,guile)
517 ("bash" ,bash)
518 ("wrapper" ,(search-path %load-path
519 "gnu/packages/ld-wrapper.in"))))
520 (arguments
521 (let ((target (target (%current-system))))
522 `(#:guile ,guile-for-build
523 #:modules ((guix build utils))
524 #:builder (begin
525 (use-modules (guix build utils)
526 (system base compile))
527
528 (let* ((out (assoc-ref %outputs "out"))
529 (bin (string-append out "/bin"))
530 (ld ,(if target
531 `(string-append bin "/" ,target "-ld")
532 '(string-append bin "/ld")))
533 (go (string-append ld ".go")))
534
535 (setvbuf (current-output-port) _IOLBF)
536 (format #t "building ~s/bin/ld wrapper in ~s~%"
537 (assoc-ref %build-inputs "binutils")
538 out)
539
540 (mkdir-p bin)
541 (copy-file (assoc-ref %build-inputs "wrapper") ld)
542 (substitute* ld
543 (("@SELF@")
544 ld)
545 (("@GUILE@")
546 (string-append (assoc-ref %build-inputs "guile")
547 "/bin/guile"))
548 (("@BASH@")
549 (string-append (assoc-ref %build-inputs "bash")
550 "/bin/bash"))
551 (("@LD@")
552 (string-append (assoc-ref %build-inputs "binutils")
553 ,(if target
554 (string-append "/bin/"
555 target "-ld")
556 "/bin/ld"))))
557 (chmod ld #o555)
558 (compile-file ld #:output-file go)
559 #t)))))
560 (synopsis "The linker wrapper")
561 (description
562 "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
563 missing '-rpath' flags, and to detect any misuse of libraries outside of the
564 store.")
565 (home-page "https://www.gnu.org/software/guix//")
566 (license gpl3+)))
567
568 (export make-ld-wrapper)
569
570 (define-public glibc/linux
571 (package
572 (name "glibc")
573 ;; Note: Always use a dot after the minor version since various places rely
574 ;; on "version-major+minor" to determine where locales are found.
575 (version "2.27")
576 (source (origin
577 (method url-fetch)
578 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
579 (sha256
580 (base32
581 "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"))
582 (snippet
583 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
584 ;; required on LFS distros to avoid loading the distro's libc.so
585 ;; instead of ours.
586 '(begin
587 (substitute* "sysdeps/unix/sysv/linux/configure"
588 (("use_ldconfig=yes")
589 "use_ldconfig=no"))
590 #t))
591 (modules '((guix build utils)))
592 (patches (search-patches "glibc-ldd-x86_64.patch"
593 "glibc-2.27-git-fixes.patch"
594 "glibc-hidden-visibility-ldconfig.patch"
595 "glibc-versioned-locpath.patch"
596 "glibc-allow-kernel-2.6.32.patch"
597 "glibc-reinstate-prlimit64-fallback.patch"))))
598 (build-system gnu-build-system)
599
600 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
601 ;; users should automatically pull Linux headers as well.
602 (propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
603
604 (outputs '("out" "debug"
605 "static")) ;9 MiB of .a files
606
607 (arguments
608 `(#:out-of-source? #t
609
610 ;; The libraries have an empty RUNPATH, but some, such as the versioned
611 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
612 ;; these libraries are always going to be found anyway, just skip
613 ;; RUNPATH checks.
614 #:validate-runpath? #f
615
616 #:modules ((ice-9 ftw)
617 (srfi srfi-26)
618 (guix build utils)
619 (guix build gnu-build-system))
620
621 #:configure-flags
622 (list "--sysconfdir=/etc"
623
624 ;; Installing a locale archive with all the locales is to
625 ;; expensive (~100 MiB), so we rely on users to install the
626 ;; locales they really want.
627 ;;
628 ;; Set the default locale path. In practice, $LOCPATH may be
629 ;; defined to point whatever locales users want. However, setuid
630 ;; binaries don't honor $LOCPATH, so they'll instead look into
631 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
632 ;; with the idea that it is going to be populated by the sysadmin.
633 ;; The "X.Y" sub-directory is because locale data formats are
634 ;; incompatible across libc versions; see
635 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
636 ;;
637 ;; `--localedir' is not honored, so work around it.
638 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
639 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
640 ,(version-major+minor version))
641
642 (string-append "--with-headers="
643 (assoc-ref ,(if (%current-target-system)
644 '%build-target-inputs
645 '%build-inputs)
646 "kernel-headers")
647 "/include")
648
649 ;; This is the default for most architectures as of GNU libc 2.26,
650 ;; but we specify it explicitly for clarity and consistency. See
651 ;; "kernel-features.h" in the GNU libc for details.
652 "--enable-kernel=3.2.0"
653
654 ;; Use our Bash instead of /bin/sh.
655 (string-append "BASH_SHELL="
656 (assoc-ref %build-inputs "bash")
657 "/bin/bash"))
658
659 #:tests? #f ; XXX
660 #:phases (modify-phases %standard-phases
661 (add-before
662 'configure 'pre-configure
663 (lambda* (#:key inputs native-inputs outputs
664 #:allow-other-keys)
665 (let* ((out (assoc-ref outputs "out"))
666 (bin (string-append out "/bin"))
667 ;; FIXME: Normally we would look it up only in INPUTS
668 ;; but cross-base uses it as a native input.
669 (bash (or (assoc-ref inputs "static-bash")
670 (assoc-ref native-inputs "static-bash"))))
671 ;; Install the rpc data base file under `$out/etc/rpc'.
672 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
673 (substitute* "sunrpc/Makefile"
674 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
675 (string-append out "/etc/rpc" suffix "\n"))
676 (("^install-others =.*$")
677 (string-append "install-others = " out "/etc/rpc\n")))
678
679 (substitute* "Makeconfig"
680 ;; According to
681 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
682 ;; linking against libgcc_s is not needed with GCC
683 ;; 4.7.1.
684 ((" -lgcc_s") ""))
685
686 ;; Have `system' use that Bash.
687 (substitute* "sysdeps/posix/system.c"
688 (("#define[[:blank:]]+SHELL_PATH.*$")
689 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
690 bash)))
691
692 ;; Same for `popen'.
693 (substitute* "libio/iopopen.c"
694 (("/bin/sh")
695 (string-append bash "/bin/sh")))
696
697 ;; Same for the shell used by the 'exec' functions for
698 ;; scripts that lack a shebang.
699 (substitute* (find-files "." "^paths\\.h$")
700 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
701 (string-append "#define _PATH_BSHELL \""
702 bash "/bin/sh\"\n")))
703
704 ;; Nscd uses __DATE__ and __TIME__ to create a string to
705 ;; make sure the client and server come from the same
706 ;; libc. Use something deterministic instead.
707 (substitute* "nscd/nscd_stat.c"
708 (("static const char compilation\\[21\\] =.*$")
709 (string-append
710 "static const char compilation[21] = \""
711 (string-take (basename out) 20) "\";\n")))
712
713 ;; Make sure we don't retain a reference to the
714 ;; bootstrap Perl.
715 (substitute* "malloc/mtrace.pl"
716 (("^#!.*")
717 ;; The shebang can be omitted, because there's the
718 ;; "bilingual" eval/exec magic at the top of the file.
719 "")
720 (("exec @PERL@")
721 "exec perl"))
722
723 #t)))
724
725 (add-after 'install 'move-static-libs
726 (lambda* (#:key outputs #:allow-other-keys)
727 ;; Move static libraries to the "static" output.
728 (define (static-library? file)
729 ;; Return true if FILE is a static library. The
730 ;; "_nonshared.a" files are referred to by libc.so,
731 ;; libpthread.so, etc., which are in fact linker
732 ;; scripts.
733 (and (string-suffix? ".a" file)
734 (not (string-contains file "_nonshared"))))
735
736 (define (linker-script? file)
737 ;; Guess whether FILE, a ".a" file, is actually a
738 ;; linker script.
739 (and (not (ar-file? file))
740 (not (elf-file? file))))
741
742 (let* ((out (assoc-ref outputs "out"))
743 (lib (string-append out "/lib"))
744 (files (scandir lib static-library?))
745 (static (assoc-ref outputs "static"))
746 (slib (string-append static "/lib")))
747 (mkdir-p slib)
748 (for-each (lambda (base)
749 (rename-file (string-append lib "/" base)
750 (string-append slib "/" base)))
751 files)
752
753 ;; Usually libm.a is a linker script so we need to
754 ;; change the file names in there to refer to STATIC
755 ;; instead of OUT.
756 (for-each (lambda (ld-script)
757 (substitute* ld-script
758 ((out) static)))
759 (filter linker-script?
760 (map (cut string-append slib "/" <>)
761 files)))
762 #t))))))
763
764 (inputs `(("static-bash" ,static-bash)))
765
766 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
767 ;; install the message catalogs, with 'msgfmt'.
768 (native-inputs `(("texinfo" ,texinfo)
769 ("perl" ,perl)
770 ("bison" ,bison)
771 ("gettext" ,gettext-minimal)))
772
773 (native-search-paths
774 ;; Search path for packages that provide locale data. This is useful
775 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
776 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
777 ;; distros.
778 (list (search-path-specification
779 (variable "GUIX_LOCPATH")
780 (files '("lib/locale")))))
781
782 (synopsis "The GNU C Library")
783 (description
784 "Any Unix-like operating system needs a C library: the library which
785 defines the \"system calls\" and other basic facilities such as open, malloc,
786 printf, exit...
787
788 The GNU C library is used as the C library in the GNU system and most systems
789 with the Linux kernel.")
790 (license lgpl2.0+)
791 (home-page "https://www.gnu.org/software/libc/")))
792
793 (define-public glibc/hurd
794 ;; The Hurd's libc variant.
795 (package (inherit glibc/linux)
796 (name "glibc-hurd")
797 (version "2.23")
798 (source (origin
799 (method url-fetch)
800 (uri (string-append "http://alpha.gnu.org/gnu/hurd/glibc-"
801 version "-hurd+libpthread-20161218" ".tar.gz"))
802 (sha256
803 (base32
804 "0vpdv05j6j3ria5bw8gp468i64gij94cslxkxj9xkfgi6p615b8p"))))
805
806 ;; Libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
807 ;; so both should be propagated.
808 (propagated-inputs `(("hurd-core-headers" ,hurd-core-headers)))
809 (native-inputs
810 `(,@(package-native-inputs glibc/linux)
811 ("mig" ,mig)
812 ("perl" ,perl)))
813
814 (arguments
815 (substitute-keyword-arguments (package-arguments glibc/linux)
816 ((#:phases original-phases)
817 ;; Add libmachuser.so and libhurduser.so to libc.so's search path.
818 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-07/msg00051.html>.
819 `(modify-phases ,original-phases
820 (add-after 'install 'augment-libc.so
821 (lambda* (#:key outputs #:allow-other-keys)
822 (let* ((out (assoc-ref outputs "out")))
823 (substitute* (string-append out "/lib/libc.so")
824 (("/[^ ]+/lib/libc.so.0.3")
825 (string-append out "/lib/libc.so.0.3" " libmachuser.so" " libhurduser.so"))))
826 #t))
827 (add-after 'pre-configure 'pre-configure-set-pwd
828 (lambda _
829 ;; Use the right 'pwd'.
830 (substitute* "configure"
831 (("/bin/pwd") "pwd"))
832 #t))
833 (replace 'build
834 (lambda _
835 ;; Force mach/hurd/libpthread subdirs to build first in order to avoid
836 ;; linking errors.
837 ;; See <https://lists.gnu.org/archive/html/bug-hurd/2016-11/msg00045.html>
838 (let ((flags (list "-j" (number->string (parallel-job-count)))))
839 (define (make target)
840 (apply invoke "make" target flags))
841 (make "mach/subdir_lib")
842 (make "hurd/subdir_lib")
843 (make "libpthread/subdir_lib")
844 (apply invoke "make" flags))))))
845 ((#:configure-flags original-configure-flags)
846 `(append (list "--host=i586-pc-gnu"
847
848 ;; We need this to get a working openpty() function.
849 "--enable-pt_chown"
850
851 ;; <https://lists.gnu.org/archive/html/bug-hurd/2016-10/msg00033.html>
852 "--disable-werror"
853
854 ;; nscd fails to build for GNU/Hurd:
855 ;; <https://lists.gnu.org/archive/html/bug-hurd/2014-07/msg00006.html>.
856 ;; Disable it.
857 "--disable-nscd")
858 (filter (lambda (flag)
859 (not (string-prefix? "--enable-kernel=" flag)))
860 ,original-configure-flags)))))
861 (synopsis "The GNU C Library (GNU Hurd variant)")
862 (supported-systems %hurd-systems)))
863
864 (define* (glibc-for-target #:optional
865 (target (or (%current-target-system)
866 (%current-system))))
867 "Return the glibc for TARGET, GLIBC/LINUX for a Linux host or
868 GLIBC/HURD for a Hurd host"
869 (match target
870 ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
871 (_ glibc/linux)))
872
873 (define-syntax glibc
874 (identifier-syntax (glibc-for-target)))
875
876 ;; The "next" libc. Useful for populating locale data before reconfiguring the
877 ;; entire system on it. Will be the default in the next rebuild cycle.
878 (define-public glibc-2.28
879 (package
880 (inherit glibc)
881 (version "2.28")
882 (source (origin
883 (inherit (package-source glibc))
884 (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz"))
885 (sha256
886 (base32
887 "10iha5ynvdj5m62vgpgqbq4cwvc2yhyl2w9yyyjgfxmdmx8h145i"))
888 (patches (search-patches "glibc-allow-kernel-2.6.32.patch"
889 "glibc-ldd-x86_64.patch"
890 "glibc-hidden-visibility-ldconfig.patch"
891 "glibc-versioned-locpath.patch"))))))
892
893 ;; Below are old libc versions, which we use mostly to build locale data in
894 ;; the old format (which the new libc cannot cope with.)
895
896 (define-public glibc-2.26
897 (package
898 (inherit glibc)
899 ;; This version number corresponds to the output of `git describe` and the
900 ;; archive can be generated by checking out the commit ID and running:
901 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
902 ;; See <https://bugs.gnu.org/29406> for why this was necessary.
903 (version "2.26.105-g0890d5379c")
904 (source (origin
905 (inherit (package-source glibc))
906 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
907 "glibc-" (version-major+minor version) "-"
908 (caddr (string-split version #\.)) ".tar.xz"))
909 (sha256
910 (base32
911 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
912 (patches (search-patches "glibc-ldd-x86_64.patch"
913 "glibc-versioned-locpath.patch"
914 "glibc-allow-kernel-2.6.32.patch"))))))
915
916 (define-public glibc-2.25
917 (package
918 (inherit glibc)
919 (version "2.25")
920 (source (origin
921 (inherit (package-source glibc))
922 (uri (string-append "mirror://gnu/glibc/glibc-"
923 version ".tar.xz"))
924 (sha256
925 (base32
926 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
927 (patches (search-patches "glibc-ldd-x86_64.patch"
928 "glibc-versioned-locpath.patch"
929 "glibc-vectorized-strcspn-guards.patch"
930 "glibc-CVE-2017-1000366-pt1.patch"
931 "glibc-CVE-2017-1000366-pt2.patch"
932 "glibc-CVE-2017-1000366-pt3.patch"))))))
933
934 (define-public glibc-2.24
935 (package
936 (inherit glibc)
937 (version "2.24")
938 (source (origin
939 (inherit (package-source glibc))
940 (uri (string-append "mirror://gnu/glibc/glibc-"
941 version ".tar.xz"))
942 (sha256
943 (base32
944 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
945 (patches (search-patches "glibc-ldd-x86_64.patch"
946 "glibc-versioned-locpath.patch"
947 "glibc-vectorized-strcspn-guards.patch"
948 "glibc-CVE-2015-5180.patch"
949 "glibc-CVE-2017-1000366-pt1.patch"
950 "glibc-CVE-2017-1000366-pt2.patch"
951 "glibc-CVE-2017-1000366-pt3.patch"))))))
952
953 (define-public glibc-2.23
954 (package
955 (inherit glibc)
956 (version "2.23")
957 (source (origin
958 (inherit (package-source glibc))
959 (uri (string-append "mirror://gnu/glibc/glibc-"
960 version ".tar.xz"))
961 (sha256
962 (base32
963 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
964 (patches (search-patches "glibc-ldd-x86_64.patch"
965 "glibc-versioned-locpath.patch"
966 "glibc-vectorized-strcspn-guards.patch"
967 "glibc-CVE-2015-5180.patch"
968 "glibc-CVE-2016-3075.patch"
969 "glibc-CVE-2016-3706.patch"
970 "glibc-CVE-2016-4429.patch"
971 "glibc-CVE-2017-1000366-pt1.patch"
972 "glibc-CVE-2017-1000366-pt2.patch"
973 "glibc-CVE-2017-1000366-pt3.patch"))))))
974
975 (define-public glibc-2.22
976 (package
977 (inherit glibc)
978 (version "2.22")
979 (source (origin
980 (inherit (package-source glibc))
981 (uri (string-append "mirror://gnu/glibc/glibc-"
982 version ".tar.xz"))
983 (sha256
984 (base32
985 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
986 (patches (search-patches "glibc-ldd-x86_64.patch"
987 "glibc-o-largefile.patch"
988 "glibc-vectorized-strcspn-guards.patch"
989 "glibc-CVE-2015-5180.patch"
990 "glibc-CVE-2015-7547.patch"
991 "glibc-CVE-2016-3075.patch"
992 "glibc-CVE-2016-3706.patch"
993 "glibc-CVE-2016-4429.patch"
994 "glibc-CVE-2017-1000366-pt1.patch"
995 "glibc-CVE-2017-1000366-pt2.patch"
996 "glibc-CVE-2017-1000366-pt3.patch"))))
997 (arguments
998 (substitute-keyword-arguments (package-arguments glibc)
999 ((#:phases phases)
1000 `(modify-phases ,phases
1001 (add-before 'configure 'fix-pwd
1002 (lambda _
1003 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
1004 (substitute* "configure"
1005 (("/bin/pwd") "pwd"))
1006 #t))))))))
1007
1008 (define-public glibc-locales
1009 (package
1010 (inherit glibc)
1011 (name "glibc-locales")
1012 (source (origin (inherit (package-source glibc))
1013 (patches (cons (search-patch "glibc-locales.patch")
1014 (origin-patches (package-source glibc))))))
1015 (synopsis "All the locales supported by the GNU C Library")
1016 (description
1017 "This package provides all the locales supported by the GNU C Library,
1018 more than 400 in total. To use them set the 'LOCPATH' environment variable to
1019 the 'share/locale' sub-directory of this package.")
1020 (outputs '("out")) ;110+ MiB
1021 (native-search-paths '())
1022 (arguments
1023 (let ((args `(#:tests? #f #:strip-binaries? #f
1024 ,@(package-arguments glibc))))
1025 (substitute-keyword-arguments args
1026 ((#:phases phases)
1027 `(modify-phases ,phases
1028 (replace 'build
1029 (lambda _
1030 (invoke "make" "localedata/install-locales"
1031 "-j" (number->string (parallel-job-count)))))
1032 (delete 'install)
1033 (delete 'move-static-libs)))
1034 ((#:configure-flags flags)
1035 `(append ,flags
1036 ;; Use $(libdir)/locale/X.Y as is the case by default.
1037 (list (string-append "libc_cv_complocaledir="
1038 (assoc-ref %outputs "out")
1039 "/lib/locale/"
1040 ,(version-major+minor
1041 (package-version glibc)))))))))))
1042
1043 (define-public glibc-utf8-locales
1044 (package
1045 (name "glibc-utf8-locales")
1046 (version (package-version glibc))
1047 (source #f)
1048 (build-system trivial-build-system)
1049 (arguments
1050 `(#:modules ((guix build utils))
1051 #:builder (begin
1052 (use-modules (guix build utils))
1053
1054 (let* ((libc (assoc-ref %build-inputs "glibc"))
1055 (gzip (assoc-ref %build-inputs "gzip"))
1056 (out (assoc-ref %outputs "out"))
1057 (localedir (string-append out "/lib/locale/"
1058 ,(version-major+minor version))))
1059 ;; 'localedef' needs 'gzip'.
1060 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1061
1062 (mkdir-p localedir)
1063 (for-each (lambda (locale)
1064 (define file
1065 ;; Use the "normalized codeset" by
1066 ;; default--e.g., "en_US.utf8".
1067 (string-append localedir "/" locale ".utf8"))
1068
1069 (invoke "localedef" "--no-archive"
1070 "--prefix" localedir
1071 "-i" locale
1072 "-f" "UTF-8" file)
1073
1074 ;; For backward compatibility with Guix
1075 ;; <= 0.8.3, add "xx_YY.UTF-8".
1076 (symlink (string-append locale ".utf8")
1077 (string-append localedir "/"
1078 locale ".UTF-8")))
1079
1080 ;; These are the locales commonly used for
1081 ;; tests---e.g., in Guile's i18n tests.
1082 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1083 #t))))
1084 (inputs `(("glibc" ,glibc)
1085 ("gzip" ,gzip)))
1086 (synopsis "Small sample of UTF-8 locales")
1087 (description
1088 "This package provides a small sample of UTF-8 locales mostly useful in
1089 test environments.")
1090 (home-page (package-home-page glibc))
1091 (license (package-license glibc))))
1092
1093 (define-public which
1094 (package
1095 (name "which")
1096 (version "2.21")
1097 (source (origin
1098 (method url-fetch)
1099 (uri (string-append "mirror://gnu/which/which-"
1100 version ".tar.gz"))
1101 (sha256
1102 (base32
1103 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1104 (build-system gnu-build-system)
1105 (home-page "https://gnu.org/software/which/")
1106 (synopsis "Find full path of shell commands")
1107 (description
1108 "The which program finds the location of executables in PATH, with a
1109 variety of options. It is an alternative to the shell \"type\" built-in
1110 command.")
1111 (license gpl3+))) ; some files are under GPLv2+
1112
1113 (define-public glibc/hurd-headers
1114 (package (inherit glibc/hurd)
1115 (name "glibc-hurd-headers")
1116 (outputs '("out"))
1117 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1118 ("hurd-headers" ,hurd-headers)))
1119 (arguments
1120 (substitute-keyword-arguments (package-arguments glibc/hurd)
1121 ;; We just pass the flags really needed to build the headers.
1122 ((#:configure-flags _)
1123 `(list "--enable-add-ons"
1124 "--host=i586-pc-gnu"
1125 "--enable-obsolete-rpc"))
1126 ((#:phases _)
1127 '(modify-phases %standard-phases
1128 (replace 'install
1129 (lambda* (#:key outputs #:allow-other-keys)
1130 (invoke "make" "install-headers")
1131
1132 ;; Make an empty stubs.h to work around not being able to
1133 ;; produce a valid stubs.h and causing the build to fail. See
1134 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1135 (let ((out (assoc-ref outputs "out")))
1136 (close-port
1137 (open-output-file
1138 (string-append out "/include/gnu/stubs.h"))))
1139 #t))
1140 (delete 'build) ; nothing to build
1141 (add-before 'configure 'patch-configure-script
1142 (lambda _
1143 ;; Use the right 'pwd'.
1144 (substitute* "configure"
1145 (("/bin/pwd") "pwd"))
1146 #t))))))))
1147
1148 (define-public tzdata
1149 (package
1150 (name "tzdata")
1151 (version "2018e")
1152 (source (origin
1153 (method url-fetch)
1154 (uri (string-append
1155 "https://www.iana.org/time-zones/repository/releases/tzdata"
1156 version ".tar.gz"))
1157 (sha256
1158 (base32
1159 "0bk97fv2i5ns42prpmlaadsswdjwv0ifi7whj2s4q6l44rcqwa3b"))))
1160 (build-system gnu-build-system)
1161 (arguments
1162 '(#:tests? #f
1163 #:make-flags (let ((out (assoc-ref %outputs "out"))
1164 (tmp (getenv "TMPDIR")))
1165 (list (string-append "TOPDIR=" out)
1166 (string-append "TZDIR=" out "/share/zoneinfo")
1167 (string-append "TZDEFAULT=" out
1168 "/share/zoneinfo/localtime")
1169
1170 ;; Likewise for the C library routines.
1171 (string-append "LIBDIR=" tmp "/lib")
1172 (string-append "MANDIR=" tmp "/man")
1173
1174 "AWK=awk"
1175 "CC=gcc"))
1176 #:modules ((guix build utils)
1177 (guix build gnu-build-system)
1178 (srfi srfi-1))
1179 #:phases
1180 (modify-phases %standard-phases
1181 (replace 'unpack
1182 (lambda* (#:key source inputs #:allow-other-keys)
1183 (invoke "tar" "xvf" source)
1184 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
1185 (add-after 'install 'post-install
1186 (lambda* (#:key outputs #:allow-other-keys)
1187 ;; Move data in the right place.
1188 (let ((out (assoc-ref outputs "out")))
1189 ;; Discard zic, dump, and tzselect, already
1190 ;; provided by glibc.
1191 (delete-file-recursively (string-append out "/usr"))
1192 (symlink (string-append out "/share/zoneinfo")
1193 (string-append out "/share/zoneinfo/posix"))
1194 (delete-file-recursively
1195 (string-append out "/share/zoneinfo-posix"))
1196 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1197 (string-append out "/share/zoneinfo/right"))
1198 (delete-file-recursively
1199 (string-append out "/share/zoneinfo-leaps"))
1200 #t)))
1201 (delete 'configure))))
1202 (inputs `(("tzcode" ,(origin
1203 (method url-fetch)
1204 (uri (string-append
1205 "http://www.iana.org/time-zones/repository/releases/tzcode"
1206 version ".tar.gz"))
1207 (sha256
1208 (base32
1209 "1kpb02631s58i068mwq63xlamcv1ffj4p6y4wpb9kdl01vr0qd6a"))))))
1210 (home-page "https://www.iana.org/time-zones")
1211 (synopsis "Database of current and historical time zones")
1212 (description "The Time Zone Database (often called tz or zoneinfo)
1213 contains code and data that represent the history of local time for many
1214 representative locations around the globe. It is updated periodically to
1215 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1216 and daylight-saving rules.")
1217 (license public-domain)))
1218
1219 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1220 ;;; and a few other places. We can update this whenever we are able to rebuild
1221 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1222 ;;; will typically be obsolete and should never be referred to by a built
1223 ;;; package.
1224 (define-public tzdata-for-tests
1225 (hidden-package
1226 (package
1227 (inherit tzdata)
1228 (version "2018d")
1229 (source (origin
1230 (method url-fetch)
1231 (uri (string-append "https://www.iana.org/time-zones/repository"
1232 "/releases/tzdata" version ".tar.gz"))
1233 (sha256
1234 (base32
1235 "0m6020dnk9r40z7k36jp13fa06xip3hn0fdx3nly66jzxgffs1ji"))))
1236 (inputs `(("tzcode" ,(origin
1237 (method url-fetch)
1238 (uri (string-append
1239 "http://www.iana.org/time-zones/repository/releases/tzcode"
1240 version ".tar.gz"))
1241 (sha256
1242 (base32
1243 "1nd882yhsazmcfqmcqyfig3axycryl30gmizgqhqsx5dpa2lxr3x")))))))))
1244
1245 (define-public libiconv
1246 (package
1247 (name "libiconv")
1248 (version "1.15")
1249 (source (origin
1250 (method url-fetch)
1251 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1252 version ".tar.gz"))
1253 (sha256
1254 (base32
1255 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1256 (modules '((guix build utils)))
1257 (snippet
1258 ;; Work around "declared gets" error on glibc systems (fixed by
1259 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1260 '(begin
1261 (substitute* "srclib/stdio.in.h"
1262 (("^#undef gets") "")
1263 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1264 #t))))
1265 (build-system gnu-build-system)
1266 (synopsis "Character set conversion library")
1267 (description
1268 "libiconv provides an implementation of the iconv function for systems
1269 that lack it. iconv is used to convert between character encodings in a
1270 program. It supports a wide variety of different encodings.")
1271 (home-page "https://www.gnu.org/software/libiconv/")
1272 (license lgpl3+)))
1273
1274 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1275 "Return either a libiconv package specification to include in a dependency
1276 list for platforms that have an incomplete libc, or the empty list. If a
1277 package needs iconv ,@(libiconv-if-needed) should be added."
1278 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1279 ;; without iconv, such as MinGW, must return the then clause.
1280 (if (target-mingw? target)
1281 `(("libiconv" ,libiconv))
1282 '()))
1283
1284 (define-public (canonical-package package)
1285 ;; Avoid circular dependency by lazily resolving 'commencement'.
1286 (let* ((iface (resolve-interface '(gnu packages commencement)))
1287 (proc (module-ref iface 'canonical-package)))
1288 (proc package)))
1289
1290 (define-public (%final-inputs)
1291 "Return the list of \"final inputs\"."
1292 ;; Avoid circular dependency by lazily resolving 'commencement'.
1293 (let ((iface (resolve-interface '(gnu packages commencement))))
1294 (module-ref iface '%final-inputs)))
1295
1296 ;;; base.scm ends here