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