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