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