gnu: ghc-7: Fix build with ncurses 6.1.
[jackhill/guix/guix.git] / gnu / packages / base.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
20bf5fce 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 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>
a55fbab7 8;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
7309045c 9;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
ad3c9f18 10;;; Copyright © 2016, 2018 Alex Vong <alexvong1995@gmail.com>
b81d11e5 11;;; Copyright © 2017 Rene Saavedra <rennes@openmailbox.org>
da8e256a 12;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
e162050d 13;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
acc2dab7 14;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
c04e5116 15;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
b672a816 16;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
e3ce5d70 17;;;
233e7676 18;;; This file is part of GNU Guix.
e3ce5d70 19;;;
233e7676 20;;; GNU Guix is free software; you can redistribute it and/or modify it
e3ce5d70
LC
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.
24;;;
233e7676 25;;; GNU Guix is distributed in the hope that it will be useful, but
e3ce5d70
LC
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.
29;;;
30;;; You should have received a copy of the GNU General Public License
233e7676 31;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
e3ce5d70 32
1ffa7090 33(define-module (gnu packages base)
c6d7e299 34 #:use-module ((guix licenses)
7309045c 35 #:select (gpl3+ lgpl2.0+ lgpl3+ public-domain))
59a43334 36 #:use-module (gnu packages)
1ffa7090
LC
37 #:use-module (gnu packages acl)
38 #:use-module (gnu packages bash)
b5ef82e0 39 #:use-module (gnu packages ed)
1ffa7090
LC
40 #:use-module (gnu packages guile)
41 #:use-module (gnu packages multiprecision)
c9505f3f 42 #:use-module (gnu packages compression)
1ffa7090
LC
43 #:use-module (gnu packages perl)
44 #:use-module (gnu packages linux)
20bf5fce 45 #:use-module (gnu packages pcre)
8fd6487e 46 #:use-module (gnu packages texinfo)
21a8fe1b 47 #:use-module (gnu packages hurd)
aa6b0d6b 48 #:use-module (gnu packages pkg-config)
a635ed5c 49 #:use-module (gnu packages gettext)
aee6180c 50 #:use-module (guix utils)
e3ce5d70 51 #:use-module (guix packages)
87f5d366 52 #:use-module (guix download)
21a8fe1b 53 #:use-module (guix git-download)
c9505f3f 54 #:use-module (guix build-system gnu)
b09617da
MR
55 #:use-module (guix build-system trivial)
56 #:use-module (ice-9 match)
4dab8c59
JN
57 #:export (glibc
58 libiconv-if-needed))
e3ce5d70
LC
59
60;;; Commentary:
61;;;
1722d680 62;;; Base packages of the Guix-based GNU user-land software distribution.
e3ce5d70
LC
63;;;
64;;; Code:
65
66(define-public hello
67 (package
17d8e33f
ML
68 (name "hello")
69 (version "2.10")
70 (source (origin
71 (method url-fetch)
72 (uri (string-append "mirror://gnu/hello/hello-" version
73 ".tar.gz"))
74 (sha256
75 (base32
76 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
77 (build-system gnu-build-system)
78 (synopsis "Hello, GNU world: An example GNU package")
79 (description
80 "GNU Hello prints the message \"Hello, world!\" and then exits. It
a22dc0c4
LC
81serves as an example of standard GNU coding practices. As such, it supports
82command-line arguments, multiple languages, and so on.")
6fd52309 83 (home-page "https://www.gnu.org/software/hello/")
17d8e33f 84 (license gpl3+)))
d7672884 85
6794b278
LC
86(define-public grep
87 (package
88 (name "grep")
63adf0fd 89 (version "3.1")
6794b278 90 (source (origin
87f5d366 91 (method url-fetch)
0db342a5 92 (uri (string-append "mirror://gnu/grep/grep-"
6794b278
LC
93 version ".tar.xz"))
94 (sha256
95 (base32
63adf0fd
EF
96 "0zm0ywmyz9g8vn1plw14mn8kj74yipx5qsljndbyfgmvndx5qqnv"))
97 (patches (search-patches "grep-timing-sensitive-test.patch"))))
6794b278 98 (build-system gnu-build-system)
304e4f51 99 (native-inputs `(("perl" ,perl))) ;some of the tests require it
20bf5fce 100 (inputs `(("pcre" ,pcre)))
1063d325
MW
101 (arguments
102 `(#:phases
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"))
112 (("^exec grep")
113 (string-append "exec " bin "/grep")))
114 #t))))))
f50d2669 115 (synopsis "Print lines matching a pattern")
d45122f5 116 (description
12bcf94a 117 "grep is a tool for finding text inside files. Text is found by
a22dc0c4 118matching a pattern provided by the user in one or many files. The pattern
79c311b8
LC
119may be provided as a basic or extended regular expression, or as fixed
120strings. By default, the matching text is simply printed to the screen,
121however the output can be greatly customized to include, for example, line
122numbers. GNU grep offers many extensions over the standard utility,
123including, for example, recursive directory searching.")
4a44e743 124 (license gpl3+)
6fd52309 125 (home-page "https://www.gnu.org/software/grep/")))
6794b278 126
8dcad9aa
LC
127(define-public sed
128 (package
129 (name "sed")
d6592d84 130 (version "4.4")
8dcad9aa 131 (source (origin
87f5d366 132 (method url-fetch)
0db342a5 133 (uri (string-append "mirror://gnu/sed/sed-" version
7d7ea947 134 ".tar.xz"))
8dcad9aa
LC
135 (sha256
136 (base32
d6592d84 137 "0fv88bcnraixc8jvpacvxshi30p5x9m7yb8ns1hfv07hmb2ypmnb"))))
8dcad9aa 138 (build-system gnu-build-system)
f50d2669 139 (synopsis "Stream editor")
52b8e5fc 140 (arguments
8a296947
LC
141 `(#:phases
142 (modify-phases %standard-phases
c8b44fc1
LC
143 (add-after 'unpack 'dont-rebuild-sed.1
144 (lambda _
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"
149 (("^doc/sed\\.1:.*")
150 "doc/sed.1:\n"))
151 #t))
8a296947
LC
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")
157 (("/bin/sh")
158 (which "sh")))
159 #t)))))
d45122f5 160 (description
a22dc0c4
LC
161 "Sed is a non-interactive, text stream editor. It receives a text
162input from a file or from standard input and it then applies a series of text
163editing commands to the stream and prints its output to standard output. It
79c311b8
LC
164is often used for substituting text patterns in a stream. The GNU
165implementation offers several extensions over the standard utility.")
4a44e743 166 (license gpl3+)
7d7ea947 167 (home-page "https://www.gnu.org/software/sed/")))
8dcad9aa 168
85240322
LC
169(define-public tar
170 (package
171 (name "tar")
ad3c9f18 172 (version "1.30")
85240322 173 (source (origin
87f5d366 174 (method url-fetch)
0db342a5 175 (uri (string-append "mirror://gnu/tar/tar-"
d6535cf1 176 version ".tar.xz"))
85240322
LC
177 (sha256
178 (base32
ad3c9f18
AV
179 "1lyjyk8z8hdddsxw0ikchrsfg3i0x3fsh7l63a8jgaz1n7dr5gzi"))
180 (patches (search-patches "tar-skip-unreliable-tests.patch"))))
85240322 181 (build-system gnu-build-system)
74d63739
LC
182 ;; Note: test suite requires ~1GiB of disk space.
183 (arguments
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"
190 (("/bin/sh")
191 (string-append bash "/bin/sh")))
ad2e1422
LC
192 #t))))
193
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'")))
bbe03294
LC
199
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)
203 `(("bash" ,bash))
204 '()))
205
f50d2669 206 (synopsis "Managing tar archives")
d45122f5 207 (description
a22dc0c4
LC
208 "Tar provides the ability to create tar archives, as well as the
209ability to extract, update or list files in an existing archive. It is
210useful for combining many files into one larger file, while maintaining
211directory structure and file information such as permissions and
79c311b8
LC
212creation/modification dates. GNU tar offers many extensions over the
213standard utility.")
4a44e743 214 (license gpl3+)
6fd52309 215 (home-page "https://www.gnu.org/software/tar/")))
85240322 216
fbeec3d9
LC
217(define-public patch
218 (package
219 (name "patch")
266d26df 220 (version "2.7.5")
f6408bc5
LC
221 (source (origin
222 (method url-fetch)
223 (uri (string-append "mirror://gnu/patch/patch-"
224 version ".tar.xz"))
225 (sha256
226 (base32
16cae799 227 "16d2r9kpivaak948mxzc0bai45mqfw73m113wrkmbffnalv1b5gx"))
fc1adab1 228 (patches (search-patches "patch-hurd-path-max.patch"))))
fbeec3d9 229 (build-system gnu-build-system)
b3546174 230 (native-inputs `(("ed" ,ed)))
f50d2669 231 (synopsis "Apply differences to originals, with optional backups")
d45122f5 232 (description
a22dc0c4 233 "Patch is a program that applies changes to files based on differences
79c311b8 234laid out as by the program \"diff\". The changes may be applied to one or more
a22dc0c4
LC
235files depending on the contents of the diff file. It accepts several
236different diff formats. It may also be used to revert previously applied
237differences.")
4a44e743 238 (license gpl3+)
6fd52309 239 (home-page "https://savannah.gnu.org/projects/patch/")))
fbeec3d9 240
04a32ee5
LC
241(define-public diffutils
242 (package
243 (name "diffutils")
03bcf7c3 244 (version "3.6")
04a32ee5 245 (source (origin
87f5d366 246 (method url-fetch)
0db342a5 247 (uri (string-append "mirror://gnu/diffutils/diffutils-"
04a32ee5
LC
248 version ".tar.xz"))
249 (sha256
250 (base32
8d6cd085
LC
251 "1mivg0fy3a6fcn535ln8nkgfj6vxh5hsxxs5h6692wxmsjyyh8fn"))
252 (patches (search-patches "diffutils-getopt.patch"))))
04a32ee5 253 (build-system gnu-build-system)
f50d2669 254 (synopsis "Comparing and merging files")
d45122f5 255 (description
79c311b8
LC
256 "GNU Diffutils is a package containing tools for finding the
257differences between files. The \"diff\" command is used to show how two files
e881752c 258differ, while \"cmp\" shows the offsets and line numbers where they differ.
79c311b8 259\"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
a22dc0c4 260interactive means to merge two files.")
4a44e743 261 (license gpl3+)
6fd52309 262 (home-page "https://www.gnu.org/software/diffutils/")))
04a32ee5 263
af5521ca
LC
264(define-public findutils
265 (package
266 (name "findutils")
e80d2555 267 (version "4.6.0")
af5521ca 268 (source (origin
87f5d366 269 (method url-fetch)
0db342a5 270 (uri (string-append "mirror://gnu/findutils/findutils-"
af5521ca
LC
271 version ".tar.gz"))
272 (sha256
273 (base32
e80d2555 274 "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y"))
da8e256a
MO
275 (patches (search-patches
276 "findutils-localstatedir.patch"
acc2dab7
EB
277 "findutils-test-xargs.patch"))
278 (modules '((guix build utils)))
279 (snippet
280 '(begin
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\\) ") ""))
287 #t))))
af5521ca 288 (build-system gnu-build-system)
af5521ca 289 (arguments
67dfa198
LC
290 `(#:configure-flags (list
291 ;; Tell 'updatedb' to write to /var.
292 "--localstatedir=/var"
293
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")
298 '()))))
f50d2669 299 (synopsis "Operating on files matching given criteria")
d45122f5 300 (description
a22dc0c4
LC
301 "Findutils supplies the basic file directory searching utilities of the
302GNU system. It consists of two primary searching utilities: \"find\"
303recursively 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
79c311b8
LC
305are included: \"updatedb\" updates the file name database and \"xargs\" may be
306used to apply commands with arbitrarily long arguments.")
4a44e743 307 (license gpl3+)
6fd52309 308 (home-page "https://www.gnu.org/software/findutils/")))
2c957cd2
LC
309
310(define-public coreutils
311 (package
312 (name "coreutils")
70144879 313 (version "8.29")
2c957cd2 314 (source (origin
87f5d366 315 (method url-fetch)
0db342a5 316 (uri (string-append "mirror://gnu/coreutils/coreutils-"
2c957cd2
LC
317 version ".tar.xz"))
318 (sha256
319 (base32
70144879 320 "0plm1zs9il6bb5mk881qvbghq4glc8ybbgakk2lfzb0w64fgml4j"))))
2c957cd2 321 (build-system gnu-build-system)
de59af4d 322 (inputs `(("acl" ,acl) ; TODO: add SELinux
09cc7729 323 ("gmp" ,gmp) ;bignums in 'expr', yay!
62ea8865
LC
324
325 ;; Drop the dependency on libcap when cross-compiling since it's
326 ;; not quite cross-compilable.
327 ,@(if (%current-target-system)
328 '()
329 `(("libcap" ,libcap))))) ;capability support is 'ls', etc.
2c1dea85
LC
330 (native-inputs
331 ;; Perl is needed to run tests in native builds, and to run the bundled
7f31c71c
LC
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
334 ;; for help2man.
1cbd63f2
LC
335 (if (%current-target-system)
336 '()
337 `(("perl" ,perl))))
9bf62d9b 338 (outputs '("out" "debug"))
2c957cd2 339 (arguments
8ba8aeb7 340 `(#:parallel-build? #f ; help2man may be called too early
656a5ba0
EF
341 #:phases (modify-phases %standard-phases
342 (add-before 'build 'patch-shell-references
343 (lambda _
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"))
b47b2b52 347
656a5ba0
EF
348 (substitute* (find-files "gnulib-tests" "\\.c$")
349 (("/bin/sh") (which "sh")))
350 (substitute* (find-files "tests" "\\.sh$")
351 (("#!/bin/sh") (which "sh")))
f3c294a2
LC
352 #t)))
353
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"))
358 '())))
f50d2669 359 (synopsis "Core GNU utilities (file, text, shell)")
d45122f5 360 (description
79c311b8 361 "GNU Coreutils includes all of the basic command-line tools that are
a22dc0c4
LC
362expected in a POSIX system. These provide the basic file, shell and text
363manipulation functions of the GNU system. Most of these tools offer extended
364functionality beyond that which is outlined in the POSIX standard.")
4a44e743 365 (license gpl3+)
6fd52309 366 (home-page "https://www.gnu.org/software/coreutils/")))
af5521ca 367
d0f74308 368(define-public coreutils-minimal
28cbc587
LC
369 ;; Coreutils without its optional dependencies.
370 (package
371 (inherit coreutils)
d0f74308 372 (name "coreutils-minimal")
28cbc587
LC
373 (outputs '("out"))
374 (inputs '())))
375
ab776865
LC
376(define-public gnu-make
377 (package
378 (name "make")
6d2b94f2 379 (version "4.2.1")
ab776865 380 (source (origin
87f5d366 381 (method url-fetch)
0db342a5 382 (uri (string-append "mirror://gnu/make/make-" version
ab776865
LC
383 ".tar.bz2"))
384 (sha256
385 (base32
6d2b94f2 386 "12f5zzyq2w56g95nni65hc0g5p7154033y2f3qmjvd016szn5qnn"))
fc1adab1 387 (patches (search-patches "make-impure-dirs.patch"))))
ab776865 388 (build-system gnu-build-system)
b3546174 389 (native-inputs `(("pkg-config" ,pkg-config))) ; to detect Guile
ed41d48e 390 (inputs `(("guile" ,guile-2.0)))
9bf62d9b 391 (outputs '("out" "debug"))
ea8fbbf2 392 (arguments
6cc83b68
EF
393 '(#:phases
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")))
399 (substitute* "job.c"
400 (("default_shell =.*$")
60f3ad8c 401 (format #f "default_shell = \"~a/bin/sh\";\n"
6cc83b68 402 bash)))))))))
f50d2669 403 (synopsis "Remake files automatically")
d45122f5 404 (description
a22dc0c4
LC
405 "Make is a program that is used to control the production of
406executables or other files from their source files. The process is
407controlled from a Makefile, in which the developer specifies how each file is
408generated from its source. It has powerful dependency resolution and the
409ability to determine when files have to be regenerated after their sources
79c311b8 410change. GNU make offers many powerful extensions over the standard utility.")
4a44e743 411 (license gpl3+)
6fd52309 412 (home-page "https://www.gnu.org/software/make/")))
ab776865 413
8f6201a3
LC
414(define-public binutils
415 (package
416 (name "binutils")
d31e7bad 417 (version "2.28.1")
8f6201a3 418 (source (origin
87f5d366 419 (method url-fetch)
0db342a5 420 (uri (string-append "mirror://gnu/binutils/binutils-"
8f6201a3
LC
421 version ".tar.bz2"))
422 (sha256
423 (base32
d31e7bad
EF
424 "1sj234nd05cdgga1r36zalvvdkvpfbr12g5mir2n8i1dwsdrj939"))
425 (patches (search-patches "binutils-ld-new-dtags.patch"
f0c6dda6 426 "binutils-loongson-workaround.patch"))))
8f6201a3
LC
427 (build-system gnu-build-system)
428
429 ;; TODO: Add dependency on zlib + those for Gold.
8f6201a3 430 (arguments
de80b504 431 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
01d45404
LC
432 ;; on GCC when bootstrapping.
433 "LDFLAGS=-static-libgcc"
8f6201a3 434
01d45404 435 ;; Don't search under /usr/lib & co.
444c64b0
LC
436 "--with-lib-path=/no-ld-lib-path"
437
6c95f363
LC
438 ;; Install BFD. It ends up in a hidden directory,
439 ;; but it's here.
cc0a1282
LC
440 "--enable-install-libbfd"
441
442 ;; Make sure 'ar' and 'ranlib' produce archives in a
443 ;; deterministic fashion.
444 "--enable-deterministic-archives")))
8f6201a3 445
f50d2669 446 (synopsis "Binary utilities: bfd gas gprof ld")
d45122f5 447 (description
a22dc0c4 448 "GNU Binutils is a collection of tools for working with binary files.
c5779c93
LC
449Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler.
450Other tools include programs to display binary profiling information, list
451the strings in a binary file, and utilities for working with archives. The
452\"bfd\" library for working with executable and object formats is also
453included.")
4a44e743 454 (license gpl3+)
6fd52309 455 (home-page "https://www.gnu.org/software/binutils/")))
8f6201a3 456
5bde4503
LC
457(define* (make-ld-wrapper name #:key
458 (target (const #f))
459 binutils
78dea6f1 460 (guile (canonical-package guile-2.2))
5bde4503 461 (bash (canonical-package bash))
8fdd4101
LC
462 (guile-for-build guile))
463 "Return a package called NAME that contains a wrapper for the 'ld' program
5bde4503
LC
464of BINUTILS, which adds '-rpath' flags to the actual 'ld' command line. The
465wrapper uses GUILE and BASH.
466
467TARGET must be a one-argument procedure that, given a system type, returns a
468cross-compilation target triplet or #f. When the result is not #f, make a
469wrapper 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.
8fdd4101
LC
473 (package
474 (name name)
475 (version "0")
476 (source #f)
477 (build-system trivial-build-system)
478 (inputs `(("binutils" ,binutils)
479 ("guile" ,guile)
480 ("bash" ,bash)
481 ("wrapper" ,(search-path %load-path
c8bfa5b4 482 "gnu/packages/ld-wrapper.in"))))
8fdd4101 483 (arguments
5bde4503
LC
484 (let ((target (target (%current-system))))
485 `(#:guile ,guile-for-build
486 #:modules ((guix build utils))
487 #:builder (begin
488 (use-modules (guix build utils)
489 (system base compile))
8fdd4101 490
5bde4503
LC
491 (let* ((out (assoc-ref %outputs "out"))
492 (bin (string-append out "/bin"))
493 (ld ,(if target
494 `(string-append bin "/" ,target "-ld")
495 '(string-append bin "/ld")))
496 (go (string-append ld ".go")))
8fdd4101 497
5bde4503
LC
498 (setvbuf (current-output-port) _IOLBF)
499 (format #t "building ~s/bin/ld wrapper in ~s~%"
500 (assoc-ref %build-inputs "binutils")
501 out)
8fdd4101 502
5bde4503
LC
503 (mkdir-p bin)
504 (copy-file (assoc-ref %build-inputs "wrapper") ld)
505 (substitute* ld
506 (("@SELF@")
507 ld)
508 (("@GUILE@")
509 (string-append (assoc-ref %build-inputs "guile")
510 "/bin/guile"))
511 (("@BASH@")
512 (string-append (assoc-ref %build-inputs "bash")
513 "/bin/bash"))
514 (("@LD@")
515 (string-append (assoc-ref %build-inputs "binutils")
516 ,(if target
517 (string-append "/bin/"
518 target "-ld")
519 "/bin/ld"))))
520 (chmod ld #o555)
521 (compile-file ld #:output-file go))))))
8fdd4101
LC
522 (synopsis "The linker wrapper")
523 (description
524 "The linker wrapper (or 'ld-wrapper') wraps the linker to add any
525missing '-rpath' flags, and to detect any misuse of libraries outside of the
526store.")
6fd52309 527 (home-page "https://www.gnu.org/software/guix//")
8fdd4101
LC
528 (license gpl3+)))
529
530(export make-ld-wrapper)
531
b09617da 532(define-public glibc/linux
7cdeac02
LC
533 (package
534 (name "glibc")
ee3ebf1a
MB
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.
538 ;;
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:
e3f9406b 541 ;; git archive --prefix=$(git describe)/ HEAD | xz > $(git describe).tar.xz
ee3ebf1a 542 ;; See <https://bugs.gnu.org/29406> for details.
c6bc8e22
MB
543 ;;
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.
e3f9406b 546 (version "2.26.105-g0890d5379c")
7cdeac02 547 (source (origin
87f5d366 548 (method url-fetch)
ee3ebf1a 549 (uri (string-append "https://alpha.gnu.org/gnu/guix/mirror/"
c6bc8e22
MB
550 "glibc-" (version-major+minor version) "-"
551 (caddr (string-split version #\.)) ".tar.xz"))
7cdeac02
LC
552 (sha256
553 (base32
e3f9406b 554 "1jck0c1i248sn02rvsfjykk77qncma34bjq89dyy2irwm50d7s3g"))
13990c73
LC
555 (snippet
556 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
557 ;; required on LFS distros to avoid loading the distro's libc.so
558 ;; instead of ours.
559 '(substitute* "sysdeps/unix/sysv/linux/configure"
560 (("use_ldconfig=yes")
561 "use_ldconfig=no")))
1faca892 562 (modules '((guix build utils)))
c3052d6b
ML
563 (patches (search-patches "glibc-ldd-x86_64.patch"
564 "glibc-versioned-locpath.patch"
8fdc843f
RW
565 "glibc-o-largefile.patch"
566 "glibc-allow-kernel-2.6.32.patch"))))
7cdeac02 567 (build-system gnu-build-system)
0a3da5b7
LC
568
569 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
570 ;; users should automatically pull Linux headers as well.
55de892b 571 (propagated-inputs `(("kernel-headers" ,linux-libre-headers)))
0a3da5b7 572
6dff905e
LC
573 (outputs '("out" "debug"
574 "static")) ;9 MiB of .a files
7f614e49 575
7cdeac02 576 (arguments
8197c978 577 `(#:out-of-source? #t
211db2f6 578
112da588 579 ;; The libraries have an empty RUNPATH, but some, such as the versioned
67fcf235 580 ;; libraries (libdl-2.24.so, etc.) have ld.so marked as NEEDED. Since
112da588
LC
581 ;; these libraries are always going to be found anyway, just skip
582 ;; RUNPATH checks.
583 #:validate-runpath? #f
584
6dff905e
LC
585 #:modules ((ice-9 ftw)
586 (srfi srfi-26)
587 (guix build utils)
588 (guix build gnu-build-system))
589
7cdeac02
LC
590 #:configure-flags
591 (list "--enable-add-ons"
592 "--sysconfdir=/etc"
7f614e49 593
97e11209
LC
594 ;; Installing a locale archive with all the locales is to
595 ;; expensive (~100 MiB), so we rely on users to install the
596 ;; locales they really want.
597 ;;
598 ;; Set the default locale path. In practice, $LOCPATH may be
599 ;; defined to point whatever locales users want. However, setuid
600 ;; binaries don't honor $LOCPATH, so they'll instead look into
9f58fe3d 601 ;; $libc_cv_complocaledir; we choose /run/current-system/locale/X.Y,
46bd6edd
LC
602 ;; with the idea that it is going to be populated by the sysadmin.
603 ;; The "X.Y" sub-directory is because locale data formats are
604 ;; incompatible across libc versions; see
605 ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
97e11209 606 ;;
7f614e49
LC
607 ;; `--localedir' is not honored, so work around it.
608 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
9f58fe3d 609 (string-append "libc_cv_complocaledir=/run/current-system/locale/"
c6bc8e22 610 ,(version-major+minor version))
7f614e49 611
7cdeac02 612 (string-append "--with-headers="
28dc10a4
LC
613 (assoc-ref ,(if (%current-target-system)
614 '%build-target-inputs
615 '%build-inputs)
aeafff53 616 "kernel-headers")
7cdeac02 617 "/include")
5f456680 618
67d527e3 619 ;; This is the default for most architectures as of GNU libc 2.26,
39ccbfad
MW
620 ;; but we specify it explicitly for clarity and consistency. See
621 ;; "kernel-features.h" in the GNU libc for details.
67d527e3 622 "--enable-kernel=3.2.0"
5f456680 623
6e32f6c0 624 ;; Use our Bash instead of /bin/sh.
8cd8e97c 625 (string-append "BASH_SHELL="
6e32f6c0 626 (assoc-ref %build-inputs "bash")
8cd8e97c
LC
627 "/bin/bash")
628
629 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
e37595d9 630 "libc_cv_ssp=no" "libc_cv_ssp_strong=no")
6e32f6c0 631
7cdeac02 632 #:tests? #f ; XXX
57f65bcc
LC
633 #:phases (modify-phases %standard-phases
634 (add-before
635 'configure 'pre-configure
636 (lambda* (#:key inputs native-inputs outputs
637 #:allow-other-keys)
638 (let* ((out (assoc-ref outputs "out"))
639 (bin (string-append out "/bin"))
640 ;; FIXME: Normally we would look it up only in INPUTS
641 ;; but cross-base uses it as a native input.
642 (bash (or (assoc-ref inputs "static-bash")
643 (assoc-ref native-inputs "static-bash"))))
57f65bcc
LC
644 ;; Install the rpc data base file under `$out/etc/rpc'.
645 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
646 (substitute* "sunrpc/Makefile"
647 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
648 (string-append out "/etc/rpc" suffix "\n"))
649 (("^install-others =.*$")
650 (string-append "install-others = " out "/etc/rpc\n")))
651
652 (substitute* "Makeconfig"
653 ;; According to
654 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
655 ;; linking against libgcc_s is not needed with GCC
656 ;; 4.7.1.
657 ((" -lgcc_s") ""))
658
659 ;; Have `system' use that Bash.
660 (substitute* "sysdeps/posix/system.c"
661 (("#define[[:blank:]]+SHELL_PATH.*$")
662 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
663 bash)))
664
665 ;; Same for `popen'.
666 (substitute* "libio/iopopen.c"
667 (("/bin/sh")
11b66876 668 (string-append bash "/bin/sh")))
57f65bcc 669
d56f8d5e
LC
670 ;; Same for the shell used by the 'exec' functions for
671 ;; scripts that lack a shebang.
672 (substitute* (find-files "." "^paths\\.h$")
673 (("#define[[:blank:]]+_PATH_BSHELL[[:blank:]].*$")
674 (string-append "#define _PATH_BSHELL \""
e4831391 675 bash "/bin/sh\"\n")))
d56f8d5e 676
c5b65f7e
LC
677 ;; Nscd uses __DATE__ and __TIME__ to create a string to
678 ;; make sure the client and server come from the same
679 ;; libc. Use something deterministic instead.
680 (substitute* "nscd/nscd_stat.c"
681 (("static const char compilation\\[21\\] =.*$")
682 (string-append
683 "static const char compilation[21] = \""
684 (string-take (basename out) 20) "\";\n")))
685
57f65bcc
LC
686 ;; Make sure we don't retain a reference to the
687 ;; bootstrap Perl.
688 (substitute* "malloc/mtrace.pl"
689 (("^#!.*")
690 ;; The shebang can be omitted, because there's the
691 ;; "bilingual" eval/exec magic at the top of the file.
692 "")
693 (("exec @PERL@")
6dff905e
LC
694 "exec perl")))))
695
696 (add-after 'install 'move-static-libs
697 (lambda* (#:key outputs #:allow-other-keys)
698 ;; Move static libraries to the "static" output.
699 (define (static-library? file)
700 ;; Return true if FILE is a static library. The
701 ;; "_nonshared.a" files are referred to by libc.so,
702 ;; libpthread.so, etc., which are in fact linker
703 ;; scripts.
704 (and (string-suffix? ".a" file)
705 (not (string-contains file "_nonshared"))))
706
707 (define (linker-script? file)
708 ;; Guess whether FILE, a ".a" file, is actually a
709 ;; linker script.
710 (and (not (ar-file? file))
711 (not (elf-file? file))))
712
713 (let* ((out (assoc-ref outputs "out"))
714 (lib (string-append out "/lib"))
715 (files (scandir lib static-library?))
716 (static (assoc-ref outputs "static"))
717 (slib (string-append static "/lib")))
718 (mkdir-p slib)
719 (for-each (lambda (base)
720 (rename-file (string-append lib "/" base)
721 (string-append slib "/" base)))
722 files)
723
724 ;; Usually libm.a is a linker script so we need to
725 ;; change the file names in there to refer to STATIC
726 ;; instead of OUT.
727 (for-each (lambda (ld-script)
728 (substitute* ld-script
729 ((out) static)))
730 (filter linker-script?
731 (map (cut string-append slib "/" <>)
732 files)))
733 #t))))))
7f614e49 734
90d891fc 735 (inputs `(("static-bash" ,static-bash)))
8fd6487e 736
6162b95d
LC
737 ;; To build the manual, we need Texinfo and Perl. Gettext is needed to
738 ;; install the message catalogs, with 'msgfmt'.
8fd6487e 739 (native-inputs `(("texinfo" ,texinfo)
6162b95d 740 ("perl" ,perl)
ff647c3d 741 ("gettext" ,gettext-minimal)))
8fd6487e 742
d6718df4
LC
743 (native-search-paths
744 ;; Search path for packages that provide locale data. This is useful
85e57214
LC
745 ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
746 ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
747 ;; distros.
d6718df4 748 (list (search-path-specification
fbb909ac 749 (variable "GUIX_LOCPATH")
f211b2af 750 (files '("lib/locale")))))
d6718df4 751
d45122f5
LC
752 (synopsis "The GNU C Library")
753 (description
7cdeac02
LC
754 "Any Unix-like operating system needs a C library: the library which
755defines the \"system calls\" and other basic facilities such as open, malloc,
756printf, exit...
757
758The GNU C library is used as the C library in the GNU system and most systems
759with the Linux kernel.")
4a44e743 760 (license lgpl2.0+)
6fd52309 761 (home-page "https://www.gnu.org/software/libc/")))
7cdeac02 762
b09617da
MR
763(define-public glibc/hurd
764 ;; The Hurd's libc variant.
765 (package (inherit glibc/linux)
766 (name "glibc-hurd")
1d9c8898 767 (version "2.23")
b09617da
MR
768 (source (origin
769 (method url-fetch)
770 (uri (string-append "http://alpha.gnu.org/gnu/hurd/glibc-"
1d9c8898 771 version "-hurd+libpthread-20161218" ".tar.gz"))
b09617da
MR
772 (sha256
773 (base32
1d9c8898 774 "0vpdv05j6j3ria5bw8gp468i64gij94cslxkxj9xkfgi6p615b8p"))))
b09617da
MR
775
776 ;; Libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
777 ;; so both should be propagated.
778 (propagated-inputs `(("hurd-core-headers" ,hurd-core-headers)))
779 (native-inputs
780 `(,@(package-native-inputs glibc/linux)
781 ("mig" ,mig)
782 ("perl" ,perl)))
783
784 (arguments
785 (substitute-keyword-arguments (package-arguments glibc/linux)
786 ((#:phases original-phases)
787 ;; Add libmachuser.so and libhurduser.so to libc.so's search path.
788 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-07/msg00051.html>.
711a0dce
RW
789 `(modify-phases ,original-phases
790 (add-after 'install 'augment-libc.so
791 (lambda* (#:key outputs #:allow-other-keys)
792 (let* ((out (assoc-ref outputs "out")))
793 (substitute* (string-append out "/lib/libc.so")
794 (("/[^ ]+/lib/libc.so.0.3")
795 (string-append out "/lib/libc.so.0.3" " libmachuser.so" " libhurduser.so"))))
796 #t))
797 (add-after 'pre-configure 'pre-configure-set-pwd
798 (lambda _
799 ;; Use the right 'pwd'.
800 (substitute* "configure"
801 (("/bin/pwd") "pwd"))
802 #t))
803 (replace 'build
804 (lambda _
805 ;; Force mach/hurd/libpthread subdirs to build first in order to avoid
806 ;; linking errors.
807 ;; See <https://lists.gnu.org/archive/html/bug-hurd/2016-11/msg00045.html>
808 (let ((-j (list "-j" (number->string (parallel-job-count)))))
809 (let-syntax ((make (syntax-rules ()
810 ((_ target)
811 (zero? (apply system* "make" target -j))))))
812 (and (make "mach/subdir_lib")
813 (make "hurd/subdir_lib")
814 (make "libpthread/subdir_lib")
815 (zero? (apply system* "make" -j)))))))))
b09617da
MR
816 ((#:configure-flags original-configure-flags)
817 `(append (list "--host=i586-pc-gnu"
818
819 ;; We need this to get a working openpty() function.
820 "--enable-pt_chown"
821
367f7013
MR
822 ;; <https://lists.gnu.org/archive/html/bug-hurd/2016-10/msg00033.html>
823 "--disable-werror"
824
b09617da
MR
825 ;; nscd fails to build for GNU/Hurd:
826 ;; <https://lists.gnu.org/archive/html/bug-hurd/2014-07/msg00006.html>.
827 ;; Disable it.
828 "--disable-nscd")
829 (filter (lambda (flag)
830 (not (string-prefix? "--enable-kernel=" flag)))
831 ,original-configure-flags)))))
832 (synopsis "The GNU C Library (GNU Hurd variant)")
833 (supported-systems %hurd-systems)))
834
835(define* (glibc-for-target #:optional
836 (target (or (%current-target-system)
837 (%current-system))))
838 "Return the glibc for TARGET, GLIBC/LINUX for a Linux host or
839GLIBC/HURD for a Hurd host"
840 (match target
841 ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
842 (_ glibc/linux)))
843
844(define-syntax glibc
845 (identifier-syntax (glibc-for-target)))
846
19ac2ba8
LC
847;; Below are old libc versions, which we use mostly to build locale data in
848;; the old format (which the new libc cannot cope with.)
849
67d527e3
MB
850(define-public glibc-2.25
851 (package
852 (inherit glibc)
853 (version "2.25")
854 (source (origin
855 (inherit (package-source glibc))
856 (uri (string-append "mirror://gnu/glibc/glibc-"
857 version ".tar.xz"))
858 (sha256
859 (base32
860 "1813dzkgw6v8q8q1m4v96yfis7vjqc9pslqib6j9mrwh6fxxjyq6"))
861 (patches (search-patches "glibc-ldd-x86_64.patch"
862 "glibc-versioned-locpath.patch"
863 "glibc-o-largefile.patch"
864 "glibc-vectorized-strcspn-guards.patch"
67d527e3
MB
865 "glibc-CVE-2017-1000366-pt1.patch"
866 "glibc-CVE-2017-1000366-pt2.patch"
867 "glibc-CVE-2017-1000366-pt3.patch"))))))
868
7ca72ec4
EF
869(define-public glibc-2.24
870 (package
871 (inherit glibc)
872 (version "2.24")
873 (source (origin
874 (inherit (package-source glibc))
875 (uri (string-append "mirror://gnu/glibc/glibc-"
876 version ".tar.xz"))
877 (sha256
878 (base32
665d6a59
EF
879 "1lxmprg9gm73gvafxd503x70z32phwjzcy74i0adfi6ixzla7m4r"))
880 (patches (search-patches "glibc-ldd-x86_64.patch"
881 "glibc-versioned-locpath.patch"
882 "glibc-o-largefile.patch"
ffc015be 883 "glibc-vectorized-strcspn-guards.patch"
575e5e4e 884 "glibc-CVE-2015-5180.patch"
665d6a59
EF
885 "glibc-CVE-2017-1000366-pt1.patch"
886 "glibc-CVE-2017-1000366-pt2.patch"
887 "glibc-CVE-2017-1000366-pt3.patch"))))))
7ca72ec4 888
19ac2ba8
LC
889(define-public glibc-2.23
890 (package
891 (inherit glibc)
892 (version "2.23")
893 (source (origin
894 (inherit (package-source glibc))
895 (uri (string-append "mirror://gnu/glibc/glibc-"
896 version ".tar.xz"))
897 (sha256
898 (base32
665d6a59
EF
899 "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))
900 (patches (search-patches "glibc-ldd-x86_64.patch"
901 "glibc-versioned-locpath.patch"
902 "glibc-o-largefile.patch"
ffc015be 903 "glibc-vectorized-strcspn-guards.patch"
a0ae64a3
EF
904 "glibc-CVE-2015-5180.patch"
905 "glibc-CVE-2016-3075.patch"
906 "glibc-CVE-2016-3706.patch"
907 "glibc-CVE-2016-4429.patch"
665d6a59
EF
908 "glibc-CVE-2017-1000366-pt1.patch"
909 "glibc-CVE-2017-1000366-pt2.patch"
910 "glibc-CVE-2017-1000366-pt3.patch"))))))
19ac2ba8 911
c2c54ebd 912(define-public glibc-2.22
455859a5 913 (package
0832787e 914 (inherit glibc)
c2c54ebd 915 (version "2.22")
137d957e
LC
916 (source (origin
917 (inherit (package-source glibc))
918 (uri (string-append "mirror://gnu/glibc/glibc-"
919 version ".tar.xz"))
920 (sha256
921 (base32
c2c54ebd 922 "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
665d6a59 923 (patches (search-patches "glibc-ldd-x86_64.patch"
ffc015be 924 "glibc-vectorized-strcspn-guards.patch"
edd08fb7
EF
925 "glibc-CVE-2015-5180.patch"
926 "glibc-CVE-2015-7547.patch"
927 "glibc-CVE-2016-3075.patch"
928 "glibc-CVE-2016-3706.patch"
929 "glibc-CVE-2016-4429.patch"
665d6a59
EF
930 "glibc-CVE-2017-1000366-pt1.patch"
931 "glibc-CVE-2017-1000366-pt2.patch"
932 "glibc-CVE-2017-1000366-pt3.patch"))))
38e9373b
EF
933 (arguments
934 (substitute-keyword-arguments (package-arguments glibc)
935 ((#:phases phases)
936 `(modify-phases ,phases
937 (add-before 'configure 'fix-pwd
938 (lambda _
6d833b13 939 ;; Use `pwd' instead of `/bin/pwd' for glibc-2.22.
38e9373b 940 (substitute* "configure"
56ed97c8
MW
941 (("/bin/pwd") "pwd"))
942 #t))))))))
137d957e 943
aee6180c
LC
944(define-public glibc-locales
945 (package
946 (inherit glibc)
947 (name "glibc-locales")
948 (source (origin (inherit (package-source glibc))
949 (patches (cons (search-patch "glibc-locales.patch")
950 (origin-patches (package-source glibc))))))
951 (synopsis "All the locales supported by the GNU C Library")
952 (description
953 "This package provides all the locales supported by the GNU C Library,
954more than 400 in total. To use them set the 'LOCPATH' environment variable to
955the 'share/locale' sub-directory of this package.")
956 (outputs '("out")) ;110+ MiB
605217be 957 (native-search-paths '())
aee6180c
LC
958 (arguments
959 (let ((args `(#:tests? #f #:strip-binaries? #f
960 ,@(package-arguments glibc))))
961 (substitute-keyword-arguments args
962 ((#:phases phases)
2320d4f0
EF
963 `(modify-phases ,phases
964 (replace 'build
965 (lambda _
966 (zero? (system* "make" "localedata/install-locales"
967 "-j" (number->string (parallel-job-count))))))
2bbd674b
MB
968 (delete 'install)
969 (delete 'move-static-libs)))
aee6180c
LC
970 ((#:configure-flags flags)
971 `(append ,flags
85e57214 972 ;; Use $(libdir)/locale/X.Y as is the case by default.
85860fdf 973 (list (string-append "libc_cv_complocaledir="
aee6180c 974 (assoc-ref %outputs "out")
f2d7bbb5 975 "/lib/locale/"
c6bc8e22
MB
976 ,(version-major+minor
977 (package-version glibc)))))))))))
aee6180c 978
c9505f3f
LC
979(define-public glibc-utf8-locales
980 (package
981 (name "glibc-utf8-locales")
982 (version (package-version glibc))
983 (source #f)
984 (build-system trivial-build-system)
985 (arguments
f2d7bbb5 986 `(#:modules ((guix build utils))
c9505f3f
LC
987 #:builder (begin
988 (use-modules (srfi srfi-1)
989 (guix build utils))
990
991 (let* ((libc (assoc-ref %build-inputs "glibc"))
992 (gzip (assoc-ref %build-inputs "gzip"))
993 (out (assoc-ref %outputs "out"))
f2d7bbb5 994 (localedir (string-append out "/lib/locale/"
c6bc8e22 995 ,(version-major+minor version))))
c9505f3f
LC
996 ;; 'localedef' needs 'gzip'.
997 (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
998
999 (mkdir-p localedir)
1000 (every (lambda (locale)
8a55e217
LC
1001 (define file
1002 ;; Use the "normalized codeset" by
1003 ;; default--e.g., "en_US.utf8".
1004 (string-append localedir "/" locale ".utf8"))
1005
1006 (and (zero? (system* "localedef" "--no-archive"
1007 "--prefix" localedir
1008 "-i" locale
1009 "-f" "UTF-8" file))
1010 (begin
1011 ;; For backward compatibility with Guix
1012 ;; <= 0.8.3, add "xx_YY.UTF-8".
1013 (symlink (string-append locale ".utf8")
c9505f3f 1014 (string-append localedir "/"
8a55e217
LC
1015 locale ".UTF-8"))
1016 #t)))
c9505f3f
LC
1017
1018 ;; These are the locales commonly used for
1019 ;; tests---e.g., in Guile's i18n tests.
1020 '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))))))
1021 (inputs `(("glibc" ,glibc)
1022 ("gzip" ,gzip)))
1023 (synopsis "Small sample of UTF-8 locales")
1024 (description
1025 "This package provides a small sample of UTF-8 locales mostly useful in
1026test environments.")
1027 (home-page (package-home-page glibc))
1028 (license (package-license glibc))))
aee6180c 1029
ce0614dd
LC
1030(define-public which
1031 (package
1032 (name "which")
70ca2e94 1033 (version "2.21")
ce0614dd
LC
1034 (source (origin
1035 (method url-fetch)
1036 (uri (string-append "mirror://gnu/which/which-"
1037 version ".tar.gz"))
1038 (sha256
1039 (base32
70ca2e94 1040 "1bgafvy3ypbhhfznwjv1lxmd6mci3x1byilnnkc7gcr486wlb8pl"))))
ce0614dd
LC
1041 (build-system gnu-build-system)
1042 (home-page "https://gnu.org/software/which/")
1043 (synopsis "Find full path of shell commands")
1044 (description
1045 "The which program finds the location of executables in PATH, with a
1046variety of options. It is an alternative to the shell \"type\" built-in
1047command.")
1048 (license gpl3+))) ; some files are under GPLv2+
1049
21a8fe1b
MR
1050(define-public glibc/hurd-headers
1051 (package (inherit glibc/hurd)
1052 (name "glibc-hurd-headers")
1053 (outputs '("out"))
1054 (propagated-inputs `(("gnumach-headers" ,gnumach-headers)
1055 ("hurd-headers" ,hurd-headers)))
1056 (arguments
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"
aa81eb73 1061 "--host=i586-pc-gnu"
21a8fe1b
MR
1062 "--enable-obsolete-rpc"))
1063 ((#:phases _)
c04e5116
TGR
1064 '(modify-phases %standard-phases
1065 (replace 'install
1066 (lambda* (#:key outputs #:allow-other-keys)
1067 (invoke "make" "install-headers")
1068
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")))
1073 (close-port
1074 (open-output-file
1075 (string-append out "/include/gnu/stubs.h"))))))
1076 (delete 'build) ; nothing to build
1077 (add-before 'configure 'patch-configure-script
1078 (lambda _
1079 ;; Use the right 'pwd'.
1080 (substitute* "configure"
1081 (("/bin/pwd") "pwd"))
1082 #t))))))))
21a8fe1b 1083
e789d9a8
LC
1084(define-public tzdata
1085 (package
1086 (name "tzdata")
232ffa84 1087 (version "2017c")
e789d9a8
LC
1088 (source (origin
1089 (method url-fetch)
1090 (uri (string-append
80b63e67 1091 "https://www.iana.org/time-zones/repository/releases/tzdata"
e789d9a8
LC
1092 version ".tar.gz"))
1093 (sha256
1094 (base32
232ffa84 1095 "02yrrfj0p7ar885ja41ylijzbr8wc6kz6kzlw8c670i9m693ym6n"))))
e789d9a8
LC
1096 (build-system gnu-build-system)
1097 (arguments
1098 '(#:tests? #f
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")
1103
1104 ;; Discard zic, dump, and tzselect, already
1105 ;; provided by glibc.
1106 (string-append "ETCDIR=" tmp "/etc")
1107
1108 ;; Likewise for the C library routines.
1109 (string-append "LIBDIR=" tmp "/lib")
1110 (string-append "MANDIR=" tmp "/man")
1111
1112 "AWK=awk"
1113 "CC=gcc"))
1114 #:modules ((guix build utils)
1115 (guix build gnu-build-system)
1116 (srfi srfi-1))
1117 #:phases
c8f35458
JD
1118 (modify-phases %standard-phases
1119 (replace 'unpack
1120 (lambda* (#:key source inputs #:allow-other-keys)
1121 (and (zero? (system* "tar" "xvf" source))
1122 (zero? (system* "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")))))
1135 (delete 'configure))))
e789d9a8
LC
1136 (inputs `(("tzcode" ,(origin
1137 (method url-fetch)
1138 (uri (string-append
1139 "http://www.iana.org/time-zones/repository/releases/tzcode"
1140 version ".tar.gz"))
1141 (sha256
1142 (base32
232ffa84 1143 "1dvrq0b2hz7cjqdyd7x21wpy4qcng3rvysr61ij0c2g64fyb9s41"))))))
80b63e67 1144 (home-page "https://www.iana.org/time-zones")
e789d9a8
LC
1145 (synopsis "Database of current and historical time zones")
1146 (description "The Time Zone Database (often called tz or zoneinfo)
1147contains code and data that represent the history of local time for many
35b9e423 1148representative locations around the globe. It is updated periodically to
e789d9a8
LC
1149reflect changes made by political bodies to time zone boundaries, UTC offsets,
1150and daylight-saving rules.")
1151 (license public-domain)))
1152
75aea16f
LF
1153;;; A "fixed" version of tzdata, which is used in the test suites of glib and R
1154;;; and a few other places. We can update this whenever we are able to rebuild
1155;;; thousands of packages (for example, in a core-updates rebuild). This package
1156;;; will typically be obsolete and should never be referred to by a built
1157;;; package.
f9c3bd2e 1158(define-public tzdata-for-tests
75aea16f
LF
1159 (hidden-package (package (inherit tzdata)
1160 (version "2017c")
3ffaec13
LF
1161 (source
1162 (origin
1163 (method url-fetch)
1164 (uri (string-append "https://www.iana.org/time-zones/repository"
1165 "/releases/tzdata" version ".tar.gz"))
1166 (sha256
1167 (base32
75aea16f 1168 "02yrrfj0p7ar885ja41ylijzbr8wc6kz6kzlw8c670i9m693ym6n"))))
3ffaec13
LF
1169 (inputs `(("tzcode" ,(origin
1170 (method url-fetch)
1171 (uri (string-append
1172 "http://www.iana.org/time-zones/repository/releases/tzcode"
1173 version ".tar.gz"))
1174 (sha256
1175 (base32
75aea16f 1176 "1dvrq0b2hz7cjqdyd7x21wpy4qcng3rvysr61ij0c2g64fyb9s41")))))))))
3ffaec13
LF
1177
1178
7309045c
JN
1179(define-public libiconv
1180 (package
1181 (name "libiconv")
a55fbab7 1182 (version "1.15")
7309045c
JN
1183 (source (origin
1184 (method url-fetch)
1185 (uri (string-append "mirror://gnu/libiconv/libiconv-"
1186 version ".tar.gz"))
1187 (sha256
1188 (base32
5c6b6827 1189 "0y1ij745r4p48mxq84rax40p10ln7fc7m243p8k8sia519i3dxfc"))
7309045c
JN
1190 (modules '((guix build utils)))
1191 (snippet
1192 ;; Work around "declared gets" error on glibc systems (fixed by
1193 ;; Gnulib commit 66712c23388e93e5c518ebc8515140fa0c807348.)
1194 '(substitute* "srclib/stdio.in.h"
1195 (("^#undef gets") "")
1196 (("^_GL_WARN_ON_USE \\(gets.*") "")))))
1197 (build-system gnu-build-system)
1198 (synopsis "Character set conversion library")
1199 (description
1200 "libiconv provides an implementation of the iconv function for systems
1201that lack it. iconv is used to convert between character encodings in a
1202program. It supports a wide variety of different encodings.")
6fd52309 1203 (home-page "https://www.gnu.org/software/libiconv/")
7309045c
JN
1204 (license lgpl3+)))
1205
4dab8c59
JN
1206(define* (libiconv-if-needed #:optional (target (%current-target-system)))
1207 "Return either a libiconv package specification to include in a dependency
1208list for platforms that have an incomplete libc, or the empty list. If a
1209package needs iconv ,@(libiconv-if-needed) should be added."
1210 ;; POSIX C libraries provide iconv. Platforms with an incomplete libc
1211 ;; without iconv, such as MinGW, must return the then clause.
1212 (if (target-mingw? target)
1213 `(("libiconv" ,libiconv))
1214 '()))
1215
bdb36958
LC
1216(define-public (canonical-package package)
1217 ;; Avoid circular dependency by lazily resolving 'commencement'.
1218 (let* ((iface (resolve-interface '(gnu packages commencement)))
1219 (proc (module-ref iface 'canonical-package)))
1220 (proc package)))
571aa6cd 1221
fb77c614
LC
1222(define-public (%final-inputs)
1223 "Return the list of \"final inputs\"."
1224 ;; Avoid circular dependency by lazily resolving 'commencement'.
1225 (let ((iface (resolve-interface '(gnu packages commencement))))
1226 (module-ref iface '%final-inputs)))
1227
1722d680 1228;;; base.scm ends here