Synchronize package descriptions with the Womb.
[jackhill/guix/guix.git] / gnu / packages / base.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
4050e5d6 2;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
233e7676 3;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
e3ce5d70 4;;;
233e7676 5;;; This file is part of GNU Guix.
e3ce5d70 6;;;
233e7676 7;;; GNU Guix is free software; you can redistribute it and/or modify it
e3ce5d70
LC
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
233e7676 12;;; GNU Guix is distributed in the hope that it will be useful, but
e3ce5d70
LC
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
233e7676 18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
e3ce5d70 19
1ffa7090 20(define-module (gnu packages base)
c6d7e299 21 #:use-module ((guix licenses)
e789d9a8 22 #:select (gpl3+ lgpl2.0+ public-domain))
59a43334 23 #:use-module (gnu packages)
1ffa7090
LC
24 #:use-module (gnu packages acl)
25 #:use-module (gnu packages bash)
26 #:use-module (gnu packages bootstrap)
27 #:use-module (gnu packages compression)
e9c0b944 28 #:use-module (gnu packages gcc)
1ffa7090
LC
29 #:use-module (gnu packages gawk)
30 #:use-module (gnu packages guile)
31 #:use-module (gnu packages multiprecision)
32 #:use-module (gnu packages perl)
33 #:use-module (gnu packages linux)
e3ce5d70 34 #:use-module (guix packages)
87f5d366 35 #:use-module (guix download)
e3ce5d70 36 #:use-module (guix build-system gnu)
321b0996 37 #:use-module (guix build-system trivial)
60f984b2
LC
38 #:use-module (guix utils)
39 #:use-module (srfi srfi-1)
40 #:use-module (srfi srfi-26)
41 #:use-module (ice-9 match))
e3ce5d70
LC
42
43;;; Commentary:
44;;;
1722d680 45;;; Base packages of the Guix-based GNU user-land software distribution.
e3ce5d70
LC
46;;;
47;;; Code:
48
49(define-public hello
50 (package
51 (name "hello")
52 (version "2.8")
90c68be8 53 (source (origin
87f5d366 54 (method url-fetch)
0db342a5 55 (uri (string-append "mirror://gnu/hello/hello-" version
90c68be8 56 ".tar.gz"))
e3ce5d70 57 (sha256
e4c245f8 58 (base32 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))))
e3ce5d70
LC
59 (build-system gnu-build-system)
60 (arguments '(#:configure-flags
61 `("--disable-dependency-tracking"
62 ,(string-append "--with-gawk=" ; for illustration purposes
63 (assoc-ref %build-inputs "gawk")))))
64fddd74 64 (inputs `(("gawk" ,gawk)))
f50d2669 65 (synopsis "Hello, GNU world: An example GNU package")
a22dc0c4
LC
66 (description
67 "GNU Hello prints the message \"Hello, world!\" and then exits. It
68serves as an example of standard GNU coding practices. As such, it supports
69command-line arguments, multiple languages, and so on.")
45753b65 70 (home-page "http://www.gnu.org/software/hello/")
4a44e743 71 (license gpl3+)))
d7672884 72
6794b278
LC
73(define-public grep
74 (package
75 (name "grep")
76 (version "2.14")
77 (source (origin
87f5d366 78 (method url-fetch)
0db342a5 79 (uri (string-append "mirror://gnu/grep/grep-"
6794b278
LC
80 version ".tar.xz"))
81 (sha256
82 (base32
83 "1qbjb1l7f9blckc5pqy8jlf6482hpx4awn2acmhyf5mv9wfq03p7"))))
84 (build-system gnu-build-system)
f50d2669 85 (synopsis "Print lines matching a pattern")
d45122f5 86 (description
a22dc0c4
LC
87 "grep is a tool for finding text inside files. Text is found by
88matching a pattern provided by the user in one or many files. The pattern
89may be provided as a basic, extended, or Perl-style regular expression, as
90well as a list of fixed strings. By default, the matching text is simply
91printed to the screen, however the output can be greatly customized to
92include, for example, line numbers.")
4a44e743 93 (license gpl3+)
6794b278
LC
94 (home-page "http://www.gnu.org/software/grep/")))
95
8dcad9aa
LC
96(define-public sed
97 (package
98 (name "sed")
847e7725 99 (version "4.2.2")
8dcad9aa 100 (source (origin
87f5d366 101 (method url-fetch)
0db342a5 102 (uri (string-append "mirror://gnu/sed/sed-" version
8dcad9aa
LC
103 ".tar.bz2"))
104 (sha256
105 (base32
847e7725 106 "1myvrmh99jsvk7v3d7crm0gcrq51hmmm1r2kjyyci152in1x2j7h"))))
8dcad9aa 107 (build-system gnu-build-system)
f50d2669 108 (synopsis "Stream editor")
52b8e5fc 109 (arguments
c8c6bba5
LC
110 (if (%current-target-system)
111 '()
112 `(#:phases (alist-cons-before
113 'patch-source-shebangs 'patch-test-suite
114 (lambda* (#:key inputs #:allow-other-keys)
115 (let ((bash (assoc-ref inputs "bash")))
116 (patch-makefile-SHELL "testsuite/Makefile.tests")
117 (substitute* '("testsuite/bsd.sh"
118 "testsuite/bug-regex9.c")
119 (("/bin/sh")
120 (string-append bash "/bin/bash")))))
121 %standard-phases))))
d45122f5 122 (description
a22dc0c4
LC
123 "Sed is a non-interactive, text stream editor. It receives a text
124input from a file or from standard input and it then applies a series of text
125editing commands to the stream and prints its output to standard output. It
126is often used for substituting text patterns in a stream.")
4a44e743 127 (license gpl3+)
8dcad9aa
LC
128 (home-page "http://www.gnu.org/software/sed/")))
129
85240322
LC
130(define-public tar
131 (package
132 (name "tar")
133 (version "1.26")
134 (source (origin
87f5d366 135 (method url-fetch)
0db342a5 136 (uri (string-append "mirror://gnu/tar/tar-"
85240322
LC
137 version ".tar.bz2"))
138 (sha256
139 (base32
140 "0hbdkzmchq9ycr2x1pxqdcgdbaxksh8c6ac0jf75jajhcks6jlss"))))
141 (build-system gnu-build-system)
472894aa
LC
142 (inputs `(("patch/gets" ,(search-patch "tar-gets-undeclared.patch"))))
143 (arguments
144 `(#:patches (list (assoc-ref %build-inputs "patch/gets"))))
f50d2669 145 (synopsis "Managing tar archives")
d45122f5 146 (description
a22dc0c4
LC
147 "Tar provides the ability to create tar archives, as well as the
148ability to extract, update or list files in an existing archive. It is
149useful for combining many files into one larger file, while maintaining
150directory structure and file information such as permissions and
151creation/modification dates.")
4a44e743 152 (license gpl3+)
85240322
LC
153 (home-page "http://www.gnu.org/software/tar/")))
154
fbeec3d9
LC
155(define-public patch
156 (package
157 (name "patch")
9369a02b 158 (version "2.7.1")
fbeec3d9 159 (source (origin
87f5d366 160 (method url-fetch)
0db342a5 161 (uri (string-append "mirror://gnu/patch/patch-"
fbeec3d9
LC
162 version ".tar.xz"))
163 (sha256
164 (base32
9369a02b 165 "1sqckf560pzwgniy00vcpdv2c9c11s4cmhlm14yqgg8avd3bl94i"))))
fbeec3d9
LC
166 (build-system gnu-build-system)
167 (native-inputs '()) ; FIXME: needs `ed' for the tests
168 (arguments
21c203a5
LC
169 '(#:tests? #f)
170 ;; TODO: When cross-compiling, add this:
171 ;; '(#:configure-flags '("ac_cv_func_strnlen_working=yes"))
172 )
f50d2669 173 (synopsis "Apply differences to originals, with optional backups")
d45122f5 174 (description
a22dc0c4
LC
175 "Patch is a program that applies changes to files based on differences
176laid out by the program \"diff\". The changes may be applied to one or more
177files depending on the contents of the diff file. It accepts several
178different diff formats. It may also be used to revert previously applied
179differences.")
4a44e743 180 (license gpl3+)
fbeec3d9
LC
181 (home-page "http://savannah.gnu.org/projects/patch/")))
182
04a32ee5
LC
183(define-public diffutils
184 (package
185 (name "diffutils")
d83ae724 186 (version "3.3")
04a32ee5 187 (source (origin
87f5d366 188 (method url-fetch)
0db342a5 189 (uri (string-append "mirror://gnu/diffutils/diffutils-"
04a32ee5
LC
190 version ".tar.xz"))
191 (sha256
192 (base32
d83ae724 193 "1761vymxbp4wb5rzjvabhdkskk95pghnn67464byvzb5mfl8jpm2"))))
04a32ee5 194 (build-system gnu-build-system)
f50d2669 195 (synopsis "Comparing and merging files")
d45122f5 196 (description
a22dc0c4
LC
197 "Diffutils is a package containing several tool for finding the
198differences between files. The diff command is used to show how two files
199differ, while cmp shows the offsets and line numbers where they differ.
200diff3 allows you to compare three files. Finally, sdiff offers an
201interactive means to merge two files.")
4a44e743 202 (license gpl3+)
04a32ee5
LC
203 (home-page "http://www.gnu.org/software/diffutils/")))
204
af5521ca
LC
205(define-public findutils
206 (package
207 (name "findutils")
208 (version "4.4.2")
209 (source (origin
87f5d366 210 (method url-fetch)
0db342a5 211 (uri (string-append "mirror://gnu/findutils/findutils-"
af5521ca
LC
212 version ".tar.gz"))
213 (sha256
214 (base32
215 "0amn0bbwqvsvvsh6drfwz20ydc2czk374lzw5kksbh6bf78k4ks3"))))
216 (build-system gnu-build-system)
217 (native-inputs
218 `(("patch/absolute-paths"
800cdeef 219 ,(search-patch "findutils-absolute-paths.patch"))))
af5521ca 220 (arguments
cf9fd501 221 `(#:patches (list (assoc-ref %build-inputs "patch/absolute-paths"))
21c203a5 222
cf9fd501
LC
223 ;; Work around cross-compilation failure.
224 ;; See <http://savannah.gnu.org/bugs/?27299#comment1>.
225 ,@(if (%current-target-system)
226 '(#:configure-flags '("gl_cv_func_wcwidth_works=yes"))
227 '())))
f50d2669 228 (synopsis "Operating on files matching given criteria")
d45122f5 229 (description
a22dc0c4
LC
230 "Findutils supplies the basic file directory searching utilities of the
231GNU system. It consists of two primary searching utilities: \"find\"
232recursively searches for files in a directory according to given criteria and
233\"locate\" lists files in a database that match a query. Two auxiliary tools
234are included: \"updatedb\" updates a file name database and \"xargs\" may be used
235to apply commands to file search results.")
4a44e743 236 (license gpl3+)
af5521ca 237 (home-page "http://www.gnu.org/software/findutils/")))
2c957cd2
LC
238
239(define-public coreutils
240 (package
241 (name "coreutils")
847e7725 242 (version "8.21")
2c957cd2 243 (source (origin
87f5d366 244 (method url-fetch)
0db342a5 245 (uri (string-append "mirror://gnu/coreutils/coreutils-"
2c957cd2
LC
246 version ".tar.xz"))
247 (sha256
248 (base32
847e7725 249 "064f512185iysqqcvhnhaf3bfmzrvcgs7n405qsyp99zmfyl9amd"))))
2c957cd2 250 (build-system gnu-build-system)
de59af4d 251 (inputs `(("acl" ,acl) ; TODO: add SELinux
8ba8aeb7 252 ("gmp" ,gmp)
de59af4d
LC
253
254 ;; Perl is needed to run tests; remove it from cross builds.
255 ,@(if (%current-target-system)
256 '()
257 `(("perl" ,perl)))))
9bf62d9b 258 (outputs '("out" "debug"))
2c957cd2 259 (arguments
8ba8aeb7
LC
260 `(#:parallel-build? #f ; help2man may be called too early
261 #:phases (alist-cons-before
262 'build 'patch-shell-references
263 (lambda* (#:key inputs #:allow-other-keys)
264 (let ((bash (assoc-ref inputs "bash")))
265 (substitute* (cons "src/split.c"
266 (find-files "gnulib-tests"
267 "\\.c$"))
268 (("/bin/sh")
269 (format #f "~a/bin/sh" bash)))
270 (substitute* (find-files "tests" "\\.sh$")
271 (("#!/bin/sh")
272 (format #f "#!~a/bin/bash" bash)))))
56c092ce 273 %standard-phases)))
f50d2669 274 (synopsis "Core GNU utilities (file, text, shell)")
d45122f5 275 (description
a22dc0c4
LC
276 "Coreutils includes all of the basic commandline tools that are
277expected in a POSIX system. These provide the basic file, shell and text
278manipulation functions of the GNU system. Most of these tools offer extended
279functionality beyond that which is outlined in the POSIX standard.")
4a44e743 280 (license gpl3+)
2c957cd2 281 (home-page "http://www.gnu.org/software/coreutils/")))
af5521ca 282
ab776865
LC
283(define-public gnu-make
284 (package
285 (name "make")
286 (version "3.82")
287 (source (origin
87f5d366 288 (method url-fetch)
0db342a5 289 (uri (string-append "mirror://gnu/make/make-" version
ab776865
LC
290 ".tar.bz2"))
291 (sha256
292 (base32
293 "0ri98385hsd7li6rh4l5afcq92v8l2lgiaz85wgcfh4w2wzsghg2"))))
294 (build-system gnu-build-system)
295 (native-inputs
800cdeef 296 `(("patch/impure-dirs" ,(search-patch "make-impure-dirs.patch"))))
9bf62d9b 297 (outputs '("out" "debug"))
ea8fbbf2
LC
298 (arguments
299 '(#:patches (list (assoc-ref %build-inputs "patch/impure-dirs"))
300 #:phases (alist-cons-before
301 'build 'set-default-shell
302 (lambda* (#:key inputs #:allow-other-keys)
303 ;; Change the default shell from /bin/sh.
304 (let ((bash (assoc-ref inputs "bash")))
305 (substitute* "job.c"
306 (("default_shell\\[\\] =.*$")
307 (format #f "default_shell[] = \"~a/bin/bash\";\n"
308 bash)))))
309 %standard-phases)))
f50d2669 310 (synopsis "Remake files automatically")
d45122f5 311 (description
a22dc0c4
LC
312 "Make is a program that is used to control the production of
313executables or other files from their source files. The process is
314controlled from a Makefile, in which the developer specifies how each file is
315generated from its source. It has powerful dependency resolution and the
316ability to determine when files have to be regenerated after their sources
317change.")
4a44e743 318 (license gpl3+)
ab776865
LC
319 (home-page "http://www.gnu.org/software/make/")))
320
8f6201a3
LC
321(define-public binutils
322 (package
323 (name "binutils")
3b401612 324 (version "2.23.2")
8f6201a3 325 (source (origin
87f5d366 326 (method url-fetch)
0db342a5 327 (uri (string-append "mirror://gnu/binutils/binutils-"
8f6201a3
LC
328 version ".tar.bz2"))
329 (sha256
330 (base32
3b401612 331 "15qhbkz3r266xaa52slh857qn3abw7rb2x2jnhpfrafpzrb4x4gy"))))
8f6201a3
LC
332 (build-system gnu-build-system)
333
4873f8ed
LC
334 ;; Split Binutils in several outputs, mostly to avoid collisions in
335 ;; user profiles with GCC---e.g., libiberty.a.
336 (outputs '("out" ; ar, ld, binutils.info, etc.
337 "lib")) ; libbfd.a, bfd.h, etc.
338
8f6201a3
LC
339 ;; TODO: Add dependency on zlib + those for Gold.
340 (native-inputs
341 `(("patch/new-dtags" ,(search-patch "binutils-ld-new-dtags.patch"))))
342 (arguments
343 `(#:patches (list (assoc-ref %build-inputs "patch/new-dtags"))
01d45404
LC
344 #:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
345 ;; on GCC when bootstrapping.
346 "LDFLAGS=-static-libgcc"
8f6201a3 347
01d45404 348 ;; Don't search under /usr/lib & co.
444c64b0
LC
349 "--with-lib-path=/no-ld-lib-path"
350
351 ;; Glibc 2.17 has a "comparison of unsigned
352 ;; expression >= 0 is always true" in wchar.h.
353 "--disable-werror")))
8f6201a3 354
f50d2669 355 (synopsis "Binary utilities: bfd gas gprof ld")
d45122f5 356 (description
a22dc0c4
LC
357 "GNU Binutils is a collection of tools for working with binary files.
358Most notable are \"ld\", a linker, and \"as\", an assembler. Several other tools
359are included, such as a program to display binary profiling information, a
360tool to list the strings in a binary file, and tools for working with
361archives.")
4a44e743 362 (license gpl3+)
8f6201a3
LC
363 (home-page "http://www.gnu.org/software/binutils/")))
364
7cdeac02
LC
365(define-public glibc
366 (package
367 (name "glibc")
3409bc01 368 (version "2.18")
7cdeac02 369 (source (origin
87f5d366 370 (method url-fetch)
0db342a5 371 (uri (string-append "mirror://gnu/glibc/glibc-"
7cdeac02
LC
372 version ".tar.xz"))
373 (sha256
374 (base32
3409bc01 375 "18spla703zav8dq9fw7rbzkyv9qfisxb26p7amg1x3wjh7iy3d1c"))))
7cdeac02 376 (build-system gnu-build-system)
0a3da5b7
LC
377
378 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
379 ;; users should automatically pull Linux headers as well.
124b1767 380 (propagated-inputs `(("linux-headers" ,linux-libre-headers)))
0a3da5b7 381
7f614e49
LC
382 ;; Store the locales separately (~100 MiB). Note that "out" retains a
383 ;; reference to them anyway, so there's no space savings here.
384 ;; TODO: Eventually we may want to add a $LOCALE_ARCHIVE search path like
385 ;; Nixpkgs does.
9bf62d9b 386 (outputs '("out" "locales" "debug"))
7f614e49 387
7cdeac02 388 (arguments
8197c978 389 `(#:out-of-source? #t
692b9340
LC
390 #:patches (list (assoc-ref %build-inputs "patch/ld.so.cache")
391 (assoc-ref %build-inputs "patch/ldd"))
7cdeac02
LC
392 #:configure-flags
393 (list "--enable-add-ons"
394 "--sysconfdir=/etc"
7f614e49
LC
395 (string-append "--localedir=" (assoc-ref %outputs "locales")
396 "/share/locale")
397
398 ;; `--localedir' is not honored, so work around it.
399 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
400 (string-append "libc_cv_localedir="
401 (assoc-ref %outputs "locales")
402 "/share/locale")
403
7cdeac02
LC
404 (string-append "--with-headers="
405 (assoc-ref %build-inputs "linux-headers")
406 "/include")
5f456680
LC
407
408 ;; The default is to assume a 2.4 Linux interface, but we'll
409 ;; always use something newer. See "kernel-features.h" in the
410 ;; GNU libc for details.
411 "--enable-kernel=2.6.30"
412
6e32f6c0 413 ;; Use our Bash instead of /bin/sh.
8cd8e97c 414 (string-append "BASH_SHELL="
6e32f6c0 415 (assoc-ref %build-inputs "bash")
8cd8e97c
LC
416 "/bin/bash")
417
418 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
419 "libc_cv_ssp=no")
6e32f6c0 420
7cdeac02
LC
421 #:tests? #f ; XXX
422 #:phases (alist-cons-before
423 'configure 'pre-configure
6e32f6c0
LC
424 (lambda* (#:key inputs outputs #:allow-other-keys)
425 (let* ((out (assoc-ref outputs "out"))
426 (bin (string-append out "/bin")))
7cdeac02
LC
427 ;; Use `pwd', not `/bin/pwd'.
428 (substitute* "configure"
0a3da5b7 429 (("/bin/pwd") "pwd"))
7cdeac02
LC
430
431 ;; Install the rpc data base file under `$out/etc/rpc'.
8197c978 432 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
7cdeac02
LC
433 (substitute* "sunrpc/Makefile"
434 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
435 (string-append out "/etc/rpc" suffix "\n"))
436 (("^install-others =.*$")
321b0996
LC
437 (string-append "install-others = " out "/etc/rpc\n")))
438
439 (substitute* "Makeconfig"
440 ;; According to
441 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
442 ;; linking against libgcc_s is not needed with GCC
443 ;; 4.7.1.
6e32f6c0
LC
444 ((" -lgcc_s") ""))
445
46866fad
LC
446 ;; Copy a statically-linked Bash in the output, with
447 ;; no references to other store paths.
6e32f6c0 448 (mkdir-p bin)
46866fad
LC
449 (copy-file (string-append (assoc-ref inputs "static-bash")
450 "/bin/bash")
6e32f6c0 451 (string-append bin "/bash"))
46866fad 452 (remove-store-references (string-append bin "/bash"))
6e32f6c0
LC
453 (chmod (string-append bin "/bash") #o555)
454
46866fad
LC
455 ;; Keep a symlink, for `patch-shebang' resolution.
456 (with-directory-excursion bin
457 (symlink "bash" "sh"))
458
6e32f6c0
LC
459 ;; Have `system' use that Bash.
460 (substitute* "sysdeps/posix/system.c"
461 (("#define[[:blank:]]+SHELL_PATH.*$")
462 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
463 out)))
464
465 ;; Same for `popen'.
466 (substitute* "libio/iopopen.c"
467 (("/bin/sh")
468 (string-append out "/bin/bash")))))
7f614e49
LC
469 (alist-cons-after
470 'install 'install-locales
471 (lambda _
472 (zero? (system* "make" "localedata/install-locales")))
473 %standard-phases))))
474
25608d64 475 (inputs `(("patch/ld.so.cache"
6e32f6c0 476 ,(search-patch "glibc-no-ld-so-cache.patch"))
692b9340
LC
477 ("patch/ldd"
478 ,(search-patch "glibc-ldd-x86_64.patch"))
46866fad 479 ("static-bash" ,(static-package bash-light))))
d45122f5
LC
480 (synopsis "The GNU C Library")
481 (description
7cdeac02
LC
482 "Any Unix-like operating system needs a C library: the library which
483defines the \"system calls\" and other basic facilities such as open, malloc,
484printf, exit...
485
486The GNU C library is used as the C library in the GNU system and most systems
487with the Linux kernel.")
4a44e743 488 (license lgpl2.0+)
7cdeac02
LC
489 (home-page "http://www.gnu.org/software/libc/")))
490
e789d9a8
LC
491(define-public tzdata
492 (package
493 (name "tzdata")
acf428dd 494 (version "2013d")
e789d9a8
LC
495 (source (origin
496 (method url-fetch)
497 (uri (string-append
498 "http://www.iana.org/time-zones/repository/releases/tzdata"
499 version ".tar.gz"))
500 (sha256
501 (base32
18555772 502 "011v63ppr73vhjgxv00inkn5pc7z48i8lhbapkpdq3kfczq9c76d"))))
e789d9a8
LC
503 (build-system gnu-build-system)
504 (arguments
505 '(#:tests? #f
506 #:make-flags (let ((out (assoc-ref %outputs "out"))
507 (tmp (getenv "TMPDIR")))
508 (list (string-append "TOPDIR=" out)
509 (string-append "TZDIR=" out "/share/zoneinfo")
510
511 ;; Discard zic, dump, and tzselect, already
512 ;; provided by glibc.
513 (string-append "ETCDIR=" tmp "/etc")
514
515 ;; Likewise for the C library routines.
516 (string-append "LIBDIR=" tmp "/lib")
517 (string-append "MANDIR=" tmp "/man")
518
519 "AWK=awk"
520 "CC=gcc"))
521 #:modules ((guix build utils)
522 (guix build gnu-build-system)
523 (srfi srfi-1))
524 #:phases
525 (alist-replace
526 'unpack
527 (lambda* (#:key inputs #:allow-other-keys)
528 (and (zero? (system* "tar" "xvf" (assoc-ref inputs "source")))
529 (zero? (system* "tar" "xvf" (assoc-ref inputs "tzcode")))))
530 (alist-cons-after
531 'install 'post-install
532 (lambda* (#:key outputs #:allow-other-keys)
533 ;; Move data in the right place.
534 (let ((out (assoc-ref outputs "out")))
535 (copy-recursively (string-append out "/share/zoneinfo-posix")
536 (string-append out "/share/zoneinfo/posix"))
537 (copy-recursively (string-append out "/share/zoneinfo-leaps")
538 (string-append out "/share/zoneinfo/right"))
539 (delete-file-recursively (string-append out "/share/zoneinfo-posix"))
540 (delete-file-recursively (string-append out "/share/zoneinfo-leaps"))))
541 (alist-delete 'configure %standard-phases)))))
542 (inputs `(("tzcode" ,(origin
543 (method url-fetch)
544 (uri (string-append
545 "http://www.iana.org/time-zones/repository/releases/tzcode"
546 version ".tar.gz"))
547 (sha256
548 (base32
853726dd 549 "1dh7nzmfxs8fps4bzcd2lz5fz24zxy2123a99avxsk34jh6bk7id"))))))
e789d9a8
LC
550 (home-page "http://www.iana.org/time-zones")
551 (synopsis "Database of current and historical time zones")
552 (description "The Time Zone Database (often called tz or zoneinfo)
553contains code and data that represent the history of local time for many
554representative locations around the globe. It is updated periodically to
555reflect changes made by political bodies to time zone boundaries, UTC offsets,
556and daylight-saving rules.")
557 (license public-domain)))
558
60f984b2
LC
559\f
560;;;
561;;; Bootstrap packages.
562;;;
563
3c0670e6 564(define gnu-make-boot0
d6e87776
LC
565 (package-with-bootstrap-guile
566 (package (inherit gnu-make)
567 (name "make-boot0")
568 (location (source-properties->location (current-source-location)))
ea8fbbf2
LC
569 (arguments
570 `(#:guile ,%bootstrap-guile
571 #:implicit-inputs? #f
572 #:tests? #f ; cannot run "make check"
573 ,@(substitute-keyword-arguments (package-arguments gnu-make)
574 ((#:phases phases)
575 `(alist-replace
576 'build (lambda _
577 (zero? (system* "./build.sh")))
578 (alist-replace
579 'install (lambda* (#:key outputs #:allow-other-keys)
580 (let* ((out (assoc-ref outputs "out"))
581 (bin (string-append out "/bin")))
582 (mkdir-p bin)
583 (copy-file "make"
584 (string-append bin "/make"))))
585 ,phases))))))
d6e87776 586 (inputs %bootstrap-inputs))))
3c0670e6
LC
587
588(define diffutils-boot0
d6e87776
LC
589 (package-with-bootstrap-guile
590 (let ((p (package-with-explicit-inputs diffutils
591 `(("make" ,gnu-make-boot0)
592 ,@%bootstrap-inputs)
593 #:guile %bootstrap-guile)))
594 (package (inherit p)
595 (location (source-properties->location (current-source-location)))
596 (arguments `(#:tests? #f ; the test suite needs diffutils
597 ,@(package-arguments p)))))))
3c0670e6
LC
598
599(define findutils-boot0
d6e87776
LC
600 (package-with-bootstrap-guile
601 (package-with-explicit-inputs findutils
602 `(("make" ,gnu-make-boot0)
603 ("diffutils" ,diffutils-boot0) ; for tests
604 ,@%bootstrap-inputs)
605 (current-source-location)
606 #:guile %bootstrap-guile)))
3c0670e6
LC
607
608
609(define %boot0-inputs
610 `(("make" ,gnu-make-boot0)
611 ("diffutils" ,diffutils-boot0)
612 ("findutils" ,findutils-boot0)
613 ,@%bootstrap-inputs))
614
21c203a5
LC
615(define* (nix-system->gnu-triplet
616 #:optional (system (%current-system)) (vendor "unknown"))
321b0996
LC
617 "Return an a guess of the GNU triplet corresponding to Nix system
618identifier SYSTEM."
619 (let* ((dash (string-index system #\-))
620 (arch (substring system 0 dash))
621 (os (substring system (+ 1 dash))))
622 (string-append arch
623 "-" vendor "-"
624 (if (string=? os "linux")
625 "linux-gnu"
626 os))))
627
21c203a5 628(define* (boot-triplet #:optional (system (%current-system)))
321b0996
LC
629 ;; Return the triplet used to create the cross toolchain needed in the
630 ;; first bootstrapping stage.
21c203a5 631 (nix-system->gnu-triplet system "guix"))
321b0996
LC
632
633;; Following Linux From Scratch, build a cross-toolchain in stage 0. That
634;; toolchain actually targets the same OS and arch, but it has the advantage
635;; of being independent of the libc and tools in %BOOTSTRAP-INPUTS, since
636;; GCC-BOOT0 (below) is built without any reference to the target libc.
637
638(define binutils-boot0
d6e87776
LC
639 (package-with-bootstrap-guile
640 (package (inherit binutils)
641 (name "binutils-cross-boot0")
642 (arguments
21c203a5
LC
643 `(#:guile ,%bootstrap-guile
644 #:implicit-inputs? #f
645 ,@(substitute-keyword-arguments (package-arguments binutils)
646 ((#:configure-flags cf)
444c64b0
LC
647 `(cons ,(string-append "--target=" (boot-triplet))
648 ,cf)))))
d6e87776 649 (inputs %boot0-inputs))))
321b0996 650
60f984b2 651(define gcc-boot0
d6e87776
LC
652 (package-with-bootstrap-guile
653 (package (inherit gcc-4.7)
654 (name "gcc-cross-boot0")
655 (arguments
21c203a5
LC
656 `(#:guile ,%bootstrap-guile
657 #:implicit-inputs? #f
658 #:modules ((guix build gnu-build-system)
659 (guix build utils)
660 (ice-9 regex)
661 (srfi srfi-1)
662 (srfi srfi-26))
663 ,@(substitute-keyword-arguments (package-arguments gcc-4.7)
664 ((#:configure-flags flags)
665 `(append (list ,(string-append "--target=" (boot-triplet))
666
667 ;; No libc yet.
668 "--without-headers"
669
670 ;; Disable features not needed at this stage.
671 "--disable-shared"
672 "--enable-languages=c"
673 "--disable-libmudflap"
674 "--disable-libgomp"
675 "--disable-libssp"
676 "--disable-libquadmath"
677 "--disable-decimal-float")
678 (remove (cut string-match "--enable-languages.*" <>)
679 ,flags)))
680 ((#:phases phases)
681 `(alist-cons-after
682 'unpack 'unpack-gmp&co
683 (lambda* (#:key inputs #:allow-other-keys)
684 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
685 (mpfr (assoc-ref %build-inputs "mpfr-source"))
686 (mpc (assoc-ref %build-inputs "mpc-source")))
687
688 ;; To reduce the set of pre-built bootstrap inputs, build
689 ;; GMP & co. from GCC.
690 (for-each (lambda (source)
691 (or (zero? (system* "tar" "xvf" source))
692 (error "failed to unpack tarball"
693 source)))
694 (list gmp mpfr mpc))
695
696 ;; Create symlinks like `gmp' -> `gmp-5.0.5'.
697 ,@(map (lambda (lib)
698 `(symlink ,(package-full-name lib)
699 ,(package-name lib)))
700 (list gmp mpfr mpc))
701
702 ;; MPFR headers/lib are found under $(MPFR)/src, but
703 ;; `configure' wrongfully tells MPC too look under
704 ;; $(MPFR), so fix that.
705 (substitute* "configure"
706 (("extra_mpc_mpfr_configure_flags(.+)--with-mpfr-include=([^/]+)/mpfr(.*)--with-mpfr-lib=([^ ]+)/mpfr"
707 _ equals include middle lib)
708 (string-append "extra_mpc_mpfr_configure_flags" equals
709 "--with-mpfr-include=" include
710 "/mpfr/src" middle
711 "--with-mpfr-lib=" lib
712 "/mpfr/src"))
713 (("gmpinc='-I([^ ]+)/mpfr -I([^ ]+)/mpfr" _ a b)
714 (string-append "gmpinc='-I" a "/mpfr/src "
715 "-I" b "/mpfr/src"))
716 (("gmplibs='-L([^ ]+)/mpfr" _ a)
717 (string-append "gmplibs='-L" a "/mpfr/src")))))
718 (alist-cons-after
719 'install 'symlink-libgcc_eh
720 (lambda* (#:key outputs #:allow-other-keys)
721 (let ((out (assoc-ref outputs "out")))
722 ;; Glibc wants to link against libgcc_eh, so provide
723 ;; it.
724 (with-directory-excursion
725 (string-append out "/lib/gcc/"
726 ,(boot-triplet)
727 "/" ,(package-version gcc-4.7))
728 (symlink "libgcc.a" "libgcc_eh.a"))))
729 ,phases))))))
d6e87776
LC
730
731 (inputs `(("gmp-source" ,(package-source gmp))
732 ("mpfr-source" ,(package-source mpfr))
733 ("mpc-source" ,(package-source mpc))
734 ("binutils-cross" ,binutils-boot0)
735
736 ;; Call it differently so that the builder can check whether
737 ;; the "libc" input is #f.
738 ("libc-native" ,@(assoc-ref %boot0-inputs "libc"))
c8ebc821
LC
739 ,@(alist-delete "libc" %boot0-inputs)))
740
741 ;; No need for Texinfo at this stage.
742 (native-inputs (alist-delete "texinfo"
743 (package-native-inputs gcc-4.7))))))
60f984b2 744
74067e1a
LC
745(define (linux-libre-headers-boot0)
746 "Return Linux-Libre header files for the bootstrap environment."
747 ;; Note: this is wrapped in a thunk to nicely handle circular dependencies
748 ;; between (gnu packages linux) and this module.
d6e87776
LC
749 (package-with-bootstrap-guile
750 (package (inherit linux-libre-headers)
751 (arguments `(#:guile ,%bootstrap-guile
752 #:implicit-inputs? #f
753 ,@(package-arguments linux-libre-headers)))
754 (native-inputs
755 (let ((perl (package-with-explicit-inputs perl
756 %boot0-inputs
757 (current-source-location)
758 #:guile %bootstrap-guile)))
759 `(("perl" ,perl)
760 ,@%boot0-inputs))))))
60f984b2
LC
761
762(define %boot1-inputs
763 ;; 2nd stage inputs.
764 `(("gcc" ,gcc-boot0)
321b0996
LC
765 ("binutils-cross" ,binutils-boot0)
766
767 ;; Keep "binutils" here because the cross-gcc invokes `as', not the
768 ;; cross-`as'.
769 ,@%boot0-inputs))
60f984b2 770
46866fad 771(define glibc-final-with-bootstrap-bash
321b0996 772 ;; The final libc, "cross-built". If everything went well, the resulting
46866fad
LC
773 ;; store path has no dependencies. Actually, the really-final libc is
774 ;; built just below; the only difference is that this one uses the
775 ;; bootstrap Bash.
d6e87776
LC
776 (package-with-bootstrap-guile
777 (package (inherit glibc)
46866fad 778 (name "glibc-intermediate")
d6e87776 779 (arguments
21c203a5
LC
780 `(#:guile ,%bootstrap-guile
781 #:implicit-inputs? #f
782
783 ,@(substitute-keyword-arguments (package-arguments glibc)
784 ((#:configure-flags flags)
785 `(append (list ,(string-append "--host=" (boot-triplet))
786 ,(string-append "--build="
787 (nix-system->gnu-triplet))
788
789 ;; Build Sun/ONC RPC support. In particular,
790 ;; install rpc/*.h.
791 "--enable-obsolete-rpc")
792 ,flags)))))
74067e1a 793 (propagated-inputs `(("linux-headers" ,(linux-libre-headers-boot0))))
46866fad
LC
794 (inputs
795 `( ;; A native GCC is needed to build `cross-rpcgen'.
796 ("native-gcc" ,@(assoc-ref %boot0-inputs "gcc"))
321b0996 797
46866fad
LC
798 ;; Here, we use the bootstrap Bash, which is not satisfactory
799 ;; because we don't want to depend on bootstrap tools.
800 ("static-bash" ,@(assoc-ref %boot0-inputs "bash"))
801
802 ,@%boot1-inputs
803 ,@(alist-delete "static-bash"
804 (package-inputs glibc))))))) ; patches
805
806(define (cross-gcc-wrapper gcc binutils glibc bash)
807 "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC
808that makes it available under the native tool names."
321b0996 809 (package (inherit gcc-4.7)
46866fad 810 (name (string-append (package-name gcc) "-wrapped"))
d6e87776 811 (source #f)
321b0996
LC
812 (build-system trivial-build-system)
813 (arguments
21c203a5
LC
814 `(#:guile ,%bootstrap-guile
815 #:modules ((guix build utils))
816 #:builder (begin
817 (use-modules (guix build utils))
818
819 (let* ((binutils (assoc-ref %build-inputs "binutils"))
820 (gcc (assoc-ref %build-inputs "gcc"))
821 (libc (assoc-ref %build-inputs "libc"))
822 (bash (assoc-ref %build-inputs "bash"))
823 (out (assoc-ref %outputs "out"))
824 (bindir (string-append out "/bin"))
825 (triplet ,(boot-triplet)))
826 (mkdir-p bindir)
827 (with-directory-excursion bindir
828 (for-each (lambda (tool)
829 (symlink (string-append binutils "/bin/"
830 triplet "-" tool)
831 tool))
832 '("ar" "ranlib"))
833
834 ;; GCC-BOOT0 is a libc-less cross-compiler, so it
835 ;; needs to be told where to find the crt files and
836 ;; the dynamic linker.
837 (call-with-output-file "gcc"
838 (lambda (p)
839 (format p "#!~a/bin/bash
683d57f4 840exec ~a/bin/~a-gcc -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
21c203a5
LC
841 bash
842 gcc triplet
843 libc libc
844 ,(glibc-dynamic-linker))))
321b0996 845
21c203a5 846 (chmod "gcc" #o555))))))
321b0996 847 (native-inputs
46866fad
LC
848 `(("binutils" ,binutils)
849 ("gcc" ,gcc)
850 ("libc" ,glibc)
851 ("bash" ,bash)))
321b0996 852 (inputs '())))
60f984b2 853
46866fad
LC
854(define static-bash-for-glibc
855 ;; A statically-linked Bash to be embedded in GLIBC-FINAL, for use by
856 ;; system(3) & co.
857 (let* ((gcc (cross-gcc-wrapper gcc-boot0 binutils-boot0
858 glibc-final-with-bootstrap-bash
859 (car (assoc-ref %boot1-inputs "bash"))))
860 (bash (package (inherit bash-light)
861 (arguments
21c203a5
LC
862 `(#:guile ,%bootstrap-guile
863 ,@(package-arguments bash-light))))))
46866fad
LC
864 (package-with-bootstrap-guile
865 (package-with-explicit-inputs (static-package bash)
866 `(("gcc" ,gcc)
867 ("libc" ,glibc-final-with-bootstrap-bash)
868 ,@(fold alist-delete %boot1-inputs
869 '("gcc" "libc")))
870 (current-source-location)))))
871
872(define-public glibc-final
873 ;; The final glibc, which embeds the statically-linked Bash built above.
874 (package (inherit glibc-final-with-bootstrap-bash)
875 (name "glibc")
876 (inputs `(("static-bash" ,static-bash-for-glibc)
877 ,@(alist-delete
878 "static-bash"
879 (package-inputs glibc-final-with-bootstrap-bash))))))
880
881(define gcc-boot0-wrapped
882 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
883 ;; non-cross names.
884 (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final
885 (car (assoc-ref %boot1-inputs "bash"))))
886
60f984b2
LC
887(define %boot2-inputs
888 ;; 3rd stage inputs.
889 `(("libc" ,glibc-final)
321b0996
LC
890 ("gcc" ,gcc-boot0-wrapped)
891 ,@(fold alist-delete %boot1-inputs '("libc" "gcc"))))
60f984b2 892
8ba60d7b 893(define-public binutils-final
a48dddfe
LC
894 (package-with-bootstrap-guile
895 (package (inherit binutils)
896 (arguments
21c203a5
LC
897 `(#:guile ,%bootstrap-guile
898 #:implicit-inputs? #f
899 ,@(package-arguments binutils)))
a48dddfe 900 (inputs %boot2-inputs))))
60f984b2 901
321b0996
LC
902(define-public gcc-final
903 ;; The final GCC.
904 (package (inherit gcc-boot0)
905 (name "gcc")
60f984b2 906 (arguments
21c203a5
LC
907 `(#:guile ,%bootstrap-guile
908 #:implicit-inputs? #f
909
910 ;; Build again GMP & co. within GCC's build process, because it's hard
911 ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus
912 ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
913 ,@(substitute-keyword-arguments (package-arguments gcc-boot0)
914 ((#:configure-flags boot-flags)
915 (let loop ((args (package-arguments gcc-4.7)))
916 (match args
917 ((#:configure-flags normal-flags _ ...)
918 normal-flags)
919 ((_ rest ...)
920 (loop rest)))))
921 ((#:phases phases)
922 `(alist-delete 'symlink-libgcc_eh ,phases)))))
321b0996
LC
923
924 (inputs `(("gmp-source" ,(package-source gmp))
925 ("mpfr-source" ,(package-source mpfr))
926 ("mpc-source" ,(package-source mpc))
927 ("binutils" ,binutils-final)
60f984b2
LC
928 ,@%boot2-inputs))))
929
82dc2b9a
LC
930(define ld-wrapper-boot3
931 ;; A linker wrapper that uses the bootstrap Guile.
932 (package
933 (name "ld-wrapper-boot3")
934 (version "0")
935 (source #f)
936 (build-system trivial-build-system)
937 (inputs `(("binutils" ,binutils-final)
dfb53ee2
LC
938 ("guile" ,%bootstrap-guile)
939 ("bash" ,@(assoc-ref %boot2-inputs "bash"))
940 ("wrapper" ,(search-path %load-path
1ffa7090 941 "gnu/packages/ld-wrapper.scm"))))
82dc2b9a 942 (arguments
2143cf7a
LC
943 `(#:guile ,%bootstrap-guile
944 #:modules ((guix build utils))
82dc2b9a
LC
945 #:builder (begin
946 (use-modules (guix build utils)
947 (system base compile))
948
949 (let* ((out (assoc-ref %outputs "out"))
950 (bin (string-append out "/bin"))
951 (ld (string-append bin "/ld"))
952 (go (string-append bin "/ld.go")))
953
954 (setvbuf (current-output-port) _IOLBF)
955 (format #t "building ~s/bin/ld wrapper in ~s~%"
956 (assoc-ref %build-inputs "binutils")
957 out)
958
7da95264 959 (mkdir-p bin)
82dc2b9a
LC
960 (copy-file (assoc-ref %build-inputs "wrapper") ld)
961 (substitute* ld
962 (("@GUILE@")
963 (string-append (assoc-ref %build-inputs "guile")
964 "/bin/guile"))
dfb53ee2
LC
965 (("@BASH@")
966 (string-append (assoc-ref %build-inputs "bash")
967 "/bin/bash"))
82dc2b9a
LC
968 (("@LD@")
969 (string-append (assoc-ref %build-inputs "binutils")
970 "/bin/ld")))
971 (chmod ld #o555)
972 (compile-file ld #:output-file go)))))
d45122f5
LC
973 (synopsis "The linker wrapper")
974 (description
82dc2b9a
LC
975 "The linker wrapper (or `ld-wrapper') wraps the linker to add any
976missing `-rpath' flags, and to detect any misuse of libraries outside of the
977store.")
978 (home-page #f)
4a44e743 979 (license gpl3+)))
82dc2b9a 980
60f984b2
LC
981(define %boot3-inputs
982 ;; 4th stage inputs.
60f984b2 983 `(("gcc" ,gcc-final)
82dc2b9a 984 ("ld-wrapper" ,ld-wrapper-boot3)
321b0996 985 ,@(alist-delete "gcc" %boot2-inputs)))
60f984b2 986
82dc2b9a 987(define-public bash-final
ce1ef15b
LC
988 ;; Link with `-static-libgcc' to make sure we don't retain a reference
989 ;; to the bootstrap GCC.
d6e87776 990 (package-with-bootstrap-guile
ce1ef15b
LC
991 (package-with-explicit-inputs (static-libgcc-package bash)
992 %boot3-inputs
d6e87776
LC
993 (current-source-location)
994 #:guile %bootstrap-guile)))
82dc2b9a 995
4033bde8
LC
996(define %boot4-inputs
997 ;; Now use the final Bash.
998 `(("bash" ,bash-final)
999 ,@(alist-delete "bash" %boot3-inputs)))
1000
82dc2b9a 1001(define-public guile-final
c0895112
LC
1002 (package-with-bootstrap-guile
1003 (package-with-explicit-inputs guile-2.0/fixed
1004 %boot4-inputs
1005 (current-source-location)
1006 #:guile %bootstrap-guile)))
82dc2b9a
LC
1007
1008(define-public ld-wrapper
1009 ;; The final `ld' wrapper, which uses the final Guile.
1010 (package (inherit ld-wrapper-boot3)
1011 (name "ld-wrapper")
1012 (inputs `(("guile" ,guile-final)
dfb53ee2
LC
1013 ("bash" ,bash-final)
1014 ,@(fold alist-delete (package-inputs ld-wrapper-boot3)
1015 '("guile" "bash"))))))
82dc2b9a 1016
60f984b2
LC
1017(define-public %final-inputs
1018 ;; Final derivations used as implicit inputs by `gnu-build-system'.
4033bde8 1019 (let ((finalize (cut package-with-explicit-inputs <> %boot4-inputs
3c0670e6 1020 (current-source-location))))
60f984b2
LC
1021 `(,@(map (match-lambda
1022 ((name package)
1023 (list name (finalize package))))
1024 `(("tar" ,tar)
1025 ("gzip" ,gzip)
6818af7b 1026 ("bzip2" ,bzip2)
60f984b2
LC
1027 ("xz" ,xz)
1028 ("diffutils" ,diffutils)
1029 ("patch" ,patch)
1030 ("coreutils" ,coreutils)
1031 ("sed" ,sed)
1032 ("grep" ,grep)
60f984b2
LC
1033 ("findutils" ,findutils)
1034 ("gawk" ,gawk)
321b0996 1035 ("make" ,gnu-make)))
82dc2b9a
LC
1036 ("bash" ,bash-final)
1037 ("ld-wrapper" ,ld-wrapper)
321b0996 1038 ("binutils" ,binutils-final)
60f984b2 1039 ("gcc" ,gcc-final)
321b0996 1040 ("libc" ,glibc-final))))
60f984b2 1041
1722d680 1042;;; base.scm ends here