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