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