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