1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
5 ;;; Copyright © 2014, 2015, 2016, 2018 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
7 ;;; Copyright © 2014, 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
8 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
9 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
10 ;;; Copyright © 2016, 2018 Alex Vong <alexvong1995@gmail.com>
11 ;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
12 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
13 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
14 ;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
15 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
16 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
18 ;;; This file is part of GNU Guix.
20 ;;; GNU Guix is free software; you can redistribute it and/or modify it
21 ;;; under the terms of the GNU General Public License as published by
22 ;;; the Free Software Foundation; either version 3 of the License, or (at
23 ;;; your option) any later version.
25 ;;; GNU Guix is distributed in the hope that it will be useful, but
26 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
27 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 ;;; GNU General Public License for more details.
30 ;;; You should have received a copy of the GNU General Public License
31 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
33 (define-module (gnu packages base)
34 #:use-module ((guix licenses)
35 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
36 #:use-module (gnu packages)
37 #:use-module (gnu packages acl)
38 #:use-module (gnu packages bash)
39 #:use-module (gnu packages ed)
40 #:use-module (gnu packages guile)
41 #:use-module (gnu packages multiprecision)
42 #:use-module (gnu packages compression)
43 #:use-module (gnu packages perl)
44 #:use-module (gnu packages linux)
45 #:use-module (gnu packages pcre)
46 #:use-module (gnu packages texinfo)
47 #:use-module (gnu packages hurd)
48 #:use-module (gnu packages pkg-config)
49 #:use-module (gnu packages gettext)
50 #:use-module (guix utils)
51 #:use-module (guix packages)
52 #:use-module (guix download)
53 #:use-module (guix git-download)
54 #:use-module (guix build-system gnu)
55 #:use-module (guix build-system trivial)
56 #:use-module (ice-9 match)
62 ;;; Base packages of the Guix-based GNU user-land software distribution.
72 (uri (string-append "mirror://gnu/hello/hello-" version
76 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
77 (build-system gnu-build-system)
78 (synopsis "Hello, GNU world: An example GNU package")
80 "GNU Hello prints the message \"Hello, world!\" and then exits. It
81 serves as an example of standard GNU coding practices. As such, it supports
82 command-line arguments, multiple languages, and so on.")
83 (home-page "https://www.gnu.org/software/hello/")
92 (uri (string-append "mirror://gnu/grep/grep-"
96 "0zm0ywmyz9g8vn1plw14mn8kj74yipx5qsljndbyfgmvndx5qqnv"))
97 (patches (search-patches "grep-timing-sensitive-test.patch"))))
98 (build-system gnu-build-system)
99 (native-inputs `(("perl" ,perl))) ;some of the tests require it
100 (inputs `(("pcre" ,pcre)))
103 (modify-phases %standard-phases
104 (add-after 'install 'fix-egrep-and-fgrep
105 ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
106 ;; absolute file name instead of searching for it in $PATH.
107 (lambda* (#:key outputs #:allow-other-keys)
108 (let* ((out (assoc-ref outputs "out"))
109 (bin (string-append out "/bin")))
110 (substitute* (list (string-append bin "/egrep")
111 (string-append bin "/fgrep"))
113 (string-append "exec " bin "/grep")))
115 (synopsis "Print lines matching a pattern")
117 "grep is a tool for finding text inside files. Text is found by
118 matching a pattern provided by the user in one or many files. The pattern
119 may be provided as a basic or extended regular expression, or as fixed
120 strings. By default, the matching text is simply printed to the screen,
121 however the output can be greatly customized to include, for example, line
122 numbers. GNU grep offers many extensions over the standard utility,
123 including, for example, recursive directory searching.")
125 (home-page "https://www.gnu.org/software/grep/")))
133 (uri (string-append "mirror://gnu/sed/sed-" version
137 "0fv88bcnraixc8jvpacvxshi30p5x9m7yb8ns1hfv07hmb2ypmnb"))))
138 (build-system gnu-build-system)
139 (synopsis "Stream editor")
142 (modify-phases %standard-phases
143 (add-after 'unpack 'dont-rebuild-sed.1
145 ;; Make sure we do not attempt to rebuild 'doc/sed.1', which does
146 ;; not work when cross-compiling because we cannot run 'sed'.
147 ;; This is fixed upstream as commit a0a25e3.
148 (substitute* "Makefile.in"
152 (add-before 'patch-source-shebangs 'patch-test-suite
153 (lambda* (#:key inputs #:allow-other-keys)
154 (patch-makefile-SHELL "testsuite/Makefile.tests")
155 (substitute* '("testsuite/bsd.sh"
156 "testsuite/bug-regex9.c")
161 "Sed is a non-interactive, text stream editor. It receives a text
162 input from a file or from standard input and it then applies a series of text
163 editing commands to the stream and prints its output to standard output. It
164 is often used for substituting text patterns in a stream. The GNU
165 implementation offers several extensions over the standard utility.")
167 (home-page "https://www.gnu.org/software/sed/")))
175 (uri (string-append "mirror://gnu/tar/tar-"
179 "1lyjyk8z8hdddsxw0ikchrsfg3i0x3fsh7l63a8jgaz1n7dr5gzi"))
180 (patches (search-patches "tar-skip-unreliable-tests.patch"))))
181 (build-system gnu-build-system)
182 ;; Note: test suite requires ~1GiB of disk space.
184 '(#:phases (modify-phases %standard-phases
185 (add-before 'build 'set-shell-file-name
186 (lambda* (#:key inputs #:allow-other-keys)
187 ;; Do not use "/bin/sh" to run programs.
188 (let ((bash (assoc-ref inputs "bash")))
189 (substitute* "src/system.c"
191 (string-append bash "/bin/sh")))
194 ;; Test #92 "link mismatch" expects "a/z: Not linked to a/y" but gets
195 ;; "a/y: Not linked to a/z" and fails, presumably due to differences in
196 ;; the order in which 'diff' traverses directories. That leads to a
197 ;; test failure even though conceptually the test passes. Skip it.
198 #:make-flags '("TESTSUITEFLAGS=-k '!link mismatch'")))
200 ;; When cross-compiling, the 'set-shell-file-name' phase needs to be able
201 ;; to refer to the target Bash.
202 (inputs (if (%current-target-system)
206 (synopsis "Managing tar archives")
208 "Tar provides the ability to create tar archives, as well as the
209 ability to extract, update or list files in an existing archive. It is
210 useful for combining many files into one larger file, while maintaining
211 directory structure and file information such as permissions and
212 creation/modification dates. GNU tar offers many extensions over the
215 (home-page "https://www.gnu.org/software/tar/")))
223 (uri (string-append "mirror://gnu/patch/patch-"
227 "1zfqy4rdcy279vwn2z1kbv19dcfw25d2aqy9nzvdkq5bjzd0nqdc"))
228 (patches (search-patches "patch-hurd-path-max.patch"))))
229 (build-system gnu-build-system)
230 (native-inputs `(("ed" ,ed)))
231 (synopsis "Apply differences to originals, with optional backups")
233 "Patch is a program that applies changes to files based on differences
234 laid out as by the program \"diff\". The changes may be applied to one or more
235 files depending on the contents of the diff file. It accepts several
236 different diff formats. It may also be used to revert previously applied
239 (home-page "https://savannah.gnu.org/projects/patch/")))
241 (define-public diffutils
247 (uri (string-append "mirror://gnu/diffutils/diffutils-"
251 "1mivg0fy3a6fcn535ln8nkgfj6vxh5hsxxs5h6692wxmsjyyh8fn"))
252 (patches (search-patches "diffutils-getopt.patch"))))
253 (build-system gnu-build-system)
254 (synopsis "Comparing and merging files")
256 "GNU Diffutils is a package containing tools for finding the
257 differences between files. The \"diff\" command is used to show how two files
258 differ, while \"cmp\" shows the offsets and line numbers where they differ.
259 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
260 interactive means to merge two files.")
262 (home-page "https://www.gnu.org/software/diffutils/")))
264 (define-public findutils
270 (uri (string-append "mirror://gnu/findutils/findutils-"
274 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
275 (patches (search-patches
276 "findutils-localstatedir.patch"
277 "findutils-test-xargs.patch"))
278 (modules '((guix build utils)))
281 ;; The gnulib test-lock test is prone to writer starvation
282 ;; with our glibc@2.25, which prefers readers, so disable it.
283 ;; The gnulib commit b20e8afb0b2 should fix this once
284 ;; incorporated here.
285 (substitute* "tests/Makefile.in"
286 (("test-lock\\$\\(EXEEXT\\) ") ""))
288 (build-system gnu-build-system)
290 `(#:configure-flags (list
291 ;; Tell 'updatedb' to write to /var.
292 "--localstatedir=/var"
294 ;; Work around cross-compilation failure. See
295 ;; <http://savannah.gnu.org/bugs/?27299#comment1>.
296 ,@(if (%current-target-system)
297 '("gl_cv_func_wcwidth_works=yes")
299 (synopsis "Operating on files matching given criteria")
301 "Findutils supplies the basic file directory searching utilities of the
302 GNU system. It consists of two primary searching utilities: \"find\"
303 recursively searches for files in a directory according to given criteria and
304 \"locate\" lists files in a database that match a query. Two auxiliary tools
305 are included: \"updatedb\" updates the file name database and \"xargs\" may be
306 used to apply commands with arbitrarily long arguments.")
308 (home-page "https://www.gnu.org/software/findutils/")))
310 (define-public coreutils
316 (uri (string-append "mirror://gnu/coreutils/coreutils-"
320 "0plm1zs9il6bb5mk881qvbghq4glc8ybbgakk2lfzb0w64fgml4j"))))
321 (build-system gnu-build-system)
322 (inputs `(("acl" ,acl) ; TODO: add SELinux
323 ("gmp" ,gmp) ;bignums in 'expr', yay!
325 ;; Drop the dependency on libcap when cross-compiling since it's
326 ;; not quite cross-compilable.
327 ,@(if (%current-target-system)
329 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
331 ;; Perl is needed to run tests in native builds, and to run the bundled
332 ;; copy of help2man. However, don't pass it when cross-compiling since
333 ;; that would lead it to try to run programs to get their '--help' output
335 (if (%current-target-system)
338 (outputs '("out" "debug"))
340 `(#:parallel-build? #f ; help2man may be called too early
341 #:phases (modify-phases %standard-phases
342 (add-before 'build 'patch-shell-references
344 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
345 ;; that tests pass, since /bin/sh isn't in the chroot.
346 (setenv "SHELL" (which "sh"))
348 (substitute* (find-files "gnulib-tests" "\\.c$")
349 (("/bin/sh") (which "sh")))
350 (substitute* (find-files "tests" "\\.sh$")
351 (("#!/bin/sh") (which "sh")))
354 ;; Work around a cross-compilation bug whereby libcoreutils.a would
355 ;; provide '__mktime_internal', which conflicts with the one in libc.a.
356 ,@(if (%current-target-system)
357 `(#:configure-flags '("gl_cv_func_working_mktime=yes"))
359 (synopsis "Core GNU utilities (file, text, shell)")
361 "GNU Coreutils includes all of the basic command-line tools that are
362 expected in a POSIX system. These provide the basic file, shell and text
363 manipulation functions of the GNU system. Most of these tools offer extended
364 functionality beyond that which is outlined in the POSIX standard.")
366 (home-page "https://www.gnu.org/software/coreutils/")))
368 (define-public coreutils-minimal
369 ;; Coreutils without its optional dependencies.
372 (name "coreutils-minimal")
376 (define-public gnu-make
382 (uri (string-append "mirror://gnu/make/make-" version
386 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
387 (patches (search-patches "make-impure-dirs.patch"))))
388 (build-system gnu-build-system)
389 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
390 (inputs `(("guile" ,guile-2.0)))
391 (outputs '("out" "debug"))
394 (modify-phases %standard-phases
395 (add-before 'build 'set-default-shell
396 (lambda* (#:key inputs #:allow-other-keys)
397 ;; Change the default shell from /bin/sh.
398 (let ((bash (assoc-ref inputs "bash")))
400 (("default_shell =.*$")
401 (format #f "default_shell = \"~a/bin/sh\";\n"
403 (synopsis "Remake files automatically")
405 "Make is a program that is used to control the production of
406 executables or other files from their source files. The process is
407 controlled from a Makefile, in which the developer specifies how each file is
408 generated from its source. It has powerful dependency resolution and the
409 ability to determine when files have to be regenerated after their sources
410 change. GNU make offers many powerful extensions over the standard utility.")
412 (home-page "https://www.gnu.org/software/make/")))
414 (define-public binutils
420 (uri (string-append "mirror://gnu/binutils/binutils-"
424 "1sj234nd05cdgga1r36zalvvdkvpfbr12g5mir2n8i1dwsdrj939"))
425 (patches (search-patches "binutils-ld-new-dtags.patch"
426 "binutils-loongson-workaround.patch"))))
427 (build-system gnu-build-system)
429 ;; TODO: Add dependency on zlib + those for Gold.
431 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
432 ;; on GCC when bootstrapping.
433 "LDFLAGS=-static-libgcc"
435 ;; Don't search under /usr/lib & co.
436 "--with-lib-path=/no-ld-lib-path"
438 ;; Install BFD. It ends up in a hidden directory,
440 "--enable-install-libbfd"
442 ;; Make sure 'ar' and 'ranlib' produce archives in a
443 ;; deterministic fashion.
444 "--enable-deterministic-archives")))
446 (synopsis "Binary utilities: bfd gas gprof ld")
448 "GNU Binutils is a collection of tools for working with binary files.
449 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
450 Other tools include programs to display binary profiling information, list
451 the strings in a binary file, and utilities for working with archives. The
452 \"bfd\" library for working with executable and object formats is also
455 (home-page "https://www.gnu.org/software/binutils/")))
457 (define* (make-ld-wrapper name #:key
460 (guile (canonical-package guile-2.2))
461 (bash (canonical-package bash))
462 (guile-for-build guile))
463 "Return a package called NAME that contains a wrapper for the 'ld' program
464 of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
465 wrapper uses GUILE and BASH.
467 TARGET must be a one-argument procedure that, given a system type, returns a
468 cross-compilation target triplet or #f. When the result is not #f, make a
469 wrapper for the cross-linker for that target, called 'TARGET-ld'."
470 ;; Note: #:system->target-triplet is a procedure so that the evaluation of
471 ;; its result can be delayed until the 'arguments' field is evaluated, thus
472 ;; in a context where '%current-system' is accurate.
477 (build-system trivial-build-system)
478 (inputs `(("binutils" ,binutils)
481 ("wrapper" ,(search-path %load-path
482 "gnu/packages/ld-wrapper.in"))))
484 (let ((target (target (%current-system))))
485 `(#:guile ,guile-for-build
486 #:modules ((guix build utils))
488 (use-modules (guix build utils)
489 (system base compile))
491 (let* ((out (assoc-ref %outputs "out"))
492 (bin (string-append out "/bin"))
494 `(string-append bin "/" ,target "-ld")
495 '(string-append bin "/ld")))
496 (go (string-append ld ".go")))
498 (setvbuf (current-output-port) _IOLBF)
499 (format #t "building ~s/bin/ld wrapper in ~s~%"
500 (assoc-ref %build-inputs "binutils")
504 (copy-file (assoc-ref %build-inputs "wrapper") ld)
509 (string-append (assoc-ref %build-inputs "guile")
512 (string-append (assoc-ref %build-inputs "bash")
515 (string-append (assoc-ref %build-inputs "binutils")
517 (string-append "/bin/"
521 (compile-file ld #:output-file go))))))
522 (synopsis "The linker wrapper")
524 "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
525 missing '-rpath' flags, and to detect any misuse of libraries outside of the
527 (home-page "https://www.gnu.org/software/guix//")
530 (export make-ld-wrapper)
532 (define-public glibc/linux
535 ;; Glibc has stable branches that continuously pick fixes for each supported
536 ;; release. Unfortunately they do not do point-releases, so we are stuck
537 ;; with copying almost all patches, or use a snapshot of the release branch.
539 ;; This version number corresponds to the output of `git describe` and the
540 ;; archive can be generated by checking out the commit ID and running:
541 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
542 ;; See <https://bugs.gnu.org/29406> for details.
544 ;; Note: Always use a dot after the minor version since various places rely
545 ;; on "version-major+minor" to determine where locales are found.
546 (version "2.26.105-g0890d5379c")
549 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
550 "glibc-" (version-major+minor version) "-"
551 (caddr (string-split version #\.)) ".tar.xz"))
554 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
556 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
557 ;; required on LFS distros to avoid loading the distro's libc.so
560 (substitute* "sysdeps/unix/sysv/linux/configure"
561 (("use_ldconfig=yes")
564 (modules '((guix build utils)))
565 (patches (search-patches "glibc-ldd-x86_64.patch"
566 "glibc-versioned-locpath.patch"
567 "glibc-o-largefile.patch"
568 "glibc-allow-kernel-2.6.32.patch"))))
569 (build-system gnu-build-system)
571 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
572 ;; users should automatically pull Linux headers as well.
573 (propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
575 (outputs '("out" "debug"
576 "static")) ;9 MiB of .a files
579 `(#:out-of-source? #t
581 ;; The libraries have an empty RUNPATH, but some, such as the versioned
582 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
583 ;; these libraries are always going to be found anyway, just skip
585 #:validate-runpath? #f
587 #:modules ((ice-9 ftw)
590 (guix build gnu-build-system))
593 (list "--enable-add-ons"
596 ;; Installing a locale archive with all the locales is to
597 ;; expensive (~100 MiB), so we rely on users to install the
598 ;; locales they really want.
600 ;; Set the default locale path. In practice, $LOCPATH may be
601 ;; defined to point whatever locales users want. However, setuid
602 ;; binaries don't honor $LOCPATH, so they'll instead look into
603 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
604 ;; with the idea that it is going to be populated by the sysadmin.
605 ;; The "X.Y" sub-directory is because locale data formats are
606 ;; incompatible across libc versions; see
607 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
609 ;; `--localedir' is not honored, so work around it.
610 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
611 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
612 ,(version-major+minor version))
614 (string-append "--with-headers="
615 (assoc-ref ,(if (%current-target-system)
616 '%build-target-inputs
621 ;; This is the default for most architectures as of GNU libc 2.26,
622 ;; but we specify it explicitly for clarity and consistency. See
623 ;; "kernel-features.h" in the GNU libc for details.
624 "--enable-kernel=3.2.0"
626 ;; Use our Bash instead of /bin/sh.
627 (string-append "BASH_SHELL="
628 (assoc-ref %build-inputs "bash")
631 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
632 "libc_cv_ssp=no" "libc_cv_ssp_strong=no")
635 #:phases (modify-phases %standard-phases
637 'configure 'pre-configure
638 (lambda* (#:key inputs native-inputs outputs
640 (let* ((out (assoc-ref outputs "out"))
641 (bin (string-append out "/bin"))
642 ;; FIXME: Normally we would look it up only in INPUTS
643 ;; but cross-base uses it as a native input.
644 (bash (or (assoc-ref inputs "static-bash")
645 (assoc-ref native-inputs "static-bash"))))
646 ;; Install the rpc data base file under `$out/etc/rpc'.
647 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
648 (substitute* "sunrpc/Makefile"
649 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
650 (string-append out "/etc/rpc" suffix "\n"))
651 (("^install-others =.*$")
652 (string-append "install-others = " out "/etc/rpc\n")))
654 (substitute* "Makeconfig"
656 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
657 ;; linking against libgcc_s is not needed with GCC
661 ;; Have `system' use that Bash.
662 (substitute* "sysdeps/posix/system.c"
663 (("#define[[:blank:]]+SHELL_PATH.*$")
664 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
668 (substitute* "libio/iopopen.c"
670 (string-append bash "/bin/sh")))
672 ;; Same for the shell used by the 'exec' functions for
673 ;; scripts that lack a shebang.
674 (substitute* (find-files "." "^paths\\.h$")
675 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
676 (string-append "#define _PATH_BSHELL \""
677 bash "/bin/sh\"\n")))
679 ;; Nscd uses __DATE__ and __TIME__ to create a string to
680 ;; make sure the client and server come from the same
681 ;; libc. Use something deterministic instead.
682 (substitute* "nscd/nscd_stat.c"
683 (("static const char compilation\\[21\\] =.*$")
685 "static const char compilation[21] = \""
686 (string-take (basename out) 20) "\";\n")))
688 ;; Make sure we don't retain a reference to the
690 (substitute* "malloc/mtrace.pl"
692 ;; The shebang can be omitted, because there's the
693 ;; "bilingual" eval/exec magic at the top of the file.
698 (add-after 'install 'move-static-libs
699 (lambda* (#:key outputs #:allow-other-keys)
700 ;; Move static libraries to the "static" output.
701 (define (static-library? file)
702 ;; Return true if FILE is a static library. The
703 ;; "_nonshared.a" files are referred to by libc.so,
704 ;; libpthread.so, etc., which are in fact linker
706 (and (string-suffix? ".a" file)
707 (not (string-contains file "_nonshared"))))
709 (define (linker-script? file)
710 ;; Guess whether FILE, a ".a" file, is actually a
712 (and (not (ar-file? file))
713 (not (elf-file? file))))
715 (let* ((out (assoc-ref outputs "out"))
716 (lib (string-append out "/lib"))
717 (files (scandir lib static-library?))
718 (static (assoc-ref outputs "static"))
719 (slib (string-append static "/lib")))
721 (for-each (lambda (base)
722 (rename-file (string-append lib "/" base)
723 (string-append slib "/" base)))
726 ;; Usually libm.a is a linker script so we need to
727 ;; change the file names in there to refer to STATIC
729 (for-each (lambda (ld-script)
730 (substitute* ld-script
732 (filter linker-script?
733 (map (cut string-append slib "/" <>)
737 (inputs `(("static-bash" ,static-bash)))
739 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
740 ;; install the message catalogs, with 'msgfmt'.
741 (native-inputs `(("texinfo" ,texinfo)
743 ("gettext" ,gettext-minimal)))
746 ;; Search path for packages that provide locale data. This is useful
747 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
748 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
750 (list (search-path-specification
751 (variable "GUIX_LOCPATH")
752 (files '("lib/locale")))))
754 (synopsis "The GNU C Library")
756 "Any Unix-like operating system needs a C library: the library which
757 defines the \"system calls\" and other basic facilities such as open, malloc,
760 The GNU C library is used as the C library in the GNU system and most systems
761 with the Linux kernel.")
763 (home-page "https://www.gnu.org/software/libc/")))
765 (define-public glibc/hurd
766 ;; The Hurd's libc variant.
767 (package (inherit glibc/linux)
772 (uri (string-append "http://alpha.gnu.org/gnu/hurd/glibc-"
773 version "-hurd+libpthread-20161218" ".tar.gz"))
776 "0vpdv05j6j3ria5bw8gp468i64gij94cslxkxj9xkfgi6p615b8p"))))
778 ;; Libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
779 ;; so both should be propagated.
780 (propagated-inputs `(("hurd-core-headers" ,hurd-core-headers)))
782 `(,@(package-native-inputs glibc/linux)
787 (substitute-keyword-arguments (package-arguments glibc/linux)
788 ((#:phases original-phases)
789 ;; Add libmachuser.so and libhurduser.so to libc.so's search path.
790 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-07/msg00051.html>.
791 `(modify-phases ,original-phases
792 (add-after 'install 'augment-libc.so
793 (lambda* (#:key outputs #:allow-other-keys)
794 (let* ((out (assoc-ref outputs "out")))
795 (substitute* (string-append out "/lib/libc.so")
796 (("/[^ ]+/lib/libc.so.0.3")
797 (string-append out "/lib/libc.so.0.3" " libmachuser.so" " libhurduser.so"))))
799 (add-after 'pre-configure 'pre-configure-set-pwd
801 ;; Use the right 'pwd'.
802 (substitute* "configure"
803 (("/bin/pwd") "pwd"))
807 ;; Force mach/hurd/libpthread subdirs to build first in order to avoid
809 ;; See <https://lists.gnu.org/archive/html/bug-hurd/2016-11/msg00045.html>
810 (let ((flags (list "-j" (number->string (parallel-job-count)))))
811 (define (make target)
812 (apply invoke "make" target flags))
813 (make "mach/subdir_lib")
814 (make "hurd/subdir_lib")
815 (make "libpthread/subdir_lib")
816 (apply invoke "make" flags))))))
817 ((#:configure-flags original-configure-flags)
818 `(append (list "--host=i586-pc-gnu"
820 ;; We need this to get a working openpty() function.
823 ;; <https://lists.gnu.org/archive/html/bug-hurd/2016-10/msg00033.html>
826 ;; nscd fails to build for GNU/Hurd:
827 ;; <https://lists.gnu.org/archive/html/bug-hurd/2014-07/msg00006.html>.
830 (filter (lambda (flag)
831 (not (string-prefix? "--enable-kernel=" flag)))
832 ,original-configure-flags)))))
833 (synopsis "The GNU C Library (GNU Hurd variant)")
834 (supported-systems %hurd-systems)))
836 (define* (glibc-for-target #:optional
837 (target (or (%current-target-system)
839 "Return the glibc for TARGET, GLIBC/LINUX for a Linux host or
840 GLIBC/HURD for a Hurd host"
842 ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
846 (identifier-syntax (glibc-for-target)))
848 ;; Below are old libc versions, which we use mostly to build locale data in
849 ;; the old format (which the new libc cannot cope with.)
851 (define-public glibc-2.25
856 (inherit (package-source glibc))
857 (uri (string-append "mirror://gnu/glibc/glibc-"
861 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
862 (patches (search-patches "glibc-ldd-x86_64.patch"
863 "glibc-versioned-locpath.patch"
864 "glibc-o-largefile.patch"
865 "glibc-vectorized-strcspn-guards.patch"
866 "glibc-CVE-2017-1000366-pt1.patch"
867 "glibc-CVE-2017-1000366-pt2.patch"
868 "glibc-CVE-2017-1000366-pt3.patch"))))))
870 (define-public glibc-2.24
875 (inherit (package-source glibc))
876 (uri (string-append "mirror://gnu/glibc/glibc-"
880 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
881 (patches (search-patches "glibc-ldd-x86_64.patch"
882 "glibc-versioned-locpath.patch"
883 "glibc-o-largefile.patch"
884 "glibc-vectorized-strcspn-guards.patch"
885 "glibc-CVE-2015-5180.patch"
886 "glibc-CVE-2017-1000366-pt1.patch"
887 "glibc-CVE-2017-1000366-pt2.patch"
888 "glibc-CVE-2017-1000366-pt3.patch"))))))
890 (define-public glibc-2.23
895 (inherit (package-source glibc))
896 (uri (string-append "mirror://gnu/glibc/glibc-"
900 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
901 (patches (search-patches "glibc-ldd-x86_64.patch"
902 "glibc-versioned-locpath.patch"
903 "glibc-o-largefile.patch"
904 "glibc-vectorized-strcspn-guards.patch"
905 "glibc-CVE-2015-5180.patch"
906 "glibc-CVE-2016-3075.patch"
907 "glibc-CVE-2016-3706.patch"
908 "glibc-CVE-2016-4429.patch"
909 "glibc-CVE-2017-1000366-pt1.patch"
910 "glibc-CVE-2017-1000366-pt2.patch"
911 "glibc-CVE-2017-1000366-pt3.patch"))))))
913 (define-public glibc-2.22
918 (inherit (package-source glibc))
919 (uri (string-append "mirror://gnu/glibc/glibc-"
923 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
924 (patches (search-patches "glibc-ldd-x86_64.patch"
925 "glibc-vectorized-strcspn-guards.patch"
926 "glibc-CVE-2015-5180.patch"
927 "glibc-CVE-2015-7547.patch"
928 "glibc-CVE-2016-3075.patch"
929 "glibc-CVE-2016-3706.patch"
930 "glibc-CVE-2016-4429.patch"
931 "glibc-CVE-2017-1000366-pt1.patch"
932 "glibc-CVE-2017-1000366-pt2.patch"
933 "glibc-CVE-2017-1000366-pt3.patch"))))
935 (substitute-keyword-arguments (package-arguments glibc)
937 `(modify-phases ,phases
938 (add-before 'configure 'fix-pwd
940 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
941 (substitute* "configure"
942 (("/bin/pwd") "pwd"))
945 (define-public glibc-locales
948 (name "glibc-locales")
949 (source (origin (inherit (package-source glibc))
950 (patches (cons (search-patch "glibc-locales.patch")
951 (origin-patches (package-source glibc))))))
952 (synopsis "All the locales supported by the GNU C Library")
954 "This package provides all the locales supported by the GNU C Library,
955 more than 400 in total. To use them set the 'LOCPATH' environment variable to
956 the 'share/locale' sub-directory of this package.")
957 (outputs '("out")) ;110+ MiB
958 (native-search-paths '())
960 (let ((args `(#:tests? #f #:strip-binaries? #f
961 ,@(package-arguments glibc))))
962 (substitute-keyword-arguments args
964 `(modify-phases ,phases
967 (invoke "make" "localedata/install-locales"
968 "-j" (number->string (parallel-job-count)))))
970 (delete 'move-static-libs)))
971 ((#:configure-flags flags)
973 ;; Use $(libdir)/locale/X.Y as is the case by default.
974 (list (string-append "libc_cv_complocaledir="
975 (assoc-ref %outputs "out")
977 ,(version-major+minor
978 (package-version glibc)))))))))))
980 (define-public glibc-utf8-locales
982 (name "glibc-utf8-locales")
983 (version (package-version glibc))
985 (build-system trivial-build-system)
987 `(#:modules ((guix build utils))
989 (use-modules (guix build utils))
991 (let* ((libc (assoc-ref %build-inputs "glibc"))
992 (gzip (assoc-ref %build-inputs "gzip"))
993 (out (assoc-ref %outputs "out"))
994 (localedir (string-append out "/lib/locale/"
995 ,(version-major+minor version))))
996 ;; 'localedef' needs 'gzip'.
997 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
1000 (for-each (lambda (locale)
1002 ;; Use the "normalized codeset" by
1003 ;; default--e.g., "en_US.utf8".
1004 (string-append localedir "/" locale ".utf8"))
1006 (invoke "localedef" "--no-archive"
1007 "--prefix" localedir
1011 ;; For backward compatibility with Guix
1012 ;; <= 0.8.3, add "xx_YY.UTF-8".
1013 (symlink (string-append locale ".utf8")
1014 (string-append localedir "/"
1017 ;; These are the locales commonly used for
1018 ;; tests---e.g., in Guile's i18n tests.
1019 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
1021 (inputs `(("glibc" ,glibc)
1023 (synopsis "Small sample of UTF-8 locales")
1025 "This package provides a small sample of UTF-8 locales mostly useful in
1026 test environments.")
1027 (home-page (package-home-page glibc))
1028 (license (package-license glibc))))
1030 (define-public which
1036 (uri (string-append "mirror://gnu/which/which-"
1040 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
1041 (build-system gnu-build-system)
1042 (home-page "https://gnu.org/software/which/")
1043 (synopsis "Find full path of shell commands")
1045 "The which program finds the location of executables in PATH, with a
1046 variety of options. It is an alternative to the shell \"type\" built-in
1048 (license gpl3+))) ; some files are under GPLv2+
1050 (define-public glibc/hurd-headers
1051 (package (inherit glibc/hurd)
1052 (name "glibc-hurd-headers")
1054 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1055 ("hurd-headers" ,hurd-headers)))
1057 (substitute-keyword-arguments (package-arguments glibc/hurd)
1058 ;; We just pass the flags really needed to build the headers.
1059 ((#:configure-flags _)
1060 `(list "--enable-add-ons"
1061 "--host=i586-pc-gnu"
1062 "--enable-obsolete-rpc"))
1064 '(modify-phases %standard-phases
1066 (lambda* (#:key outputs #:allow-other-keys)
1067 (invoke "make" "install-headers")
1069 ;; Make an empty stubs.h to work around not being able to
1070 ;; produce a valid stubs.h and causing the build to fail. See
1071 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-04/msg00233.html>.
1072 (let ((out (assoc-ref outputs "out")))
1075 (string-append out "/include/gnu/stubs.h"))))))
1076 (delete 'build) ; nothing to build
1077 (add-before 'configure 'patch-configure-script
1079 ;; Use the right 'pwd'.
1080 (substitute* "configure"
1081 (("/bin/pwd") "pwd"))
1084 (define-public tzdata
1091 "https://www.iana.org/time-zones/repository/releases/tzdata"
1095 "02yrrfj0p7ar885ja41ylijzbr8wc6kz6kzlw8c670i9m693ym6n"))))
1096 (build-system gnu-build-system)
1099 #:make-flags (let ((out (assoc-ref %outputs "out"))
1100 (tmp (getenv "TMPDIR")))
1101 (list (string-append "TOPDIR=" out)
1102 (string-append "TZDIR=" out "/share/zoneinfo")
1104 ;; Discard zic, dump, and tzselect, already
1105 ;; provided by glibc.
1106 (string-append "ETCDIR=" tmp "/etc")
1108 ;; Likewise for the C library routines.
1109 (string-append "LIBDIR=" tmp "/lib")
1110 (string-append "MANDIR=" tmp "/man")
1114 #:modules ((guix build utils)
1115 (guix build gnu-build-system)
1118 (modify-phases %standard-phases
1120 (lambda* (#:key source inputs #:allow-other-keys)
1121 (invoke "tar" "xvf" source)
1122 (invoke "tar" "xvf" (assoc-ref inputs "tzcode"))))
1123 (add-after 'install 'post-install
1124 (lambda* (#:key outputs #:allow-other-keys)
1125 ;; Move data in the right place.
1126 (let ((out (assoc-ref outputs "out")))
1127 (symlink (string-append out "/share/zoneinfo")
1128 (string-append out "/share/zoneinfo/posix"))
1129 (delete-file-recursively
1130 (string-append out "/share/zoneinfo-posix"))
1131 (copy-recursively (string-append out "/share/zoneinfo-leaps")
1132 (string-append out "/share/zoneinfo/right"))
1133 (delete-file-recursively
1134 (string-append out "/share/zoneinfo-leaps"))
1136 (delete 'configure))))
1137 (inputs `(("tzcode" ,(origin
1140 "http://www.iana.org/time-zones/repository/releases/tzcode"
1144 "1dvrq0b2hz7cjqdyd7x21wpy4qcng3rvysr61ij0c2g64fyb9s41"))))))
1145 (home-page "https://www.iana.org/time-zones")
1146 (synopsis "Database of current and historical time zones")
1147 (description "The Time Zone Database (often called tz or zoneinfo)
1148 contains code and data that represent the history of local time for many
1149 representative locations around the globe. It is updated periodically to
1150 reflect changes made by political bodies to time zone boundaries, UTC offsets,
1151 and daylight-saving rules.")
1152 (license public-domain)))
1154 ;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1155 ;;; and a few other places. We can update this whenever we are able to rebuild
1156 ;;; thousands of packages (for example, in a core-updates rebuild). This package
1157 ;;; will typically be obsolete and should never be referred to by a built
1159 (define-public tzdata-for-tests
1160 (hidden-package (package (inherit tzdata)
1165 (uri (string-append "https://www.iana.org/time-zones/repository"
1166 "/releases/tzdata" version ".tar.gz"))
1169 "02yrrfj0p7ar885ja41ylijzbr8wc6kz6kzlw8c670i9m693ym6n"))))
1170 (inputs `(("tzcode" ,(origin
1173 "http://www.iana.org/time-zones/repository/releases/tzcode"
1177 "1dvrq0b2hz7cjqdyd7x21wpy4qcng3rvysr61ij0c2g64fyb9s41")))))))))
1180 (define-public libiconv
1186 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1190 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
1191 (modules '((guix build utils)))
1193 ;; Work around "declared gets" error on glibc systems (fixed by
1194 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1196 (substitute* "srclib/stdio.in.h"
1197 (("^#undef gets") "")
1198 (("^_GL_WARN_ON_USE \\(gets.*") ""))
1200 (build-system gnu-build-system)
1201 (synopsis "Character set conversion library")
1203 "libiconv provides an implementation of the iconv function for systems
1204 that lack it. iconv is used to convert between character encodings in a
1205 program. It supports a wide variety of different encodings.")
1206 (home-page "https://www.gnu.org/software/libiconv/")
1209 (define* (libiconv-if-needed #:optional (target (%current-target-system)))
1210 "Return either a libiconv package specification to include in a dependency
1211 list for platforms that have an incomplete libc, or the empty list. If a
1212 package needs iconv ,@(libiconv-if-needed) should be added."
1213 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1214 ;; without iconv, such as MinGW, must return the then clause.
1215 (if (target-mingw? target)
1216 `(("libiconv" ,libiconv))
1219 (define-public (canonical-package package)
1220 ;; Avoid circular dependency by lazily resolving 'commencement'.
1221 (let* ((iface (resolve-interface '(gnu packages commencement)))
1222 (proc (module-ref iface 'canonical-package)))
1225 (define-public (%final-inputs)
1226 "Return the list of \"final inputs\"."
1227 ;; Avoid circular dependency by lazily resolving 'commencement'.
1228 (let ((iface (resolve-interface '(gnu packages commencement))))
1229 (module-ref iface '%final-inputs)))
1231 ;;; base.scm ends here