gnu: libiconv: Update to 1.15.
[jackhill/guix/guix.git] / gnu / packages / base.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 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 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 © 2017 Rene Saavedra <rennes@openmailbox.org>
11 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
12 ;;;
13 ;;; This file is part of GNU Guix.
14 ;;;
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
19 ;;;
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
24 ;;;
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28 (define-module (gnu packages base)
29 #:use-module ((guix licenses)
30 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
31 #:use-module (gnu packages)
32 #:use-module (gnu packages acl)
33 #:use-module (gnu packages bash)
34 #:use-module (gnu packages ed)
35 #:use-module (gnu packages guile)
36 #:use-module (gnu packages multiprecision)
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages perl)
39 #:use-module (gnu packages linux)
40 #:use-module (gnu packages texinfo)
41 #:use-module (gnu packages hurd)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages gettext)
44 #:use-module (guix utils)
45 #:use-module (guix packages)
46 #:use-module (guix download)
47 #:use-module (guix git-download)
48 #:use-module (guix build-system gnu)
49 #:use-module (guix build-system trivial)
50 #:use-module (ice-9 match)
51 #:export (glibc
52 libiconv-if-needed))
53
54 ;;; Commentary:
55 ;;;
56 ;;; Base packages of the Guix-based GNU user-land software distribution.
57 ;;;
58 ;;; Code:
59
60 (define-public hello
61 (package
62 (name "hello")
63 (version "2.10")
64 (source (origin
65 (method url-fetch)
66 (uri (string-append "mirror://gnu/hello/hello-" version
67 ".tar.gz"))
68 (sha256
69 (base32
70 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
71 (build-system gnu-build-system)
72 (synopsis "Hello, GNU world: An example GNU package")
73 (description
74 "GNU Hello prints the message \"Hello, world!\" and then exits. It
75 serves as an example of standard GNU coding practices. As such, it supports
76 command-line arguments, multiple languages, and so on.")
77 (home-page "https://www.gnu.org/software/hello/")
78 (license gpl3+)))
79
80 (define-public grep
81 (package
82 (name "grep")
83 (version "3.0")
84 (source (origin
85 (method url-fetch)
86 (uri (string-append "mirror://gnu/grep/grep-"
87 version ".tar.xz"))
88 (sha256
89 (base32
90 "1dcasjp3a578nrvzrcn38mpizb8w1q6mvfzhjmcqqgkf0nsivj72"))
91 (patches (search-patches "grep-timing-sensitive-test.patch"
92 "grep-gnulib-lock.patch"))))
93 (build-system gnu-build-system)
94 (native-inputs `(("perl" ,perl))) ;some of the tests require it
95 (arguments
96 `(#:phases
97 (modify-phases %standard-phases
98 (add-after 'install 'fix-egrep-and-fgrep
99 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
100 ;; absolute file name instead of searching for it in $PATH.
101 (lambda* (#:key outputs #:allow-other-keys)
102 (let* ((out (assoc-ref outputs "out"))
103 (bin (string-append out "/bin")))
104 (substitute* (list (string-append bin "/egrep")
105 (string-append bin "/fgrep"))
106 (("^exec grep")
107 (string-append "exec " bin "/grep")))
108 #t))))))
109 (synopsis "Print lines matching a pattern")
110 (description
111 "grep is a tool for finding text inside files. Text is found by
112 matching a pattern provided by the user in one or many files. The pattern
113 may be provided as a basic or extended regular expression, or as fixed
114 strings. By default, the matching text is simply printed to the screen,
115 however the output can be greatly customized to include, for example, line
116 numbers. GNU grep offers many extensions over the standard utility,
117 including, for example, recursive directory searching.")
118 (license gpl3+)
119 (home-page "https://www.gnu.org/software/grep/")))
120
121 (define-public sed
122 (package
123 (name "sed")
124 (version "4.4")
125 (source (origin
126 (method url-fetch)
127 (uri (string-append "mirror://gnu/sed/sed-" version
128 ".tar.xz"))
129 (sha256
130 (base32
131 "0fv88bcnraixc8jvpacvxshi30p5x9m7yb8ns1hfv07hmb2ypmnb"))))
132 (build-system gnu-build-system)
133 (synopsis "Stream editor")
134 (arguments
135 `(#:phases
136 (modify-phases %standard-phases
137 (add-after 'unpack 'dont-rebuild-sed.1
138 (lambda _
139 ;; Make sure we do not attempt to rebuild 'doc/sed.1', which does
140 ;; not work when cross-compiling because we cannot run 'sed'.
141 ;; This is fixed upstream as commit a0a25e3.
142 (substitute* "Makefile.in"
143 (("^doc/sed\\.1:.*")
144 "doc/sed.1:\n"))
145 #t))
146 (add-before 'patch-source-shebangs 'patch-test-suite
147 (lambda* (#:key inputs #:allow-other-keys)
148 (patch-makefile-SHELL "testsuite/Makefile.tests")
149 (substitute* '("testsuite/bsd.sh"
150 "testsuite/bug-regex9.c")
151 (("/bin/sh")
152 (which "sh")))
153 #t)))))
154 (description
155 "Sed is a non-interactive, text stream editor. It receives a text
156 input from a file or from standard input and it then applies a series of text
157 editing commands to the stream and prints its output to standard output. It
158 is often used for substituting text patterns in a stream. The GNU
159 implementation offers several extensions over the standard utility.")
160 (license gpl3+)
161 (home-page "https://www.gnu.org/software/sed/")))
162
163 (define-public tar
164 (package
165 (name "tar")
166 (version "1.29")
167 (source (origin
168 (method url-fetch)
169 (uri (string-append "mirror://gnu/tar/tar-"
170 version ".tar.xz"))
171 (sha256
172 (base32
173 "097hx7sbzp8qirl4m930lw84kn0wmxhmq7v1qpra3mrg0b8cyba0"))
174 (patches (search-patches "tar-CVE-2016-6321.patch"
175 "tar-skip-unreliable-tests.patch"))))
176 (build-system gnu-build-system)
177 ;; Note: test suite requires ~1GiB of disk space.
178 (arguments
179 '(#:phases (modify-phases %standard-phases
180 (add-before 'build 'set-shell-file-name
181 (lambda* (#:key inputs #:allow-other-keys)
182 ;; Do not use "/bin/sh" to run programs.
183 (let ((bash (assoc-ref inputs "bash")))
184 (substitute* "src/system.c"
185 (("/bin/sh")
186 (string-append bash "/bin/sh")))
187 #t))))))
188
189 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
190 ;; to refer to the target Bash.
191 (inputs (if (%current-target-system)
192 `(("bash" ,bash))
193 '()))
194
195 (synopsis "Managing tar archives")
196 (description
197 "Tar provides the ability to create tar archives, as well as the
198 ability to extract, update or list files in an existing archive. It is
199 useful for combining many files into one larger file, while maintaining
200 directory structure and file information such as permissions and
201 creation/modification dates. GNU tar offers many extensions over the
202 standard utility.")
203 (license gpl3+)
204 (home-page "https://www.gnu.org/software/tar/")))
205
206 (define-public patch
207 (package
208 (name "patch")
209 (version "2.7.5")
210 (source (origin
211 (method url-fetch)
212 (uri (string-append "mirror://gnu/patch/patch-"
213 version ".tar.xz"))
214 (sha256
215 (base32
216 "16d2r9kpivaak948mxzc0bai45mqfw73m113wrkmbffnalv1b5gx"))
217 (patches (search-patches "patch-hurd-path-max.patch"))))
218 (build-system gnu-build-system)
219 (native-inputs `(("ed" ,ed)))
220 (synopsis "Apply differences to originals, with optional backups")
221 (description
222 "Patch is a program that applies changes to files based on differences
223 laid out as by the program \"diff\". The changes may be applied to one or more
224 files depending on the contents of the diff file. It accepts several
225 different diff formats. It may also be used to revert previously applied
226 differences.")
227 (license gpl3+)
228 (home-page "https://savannah.gnu.org/projects/patch/")))
229
230 (define-public diffutils
231 (package
232 (name "diffutils")
233 (version "3.5")
234 (source (origin
235 (method url-fetch)
236 (uri (string-append "mirror://gnu/diffutils/diffutils-"
237 version ".tar.xz"))
238 (sha256
239 (base32
240 "0csmqfz8ks23kdjsq0v2ll1acqiz8lva06dj19mwmymrsp69ilys"))))
241 (build-system gnu-build-system)
242 (synopsis "Comparing and merging files")
243 (description
244 "GNU Diffutils is a package containing tools for finding the
245 differences between files. The \"diff\" command is used to show how two files
246 differ, while \"cmp\" shows the offsets and line numbers where they differ.
247 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
248 interactive means to merge two files.")
249 (license gpl3+)
250 (home-page "https://www.gnu.org/software/diffutils/")))
251
252 (define-public findutils
253 (package
254 (name "findutils")
255 (version "4.6.0")
256 (source (origin
257 (method url-fetch)
258 (uri (string-append "mirror://gnu/findutils/findutils-"
259 version ".tar.gz"))
260 (sha256
261 (base32
262 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
263 (patches (search-patches
264 "findutils-localstatedir.patch"
265 "findutils-test-xargs.patch"
266 ;; test-lock has performance issues on multi-core
267 ;; machines, it hangs or takes a long time to complete.
268 ;; This is a commit from gnulib to fix this issue.
269 "findutils-gnulib-multi-core.patch"))))
270 (build-system gnu-build-system)
271 (arguments
272 `(#:configure-flags (list
273 ;; Tell 'updatedb' to write to /var.
274 "--localstatedir=/var"
275
276 ;; Work around cross-compilation failure. See
277 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
278 ,@(if (%current-target-system)
279 '("gl_cv_func_wcwidth_works=yes")
280 '()))))
281 (synopsis "Operating on files matching given criteria")
282 (description
283 "Findutils supplies the basic file directory searching utilities of the
284 GNU system. It consists of two primary searching utilities: \"find\"
285 recursively searches for files in a directory according to given criteria and
286 \"locate\" lists files in a database that match a query. Two auxiliary tools
287 are included: \"updatedb\" updates the file name database and \"xargs\" may be
288 used to apply commands with arbitrarily long arguments.")
289 (license gpl3+)
290 (home-page "https://www.gnu.org/software/findutils/")))
291
292 (define-public coreutils
293 (package
294 (name "coreutils")
295 (version "8.27")
296 (source (origin
297 (method url-fetch)
298 (uri (string-append "mirror://gnu/coreutils/coreutils-"
299 version ".tar.xz"))
300 (sha256
301 (base32
302 "0sv547572iq8ayy8klir4hnngnx92a9nsazmf1wgzfc7xr4x74c8"))
303 (patches (search-patches "coreutils-cut-huge-range-test.patch"))))
304 (build-system gnu-build-system)
305 (inputs `(("acl" ,acl) ; TODO: add SELinux
306 ("gmp" ,gmp) ;bignums in 'expr', yay!
307
308 ;; Drop the dependency on libcap when cross-compiling since it's
309 ;; not quite cross-compilable.
310 ,@(if (%current-target-system)
311 '()
312 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
313 (native-inputs
314 ;; Perl is needed to run tests in native builds, and to run the bundled
315 ;; copy of help2man. However, don't pass it when cross-compiling since
316 ;; that would lead it to try to run programs to get their '--help' output
317 ;; for help2man.
318 (if (%current-target-system)
319 '()
320 `(("perl" ,perl))))
321 (outputs '("out" "debug"))
322 (arguments
323 `(#:parallel-build? #f ; help2man may be called too early
324 #:phases (alist-cons-before
325 'build 'patch-shell-references
326 (lambda* (#:key inputs #:allow-other-keys)
327 (let ((bash (assoc-ref inputs "bash")))
328 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
329 ;; that tests pass, since /bin/sh isn't in the chroot.
330 (setenv "SHELL" (which "sh"))
331
332 (substitute* (find-files "gnulib-tests" "\\.c$")
333 (("/bin/sh")
334 (format #f "~a/bin/sh" bash)))
335 (substitute* (find-files "tests" "\\.sh$")
336 (("#!/bin/sh")
337 (format #f "#!~a/bin/sh" bash)))))
338 %standard-phases)))
339 (synopsis "Core GNU utilities (file, text, shell)")
340 (description
341 "GNU Coreutils includes all of the basic command-line tools that are
342 expected in a POSIX system. These provide the basic file, shell and text
343 manipulation functions of the GNU system. Most of these tools offer extended
344 functionality beyond that which is outlined in the POSIX standard.")
345 (license gpl3+)
346 (home-page "https://www.gnu.org/software/coreutils/")))
347
348 (define-public coreutils-minimal
349 ;; Coreutils without its optional dependencies.
350 (package
351 (inherit coreutils)
352 (name "coreutils-minimal")
353 (outputs '("out"))
354 (inputs '())))
355
356 (define-public gnu-make
357 (package
358 (name "make")
359 (version "4.2.1")
360 (source (origin
361 (method url-fetch)
362 (uri (string-append "mirror://gnu/make/make-" version
363 ".tar.bz2"))
364 (sha256
365 (base32
366 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
367 (patches (search-patches "make-impure-dirs.patch"))))
368 (build-system gnu-build-system)
369 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
370 (inputs `(("guile" ,guile-2.0)))
371 (outputs '("out" "debug"))
372 (arguments
373 '(#:phases
374 (modify-phases %standard-phases
375 (add-before 'build 'set-default-shell
376 (lambda* (#:key inputs #:allow-other-keys)
377 ;; Change the default shell from /bin/sh.
378 (let ((bash (assoc-ref inputs "bash")))
379 (substitute* "job.c"
380 (("default_shell =.*$")
381 (format #f "default_shell = \"~a/bin/sh\";\n"
382 bash)))))))))
383 (synopsis "Remake files automatically")
384 (description
385 "Make is a program that is used to control the production of
386 executables or other files from their source files. The process is
387 controlled from a Makefile, in which the developer specifies how each file is
388 generated from its source. It has powerful dependency resolution and the
389 ability to determine when files have to be regenerated after their sources
390 change. GNU make offers many powerful extensions over the standard utility.")
391 (license gpl3+)
392 (home-page "https://www.gnu.org/software/make/")))
393
394 (define-public binutils
395 (package
396 (name "binutils")
397 (version "2.27")
398 (source (origin
399 (method url-fetch)
400 (uri (string-append "mirror://gnu/binutils/binutils-"
401 version ".tar.bz2"))
402 (sha256
403 (base32
404 "125clslv17xh1sab74343fg6v31msavpmaa1c1394zsqa773g5rn"))
405 (patches (search-patches "binutils-ld-new-dtags.patch"
406 "binutils-loongson-workaround.patch"
407 "binutils-mips-bash-bug.patch"))))
408 (build-system gnu-build-system)
409
410 ;; TODO: Add dependency on zlib + those for Gold.
411 (arguments
412 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
413 ;; on GCC when bootstrapping.
414 "LDFLAGS=-static-libgcc"
415
416 ;; Don't search under /usr/lib & co.
417 "--with-lib-path=/no-ld-lib-path"
418
419 ;; Glibc 2.17 has a "comparison of unsigned
420 ;; expression >= 0 is always true" in wchar.h.
421 "--disable-werror"
422
423 ;; Install BFD. It ends up in a hidden directory,
424 ;; but it's here.
425 "--enable-install-libbfd"
426
427 ;; Make sure 'ar' and 'ranlib' produce archives in a
428 ;; deterministic fashion.
429 "--enable-deterministic-archives")))
430
431 (synopsis "Binary utilities: bfd gas gprof ld")
432 (description
433 "GNU Binutils is a collection of tools for working with binary files.
434 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
435 Other tools include programs to display binary profiling information, list
436 the strings in a binary file, and utilities for working with archives. The
437 \"bfd\" library for working with executable and object formats is also
438 included.")
439 (license gpl3+)
440 (home-page "https://www.gnu.org/software/binutils/")))
441
442 (define* (make-ld-wrapper name #:key
443 (target (const #f))
444 binutils
445 (guile (canonical-package guile-2.0))
446 (bash (canonical-package bash))
447 (guile-for-build guile))
448 "Return a package called NAME that contains a wrapper for the 'ld' program
449 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
450 wrapper uses GUILE and BASH.
451
452 TARGET must be a one-argument procedure that, given a system type, returns a
453 cross-compilation target triplet or #f. When the result is not #f, make a
454 wrapper for the cross-linker for that target, called 'TARGET-ld'."
455 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
456 ;; its result can be delayed until the 'arguments' field is evaluated, thus
457 ;; in a context where '%current-system' is accurate.
458 (package
459 (name name)
460 (version "0")
461 (source #f)
462 (build-system trivial-build-system)
463 (inputs `(("binutils" ,binutils)
464 ("guile" ,guile)
465 ("bash" ,bash)
466 ("wrapper" ,(search-path %load-path
467 "gnu/packages/ld-wrapper.in"))))
468 (arguments
469 (let ((target (target (%current-system))))
470 `(#:guile ,guile-for-build
471 #:modules ((guix build utils))
472 #:builder (begin
473 (use-modules (guix build utils)
474 (system base compile))
475
476 (let* ((out (assoc-ref %outputs "out"))
477 (bin (string-append out "/bin"))
478 (ld ,(if target
479 `(string-append bin "/" ,target "-ld")
480 '(string-append bin "/ld")))
481 (go (string-append ld ".go")))
482
483 (setvbuf (current-output-port) _IOLBF)
484 (format #t "building ~s/bin/ld wrapper in ~s~%"
485 (assoc-ref %build-inputs "binutils")
486 out)
487
488 (mkdir-p bin)
489 (copy-file (assoc-ref %build-inputs "wrapper") ld)
490 (substitute* ld
491 (("@SELF@")
492 ld)
493 (("@GUILE@")
494 (string-append (assoc-ref %build-inputs "guile")
495 "/bin/guile"))
496 (("@BASH@")
497 (string-append (assoc-ref %build-inputs "bash")
498 "/bin/bash"))
499 (("@LD@")
500 (string-append (assoc-ref %build-inputs "binutils")
501 ,(if target
502 (string-append "/bin/"
503 target "-ld")
504 "/bin/ld"))))
505 (chmod ld #o555)
506 (compile-file ld #:output-file go))))))
507 (synopsis "The linker wrapper")
508 (description
509 "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
510 missing '-rpath' flags, and to detect any misuse of libraries outside of the
511 store.")
512 (home-page "https://www.gnu.org/software/guix//")
513 (license gpl3+)))
514
515 (export make-ld-wrapper)
516
517 (define-public glibc/linux
518 (package
519 (name "glibc")
520 (version "2.25")
521 (source (origin
522 (method url-fetch)
523 (uri (string-append "mirror://gnu/glibc/glibc-"
524 version ".tar.xz"))
525 (sha256
526 (base32
527 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
528 (snippet
529 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
530 ;; required on LFS distros to avoid loading the distro's libc.so
531 ;; instead of ours.
532 '(substitute* "sysdeps/unix/sysv/linux/configure"
533 (("use_ldconfig=yes")
534 "use_ldconfig=no")))
535 (modules '((guix build utils)))
536 (patches (search-patches "glibc-ldd-x86_64.patch"
537 "glibc-versioned-locpath.patch"
538 "glibc-o-largefile.patch"))))
539 (build-system gnu-build-system)
540
541 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
542 ;; users should automatically pull Linux headers as well.
543 (propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
544
545 (outputs '("out" "debug"))
546
547 (arguments
548 `(#:out-of-source? #t
549
550 ;; The libraries have an empty RUNPATH, but some, such as the versioned
551 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
552 ;; these libraries are always going to be found anyway, just skip
553 ;; RUNPATH checks.
554 #:validate-runpath? #f
555
556 #:configure-flags
557 (list "--enable-add-ons"
558 "--sysconfdir=/etc"
559
560 ;; Installing a locale archive with all the locales is to
561 ;; expensive (~100 MiB), so we rely on users to install the
562 ;; locales they really want.
563 ;;
564 ;; Set the default locale path. In practice, $LOCPATH may be
565 ;; defined to point whatever locales users want. However, setuid
566 ;; binaries don't honor $LOCPATH, so they'll instead look into
567 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
568 ;; with the idea that it is going to be populated by the sysadmin.
569 ;; The "X.Y" sub-directory is because locale data formats are
570 ;; incompatible across libc versions; see
571 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
572 ;;
573 ;; `--localedir' is not honored, so work around it.
574 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
575 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
576 ,version)
577
578 (string-append "--with-headers="
579 (assoc-ref ,(if (%current-target-system)
580 '%build-target-inputs
581 '%build-inputs)
582 "kernel-headers")
583 "/include")
584
585 ;; This is the default for most architectures as of GNU libc 2.21,
586 ;; but we specify it explicitly for clarity and consistency. See
587 ;; "kernel-features.h" in the GNU libc for details.
588 "--enable-kernel=2.6.32"
589
590 ;; Use our Bash instead of /bin/sh.
591 (string-append "BASH_SHELL="
592 (assoc-ref %build-inputs "bash")
593 "/bin/bash")
594
595 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
596 "libc_cv_ssp=no" "libc_cv_ssp_strong=no")
597
598 #:tests? #f ; XXX
599 #:phases (modify-phases %standard-phases
600 (add-before
601 'configure 'pre-configure
602 (lambda* (#:key inputs native-inputs outputs
603 #:allow-other-keys)
604 (let* ((out (assoc-ref outputs "out"))
605 (bin (string-append out "/bin"))
606 ;; FIXME: Normally we would look it up only in INPUTS
607 ;; but cross-base uses it as a native input.
608 (bash (or (assoc-ref inputs "static-bash")
609 (assoc-ref native-inputs "static-bash"))))
610 ;; Install the rpc data base file under `$out/etc/rpc'.
611 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
612 (substitute* "sunrpc/Makefile"
613 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
614 (string-append out "/etc/rpc" suffix "\n"))
615 (("^install-others =.*$")
616 (string-append "install-others = " out "/etc/rpc\n")))
617
618 (substitute* "Makeconfig"
619 ;; According to
620 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
621 ;; linking against libgcc_s is not needed with GCC
622 ;; 4.7.1.
623 ((" -lgcc_s") ""))
624
625 ;; Have `system' use that Bash.
626 (substitute* "sysdeps/posix/system.c"
627 (("#define[[:blank:]]+SHELL_PATH.*$")
628 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
629 bash)))
630
631 ;; Same for `popen'.
632 (substitute* "libio/iopopen.c"
633 (("/bin/sh")
634 (string-append bash "/bin/sh")))
635
636 ;; Same for the shell used by the 'exec' functions for
637 ;; scripts that lack a shebang.
638 (substitute* (find-files "." "^paths\\.h$")
639 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
640 (string-append "#define _PATH_BSHELL \""
641 bash "/bin/sh\"\n")))
642
643 ;; Nscd uses __DATE__ and __TIME__ to create a string to
644 ;; make sure the client and server come from the same
645 ;; libc. Use something deterministic instead.
646 (substitute* "nscd/nscd_stat.c"
647 (("static const char compilation\\[21\\] =.*$")
648 (string-append
649 "static const char compilation[21] = \""
650 (string-take (basename out) 20) "\";\n")))
651
652 ;; Make sure we don't retain a reference to the
653 ;; bootstrap Perl.
654 (substitute* "malloc/mtrace.pl"
655 (("^#!.*")
656 ;; The shebang can be omitted, because there's the
657 ;; "bilingual" eval/exec magic at the top of the file.
658 "")
659 (("exec @PERL@")
660 "exec perl"))))))))
661
662 (inputs `(("static-bash" ,static-bash)))
663
664 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
665 ;; install the message catalogs, with 'msgfmt'.
666 (native-inputs `(("texinfo" ,texinfo)
667 ("perl" ,perl)
668 ("gettext" ,gettext-minimal)))
669
670 (native-search-paths
671 ;; Search path for packages that provide locale data. This is useful
672 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
673 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
674 ;; distros.
675 (list (search-path-specification
676 (variable "GUIX_LOCPATH")
677 (files '("lib/locale")))))
678
679 (synopsis "The GNU C Library")
680 (description
681 "Any Unix-like operating system needs a C library: the library which
682 defines the \"system calls\" and other basic facilities such as open, malloc,
683 printf, exit...
684
685 The GNU C library is used as the C library in the GNU system and most systems
686 with the Linux kernel.")
687 (license lgpl2.0+)
688 (home-page "https://www.gnu.org/software/libc/")))
689
690 (define-public glibc/hurd
691 ;; The Hurd's libc variant.
692 (package (inherit glibc/linux)
693 (name "glibc-hurd")
694 (version "2.23")
695 (source (origin
696 (method url-fetch)
697 (uri (string-append "http://alpha.gnu.org/gnu/hurd/glibc-"
698 version "-hurd+libpthread-20161218" ".tar.gz"))
699 (sha256
700 (base32
701 "0vpdv05j6j3ria5bw8gp468i64gij94cslxkxj9xkfgi6p615b8p"))))
702
703 ;; Libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
704 ;; so both should be propagated.
705 (propagated-inputs `(("hurd-core-headers" ,hurd-core-headers)))
706 (native-inputs
707 `(,@(package-native-inputs glibc/linux)
708 ("mig" ,mig)
709 ("perl" ,perl)))
710
711 (arguments
712 (substitute-keyword-arguments (package-arguments glibc/linux)
713 ((#:phases original-phases)
714 ;; Add libmachuser.so and libhurduser.so to libc.so's search path.
715 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-07/msg00051.html>.
716 `(alist-cons-after
717 'install 'augment-libc.so
718 (lambda* (#:key outputs #:allow-other-keys)
719 (let* ((out (assoc-ref outputs "out")))
720 (substitute* (string-append out "/lib/libc.so")
721 (("/[^ ]+/lib/libc.so.0.3")
722 (string-append out "/lib/libc.so.0.3" " libmachuser.so" " libhurduser.so"))))
723 #t)
724 (alist-cons-after
725 'pre-configure 'pre-configure-set-pwd
726 (lambda _
727 ;; Use the right 'pwd'.
728 (substitute* "configure"
729 (("/bin/pwd") "pwd")))
730 (alist-replace
731 'build
732 (lambda _
733 ;; Force mach/hurd/libpthread subdirs to build first in order to avoid
734 ;; linking errors.
735 ;; See <https://lists.gnu.org/archive/html/bug-hurd/2016-11/msg00045.html>
736 (let ((-j (list "-j" (number->string (parallel-job-count)))))
737 (let-syntax ((make (syntax-rules ()
738 ((_ target)
739 (zero? (apply system* "make" target -j))))))
740 (and (make "mach/subdir_lib")
741 (make "hurd/subdir_lib")
742 (make "libpthread/subdir_lib")
743 (zero? (apply system* "make" -j))))))
744 ,original-phases))))
745 ((#:configure-flags original-configure-flags)
746 `(append (list "--host=i586-pc-gnu"
747
748 ;; We need this to get a working openpty() function.
749 "--enable-pt_chown"
750
751 ;; <https://lists.gnu.org/archive/html/bug-hurd/2016-10/msg00033.html>
752 "--disable-werror"
753
754 ;; nscd fails to build for GNU/Hurd:
755 ;; <https://lists.gnu.org/archive/html/bug-hurd/2014-07/msg00006.html>.
756 ;; Disable it.
757 "--disable-nscd")
758 (filter (lambda (flag)
759 (not (string-prefix? "--enable-kernel=" flag)))
760 ,original-configure-flags)))))
761 (synopsis "The GNU C Library (GNU Hurd variant)")
762 (supported-systems %hurd-systems)))
763
764 (define* (glibc-for-target #:optional
765 (target (or (%current-target-system)
766 (%current-system))))
767 "Return the glibc for TARGET, GLIBC/LINUX for a Linux host or
768 GLIBC/HURD for a Hurd host"
769 (match target
770 ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
771 (_ glibc/linux)))
772
773 (define-syntax glibc
774 (identifier-syntax (glibc-for-target)))
775
776 ;; Below are old libc versions, which we use mostly to build locale data in
777 ;; the old format (which the new libc cannot cope with.)
778
779 (define-public glibc-2.24
780 (package
781 (inherit glibc)
782 (version "2.24")
783 (source (origin
784 (inherit (package-source glibc))
785 (uri (string-append "mirror://gnu/glibc/glibc-"
786 version ".tar.xz"))
787 (sha256
788 (base32
789 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))))))
790
791 (define-public glibc-2.23
792 (package
793 (inherit glibc)
794 (version "2.23")
795 (source (origin
796 (inherit (package-source glibc))
797 (uri (string-append "mirror://gnu/glibc/glibc-"
798 version ".tar.xz"))
799 (sha256
800 (base32
801 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))))))
802
803 (define-public glibc-2.22
804 (package
805 (inherit glibc)
806 (version "2.22")
807 (source (origin
808 (inherit (package-source glibc))
809 (uri (string-append "mirror://gnu/glibc/glibc-"
810 version ".tar.xz"))
811 (sha256
812 (base32
813 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
814 (patches (search-patches "glibc-ldd-x86_64.patch"))))
815 (arguments
816 (substitute-keyword-arguments (package-arguments glibc)
817 ((#:phases phases)
818 `(modify-phases ,phases
819 (add-before 'configure 'fix-pwd
820 (lambda _
821 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.21
822 (substitute* "configure"
823 (("/bin/pwd") "pwd"))))))))))
824
825 (define-public glibc-2.21
826 (package
827 (inherit glibc-2.22)
828 (version "2.21")
829 (source (origin
830 (inherit (package-source glibc))
831 (uri (string-append "mirror://gnu/glibc/glibc-"
832 version ".tar.xz"))
833 (sha256
834 (base32
835 "1f135546j34s9bfkydmx2nhh9vwxlx60jldi80zmsnln6wj3dsxf"))
836 (patches (search-patches "glibc-ldd-x86_64.patch"))))))
837
838 (define-public glibc-locales
839 (package
840 (inherit glibc)
841 (name "glibc-locales")
842 (source (origin (inherit (package-source glibc))
843 (patches (cons (search-patch "glibc-locales.patch")
844 (origin-patches (package-source glibc))))))
845 (synopsis "All the locales supported by the GNU C Library")
846 (description
847 "This package provides all the locales supported by the GNU C Library,
848 more than 400 in total. To use them set the 'LOCPATH' environment variable to
849 the 'share/locale' sub-directory of this package.")
850 (outputs '("out")) ;110+ MiB
851 (native-search-paths '())
852 (arguments
853 (let ((args `(#:tests? #f #:strip-binaries? #f
854 ,@(package-arguments glibc))))
855 (substitute-keyword-arguments args
856 ((#:phases phases)
857 `(alist-replace
858 'build
859 (lambda* (#:key outputs #:allow-other-keys)
860 (zero? (system* "make" "localedata/install-locales"
861 "-j" (number->string (parallel-job-count)))))
862 (alist-delete 'install ,phases)))
863 ((#:configure-flags flags)
864 `(append ,flags
865 ;; Use $(libdir)/locale/X.Y as is the case by default.
866 (list (string-append "libc_cv_complocaledir="
867 (assoc-ref %outputs "out")
868 "/lib/locale/"
869 ,(package-version glibc))))))))))
870
871 (define-public glibc-utf8-locales
872 (package
873 (name "glibc-utf8-locales")
874 (version (package-version glibc))
875 (source #f)
876 (build-system trivial-build-system)
877 (arguments
878 `(#:modules ((guix build utils))
879 #:builder (begin
880 (use-modules (srfi srfi-1)
881 (guix build utils))
882
883 (let* ((libc (assoc-ref %build-inputs "glibc"))
884 (gzip (assoc-ref %build-inputs "gzip"))
885 (out (assoc-ref %outputs "out"))
886 (localedir (string-append out "/lib/locale/"
887 ,version)))
888 ;; 'localedef' needs 'gzip'.
889 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
890
891 (mkdir-p localedir)
892 (every (lambda (locale)
893 (define file
894 ;; Use the "normalized codeset" by
895 ;; default--e.g., "en_US.utf8".
896 (string-append localedir "/" locale ".utf8"))
897
898 (and (zero? (system* "localedef" "--no-archive"
899 "--prefix" localedir
900 "-i" locale
901 "-f" "UTF-8" file))
902 (begin
903 ;; For backward compatibility with Guix
904 ;; <= 0.8.3, add "xx_YY.UTF-8".
905 (symlink (string-append locale ".utf8")
906 (string-append localedir "/"
907 locale ".UTF-8"))
908 #t)))
909
910 ;; These are the locales commonly used for
911 ;; tests---e.g., in Guile's i18n tests.
912 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))))))
913 (inputs `(("glibc" ,glibc)
914 ("gzip" ,gzip)))
915 (synopsis "Small sample of UTF-8 locales")
916 (description
917 "This package provides a small sample of UTF-8 locales mostly useful in
918 test environments.")
919 (home-page (package-home-page glibc))
920 (license (package-license glibc))))
921
922 (define-public which
923 (package
924 (name "which")
925 (version "2.21")
926 (source (origin
927 (method url-fetch)
928 (uri (string-append "mirror://gnu/which/which-"
929 version ".tar.gz"))
930 (sha256
931 (base32
932 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
933 (build-system gnu-build-system)
934 (home-page "https://gnu.org/software/which/")
935 (synopsis "Find full path of shell commands")
936 (description
937 "The which program finds the location of executables in PATH, with a
938 variety of options. It is an alternative to the shell \"type\" built-in
939 command.")
940 (license gpl3+))) ; some files are under GPLv2+
941
942 (define-public glibc/hurd-headers
943 (package (inherit glibc/hurd)
944 (name "glibc-hurd-headers")
945 (outputs '("out"))
946 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
947 ("hurd-headers" ,hurd-headers)))
948 (arguments
949 (substitute-keyword-arguments (package-arguments glibc/hurd)
950 ;; We just pass the flags really needed to build the headers.
951 ((#:configure-flags _)
952 `(list "--enable-add-ons"
953 "--host=i586-pc-gnu"
954 "--enable-obsolete-rpc"))
955 ((#:phases _)
956 '(alist-replace
957 'install
958 (lambda* (#:key outputs #:allow-other-keys)
959 (and (zero? (system* "make" "install-headers"))
960
961 ;; Make an empty stubs.h to work around not being able to
962 ;; produce a valid stubs.h and causing the build to fail. See
963 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
964 (let ((out (assoc-ref outputs "out")))
965 (close-port
966 (open-output-file
967 (string-append out "/include/gnu/stubs.h"))))))
968
969 ;; Nothing to build.
970 (alist-delete
971 'build
972
973 (alist-cons-before
974 'configure 'pre-configure
975 (lambda _
976 ;; Use the right 'pwd'.
977 (substitute* "configure"
978 (("/bin/pwd") "pwd")))
979 %standard-phases))))))))
980
981 (define-public tzdata
982 (package
983 (name "tzdata")
984 (version "2017a")
985 (source (origin
986 (method url-fetch)
987 (uri (string-append
988 "https://www.iana.org/time-zones/repository/releases/tzdata"
989 version ".tar.gz"))
990 (sha256
991 (base32
992 "1mmv4rvcs12lrvgghw4fidczvb69yv69cmzknghcvw1c196mqfnz"))))
993 (build-system gnu-build-system)
994 (arguments
995 '(#:tests? #f
996 #:make-flags (let ((out (assoc-ref %outputs "out"))
997 (tmp (getenv "TMPDIR")))
998 (list (string-append "TOPDIR=" out)
999 (string-append "TZDIR=" out "/share/zoneinfo")
1000
1001 ;; Discard zic, dump, and tzselect, already
1002 ;; provided by glibc.
1003 (string-append "ETCDIR=" tmp "/etc")
1004
1005 ;; Likewise for the C library routines.
1006 (string-append "LIBDIR=" tmp "/lib")
1007 (string-append "MANDIR=" tmp "/man")
1008
1009 "AWK=awk"
1010 "CC=gcc"))
1011 #:modules ((guix build utils)
1012 (guix build gnu-build-system)
1013 (srfi srfi-1))
1014 #:phases
1015 (modify-phases %standard-phases
1016 (replace 'unpack
1017 (lambda* (#:key source inputs #:allow-other-keys)
1018 (and (zero? (system* "tar" "xvf" source))
1019 (zero? (system* "tar" "xvf" (assoc-ref inputs "tzcode"))))))
1020 (add-after 'install 'post-install
1021 (lambda* (#:key outputs #:allow-other-keys)
1022 ;; Move data in the right place.
1023 (let ((out (assoc-ref outputs "out")))
1024 (symlink (string-append out "/share/zoneinfo")
1025 (string-append out "/share/zoneinfo/posix"))
1026 (delete-file-recursively
1027 (string-append out "/share/zoneinfo-posix"))
1028 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1029 (string-append out "/share/zoneinfo/right"))
1030 (delete-file-recursively
1031 (string-append out "/share/zoneinfo-leaps")))))
1032 (delete 'configure))))
1033 (inputs `(("tzcode" ,(origin
1034 (method url-fetch)
1035 (uri (string-append
1036 "http://www.iana.org/time-zones/repository/releases/tzcode"
1037 version ".tar.gz"))
1038 (sha256
1039 (base32
1040 "1b1q7gnlsh5hjgs5065pvajd37rmbc3k9b8cgzad1vcrifswdwh2"))))))
1041 (home-page "https://www.iana.org/time-zones")
1042 (synopsis "Database of current and historical time zones")
1043 (description "The Time Zone Database (often called tz or zoneinfo)
1044 contains code and data that represent the history of local time for many
1045 representative locations around the globe. It is updated periodically to
1046 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1047 and daylight-saving rules.")
1048 (license public-domain)))
1049
1050 ;;; A "fixed" version of tzdata, which is used in the test suites of
1051 ;;; glib and R. We can update this whenever we are able to rebuild
1052 ;;; thousands of packages (for example, in a core-updates rebuild).
1053 (define-public tzdata-2017a
1054 (package
1055 (inherit tzdata)
1056 (version "2017a")
1057 (source
1058 (origin
1059 (method url-fetch)
1060 (uri (string-append "https://www.iana.org/time-zones/repository"
1061 "/releases/tzdata" version ".tar.gz"))
1062 (sha256
1063 (base32
1064 "1mmv4rvcs12lrvgghw4fidczvb69yv69cmzknghcvw1c196mqfnz"))))
1065 (inputs `(("tzcode" ,(origin
1066 (method url-fetch)
1067 (uri (string-append
1068 "http://www.iana.org/time-zones/repository/releases/tzcode"
1069 version ".tar.gz"))
1070 (sha256
1071 (base32
1072 "1b1q7gnlsh5hjgs5065pvajd37rmbc3k9b8cgzad1vcrifswdwh2"))))))))
1073
1074
1075 (define-public libiconv
1076 (package
1077 (name "libiconv")
1078 (version "1.15")
1079 (source (origin
1080 (method url-fetch)
1081 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1082 version ".tar.gz"))
1083 (sha256
1084 (base32
1085 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))))
1086 (build-system gnu-build-system)
1087 (synopsis "Character set conversion library")
1088 (description
1089 "libiconv provides an implementation of the iconv function for systems
1090 that lack it. iconv is used to convert between character encodings in a
1091 program. It supports a wide variety of different encodings.")
1092 (home-page "https://www.gnu.org/software/libiconv/")
1093 (license lgpl3+)))
1094
1095 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1096 "Return either a libiconv package specification to include in a dependency
1097 list for platforms that have an incomplete libc, or the empty list. If a
1098 package needs iconv ,@(libiconv-if-needed) should be added."
1099 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1100 ;; without iconv, such as MinGW, must return the then clause.
1101 (if (target-mingw? target)
1102 `(("libiconv" ,libiconv))
1103 '()))
1104
1105 (define-public (canonical-package package)
1106 ;; Avoid circular dependency by lazily resolving 'commencement'.
1107 (let* ((iface (resolve-interface '(gnu packages commencement)))
1108 (proc (module-ref iface 'canonical-package)))
1109 (proc package)))
1110
1111 (define-public (%final-inputs)
1112 "Return the list of \"final inputs\"."
1113 ;; Avoid circular dependency by lazily resolving 'commencement'.
1114 (let ((iface (resolve-interface '(gnu packages commencement))))
1115 (module-ref iface '%final-inputs)))
1116
1117 ;;; base.scm ends here