gnu: sudo: Apply workaround to build system for MIPS.
[jackhill/guix/guix.git] / gnu / packages / base.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
5 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages base)
23 #:use-module ((guix licenses)
24 #:select (gpl3+ lgpl2.0+ public-domain))
25 #:use-module (gnu packages)
26 #:use-module (gnu packages acl)
27 #:use-module (gnu packages bash)
28 #:use-module (gnu packages bootstrap)
29 #:use-module (gnu packages compression)
30 #:use-module (gnu packages gcc)
31 #:use-module (gnu packages gawk)
32 #:use-module (gnu packages guile)
33 #:use-module (gnu packages multiprecision)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages linux)
36 #:use-module (gnu packages texinfo)
37 #:use-module (gnu packages pkg-config)
38 #:use-module (guix packages)
39 #:use-module (guix download)
40 #:use-module (guix build-system gnu)
41 #:use-module (guix build-system trivial)
42 #:use-module (guix utils)
43 #:use-module (srfi srfi-1)
44 #:use-module (srfi srfi-26)
45 #:use-module (ice-9 vlist)
46 #:use-module (ice-9 match))
47
48 ;;; Commentary:
49 ;;;
50 ;;; Base packages of the Guix-based GNU user-land software distribution.
51 ;;;
52 ;;; Code:
53
54 (define-public hello
55 (package
56 (name "hello")
57 (version "2.9")
58 (source (origin
59 (method url-fetch)
60 (uri (string-append "mirror://gnu/hello/hello-" version
61 ".tar.gz"))
62 (sha256
63 (base32 "19qy37gkasc4csb1d3bdiz9snn8mir2p3aj0jgzmfv0r2hi7mfzc"))))
64 (build-system gnu-build-system)
65 (synopsis "Hello, GNU world: An example GNU package")
66 (description
67 "GNU Hello prints the message \"Hello, world!\" and then exits. It
68 serves as an example of standard GNU coding practices. As such, it supports
69 command-line arguments, multiple languages, and so on.")
70 (home-page "http://www.gnu.org/software/hello/")
71 (license gpl3+)))
72
73 (define-public grep
74 (package
75 (name "grep")
76 (version "2.20")
77 (source (origin
78 (method url-fetch)
79 (uri (string-append "mirror://gnu/grep/grep-"
80 version ".tar.xz"))
81 (sha256
82 (base32
83 "0rcs0spsxdmh6yz8y4frkqp6f5iw19mdbdl9s2v6956hq0mlbbzh"))))
84 (build-system gnu-build-system)
85 (synopsis "Print lines matching a pattern")
86 (description
87 "grep is a tool for finding text inside files. Text is found by
88 matching a pattern provided by the user in one or many files. The pattern
89 may be provided as a basic or extended regular expression, or as fixed
90 strings. By default, the matching text is simply printed to the screen,
91 however the output can be greatly customized to include, for example, line
92 numbers. GNU grep offers many extensions over the standard utility,
93 including, for example, recursive directory searching.")
94 (license gpl3+)
95 (home-page "http://www.gnu.org/software/grep/")))
96
97 (define-public sed
98 (package
99 (name "sed")
100 (version "4.2.2")
101 (source (origin
102 (method url-fetch)
103 (uri (string-append "mirror://gnu/sed/sed-" version
104 ".tar.bz2"))
105 (sha256
106 (base32
107 "1myvrmh99jsvk7v3d7crm0gcrq51hmmm1r2kjyyci152in1x2j7h"))))
108 (build-system gnu-build-system)
109 (synopsis "Stream editor")
110 (arguments
111 (if (%current-target-system)
112 '()
113 `(#:phases (alist-cons-before
114 'patch-source-shebangs 'patch-test-suite
115 (lambda* (#:key inputs #:allow-other-keys)
116 (let ((bash (assoc-ref inputs "bash")))
117 (patch-makefile-SHELL "testsuite/Makefile.tests")
118 (substitute* '("testsuite/bsd.sh"
119 "testsuite/bug-regex9.c")
120 (("/bin/sh")
121 (string-append bash "/bin/bash")))))
122 %standard-phases))))
123 (description
124 "Sed is a non-interactive, text stream editor. It receives a text
125 input from a file or from standard input and it then applies a series of text
126 editing commands to the stream and prints its output to standard output. It
127 is often used for substituting text patterns in a stream. The GNU
128 implementation offers several extensions over the standard utility.")
129 (license gpl3+)
130 (home-page "http://www.gnu.org/software/sed/")))
131
132 (define-public tar
133 (package
134 (name "tar")
135 (version "1.27.1")
136 (source (origin
137 (method url-fetch)
138 (uri (string-append "mirror://gnu/tar/tar-"
139 version ".tar.bz2"))
140 (sha256
141 (base32
142 "1iip0fk0wqhxb0jcwphz43r4fxkx1y7mznnhmlvr618jhp7b63wv"))))
143 (build-system gnu-build-system)
144 (synopsis "Managing tar archives")
145 (description
146 "Tar provides the ability to create tar archives, as well as the
147 ability to extract, update or list files in an existing archive. It is
148 useful for combining many files into one larger file, while maintaining
149 directory structure and file information such as permissions and
150 creation/modification dates. GNU tar offers many extensions over the
151 standard utility.")
152 (license gpl3+)
153 (home-page "http://www.gnu.org/software/tar/")))
154
155 (define-public patch
156 (package
157 (name "patch")
158 (version "2.7.1")
159 (source (origin
160 (method url-fetch)
161 (uri (string-append "mirror://gnu/patch/patch-"
162 version ".tar.xz"))
163 (sha256
164 (base32
165 "1sqckf560pzwgniy00vcpdv2c9c11s4cmhlm14yqgg8avd3bl94i"))))
166 (build-system gnu-build-system)
167 (native-inputs '()) ; FIXME: needs `ed' for the tests
168 (arguments
169 '(#:tests? #f)
170 ;; TODO: When cross-compiling, add this:
171 ;; '(#:configure-flags '("ac_cv_func_strnlen_working=yes"))
172 )
173 (synopsis "Apply differences to originals, with optional backups")
174 (description
175 "Patch is a program that applies changes to files based on differences
176 laid out as by the program \"diff\". The changes may be applied to one or more
177 files depending on the contents of the diff file. It accepts several
178 different diff formats. It may also be used to revert previously applied
179 differences.")
180 (license gpl3+)
181 (home-page "http://savannah.gnu.org/projects/patch/")))
182
183 (define-public diffutils
184 (package
185 (name "diffutils")
186 (version "3.3")
187 (source (origin
188 (method url-fetch)
189 (uri (string-append "mirror://gnu/diffutils/diffutils-"
190 version ".tar.xz"))
191 (sha256
192 (base32
193 "1761vymxbp4wb5rzjvabhdkskk95pghnn67464byvzb5mfl8jpm2"))))
194 (build-system gnu-build-system)
195 (synopsis "Comparing and merging files")
196 (description
197 "GNU Diffutils is a package containing tools for finding the
198 differences between files. The \"diff\" command is used to show how two files
199 differ, while \"cmp\" shows the offsets and line numbers where they differ.
200 \"diff3\" allows you to compare three files. Finally, \"sdiff\" offers an
201 interactive means to merge two files.")
202 (license gpl3+)
203 (home-page "http://www.gnu.org/software/diffutils/")))
204
205 (define-public findutils
206 (package
207 (name "findutils")
208 (version "4.4.2")
209 (source (origin
210 (method url-fetch)
211 (uri (string-append "mirror://gnu/findutils/findutils-"
212 version ".tar.gz"))
213 (sha256
214 (base32
215 "0amn0bbwqvsvvsh6drfwz20ydc2czk374lzw5kksbh6bf78k4ks3"))
216 (patches (list (search-patch "findutils-absolute-paths.patch")))))
217 (build-system gnu-build-system)
218 (arguments
219 ;; Work around cross-compilation failure.
220 ;; See <http://savannah.gnu.org/bugs/?27299#comment1>.
221 (if (%current-target-system)
222 '(#:configure-flags '("gl_cv_func_wcwidth_works=yes"))
223 '()))
224 (synopsis "Operating on files matching given criteria")
225 (description
226 "Findutils supplies the basic file directory searching utilities of the
227 GNU system. It consists of two primary searching utilities: \"find\"
228 recursively searches for files in a directory according to given criteria and
229 \"locate\" lists files in a database that match a query. Two auxiliary tools
230 are included: \"updatedb\" updates the file name database and \"xargs\" may be
231 used to apply commands with arbitrarily long arguments.")
232 (license gpl3+)
233 (home-page "http://www.gnu.org/software/findutils/")))
234
235 (define-public coreutils
236 (package
237 (name "coreutils")
238 (version "8.22")
239 (source (origin
240 (method url-fetch)
241 (uri (string-append "mirror://gnu/coreutils/coreutils-"
242 version ".tar.xz"))
243 (sha256
244 (base32
245 "04hjzzv434fb8ak3hh3dyhdvg3hqjjwvjmjxqzk1gh2jh6cr8gjv"))
246 (patches (list (search-patch "coreutils-dummy-man.patch")
247 ;; TODO: remove this patch for >= 8.23
248 (search-patch "coreutils-skip-nohup.patch")))))
249 (build-system gnu-build-system)
250 (inputs `(("acl" ,acl) ; TODO: add SELinux
251 ("gmp" ,gmp)))
252 (native-inputs
253 ;; Perl is needed to run tests in native builds, and to run the bundled
254 ;; copy of help2man. However, don't pass it when cross-compiling since
255 ;; that would lead it to try to run programs to get their '--help' output
256 ;; for help2man.
257 (if (%current-target-system)
258 '()
259 `(("perl" ,perl))))
260 (outputs '("out" "debug"))
261 (arguments
262 `(#:parallel-build? #f ; help2man may be called too early
263 #:phases (alist-cons-before
264 'build 'patch-shell-references
265 (lambda* (#:key inputs #:allow-other-keys)
266 (let ((bash (assoc-ref inputs "bash")))
267 ;; 'split' uses either $SHELL or /bin/sh. Set $SHELL so
268 ;; that tests pass, since /bin/sh isn't in the chroot.
269 (setenv "SHELL" (which "sh"))
270
271 (substitute* (find-files "gnulib-tests" "\\.c$")
272 (("/bin/sh")
273 (format #f "~a/bin/sh" bash)))
274 (substitute* (find-files "tests" "\\.sh$")
275 (("#!/bin/sh")
276 (format #f "#!~a/bin/sh" bash)))))
277 %standard-phases)))
278 (synopsis "Core GNU utilities (file, text, shell)")
279 (description
280 "GNU Coreutils includes all of the basic command-line tools that are
281 expected in a POSIX system. These provide the basic file, shell and text
282 manipulation functions of the GNU system. Most of these tools offer extended
283 functionality beyond that which is outlined in the POSIX standard.")
284 (license gpl3+)
285 (home-page "http://www.gnu.org/software/coreutils/")))
286
287 (define-public gnu-make
288 (package
289 (name "make")
290 (version "4.0")
291 (source (origin
292 (method url-fetch)
293 (uri (string-append "mirror://gnu/make/make-" version
294 ".tar.bz2"))
295 (sha256
296 (base32
297 "1nyvn8mknw0mf7727lprva3lisl1y0n03lvar342rrpdmz3qc1p6"))
298 (patches (list (search-patch "make-impure-dirs.patch")))))
299 (build-system gnu-build-system)
300 (native-inputs `(("pkg-config", pkg-config))) ; to detect Guile
301 (inputs `(("guile" ,guile-2.0)))
302 (outputs '("out" "debug"))
303 (arguments
304 '(#:phases (alist-cons-before
305 'build 'set-default-shell
306 (lambda* (#:key inputs #:allow-other-keys)
307 ;; Change the default shell from /bin/sh.
308 (let ((bash (assoc-ref inputs "bash")))
309 (substitute* "job.c"
310 (("default_shell\\[\\] =.*$")
311 (format #f "default_shell[] = \"~a/bin/bash\";\n"
312 bash)))))
313 %standard-phases)))
314 (synopsis "Remake files automatically")
315 (description
316 "Make is a program that is used to control the production of
317 executables or other files from their source files. The process is
318 controlled from a Makefile, in which the developer specifies how each file is
319 generated from its source. It has powerful dependency resolution and the
320 ability to determine when files have to be regenerated after their sources
321 change. GNU make offers many powerful extensions over the standard utility.")
322 (license gpl3+)
323 (home-page "http://www.gnu.org/software/make/")))
324
325 (define-public binutils
326 (package
327 (name "binutils")
328 (version "2.24")
329 (source (origin
330 (method url-fetch)
331 (uri (string-append "mirror://gnu/binutils/binutils-"
332 version ".tar.bz2"))
333 (sha256
334 (base32
335 "0ds1y7qa0xqihw4ihnsgg6bxanmb228r228ddvwzgrv4jszcbs75"))
336 (patches (list (search-patch "binutils-ld-new-dtags.patch")
337 (search-patch "binutils-loongson-workaround.patch")))))
338 (build-system gnu-build-system)
339
340 ;; TODO: Add dependency on zlib + those for Gold.
341 (arguments
342 `(#:configure-flags '(;; Add `-static-libgcc' to not retain a dependency
343 ;; on GCC when bootstrapping.
344 "LDFLAGS=-static-libgcc"
345
346 ;; Don't search under /usr/lib & co.
347 "--with-lib-path=/no-ld-lib-path"
348
349 ;; Glibc 2.17 has a "comparison of unsigned
350 ;; expression >= 0 is always true" in wchar.h.
351 "--disable-werror"
352
353 ;; Install BFD. It ends up in a hidden directory,
354 ;; but it's here.
355 "--enable-install-libbfd"
356
357 ;; Make sure 'ar' and 'ranlib' produce archives in a
358 ;; deterministic fashion.
359 "--enable-deterministic-archives")))
360
361 (synopsis "Binary utilities: bfd gas gprof ld")
362 (description
363 "GNU Binutils is a collection of tools for working with binary files.
364 Perhaps the most notable are \"ld\", a linker, and \"as\", an assembler. Other
365 tools include programs to display binary profiling information, list the
366 strings in a binary file, and utilities for working with archives. The \"bfd\"
367 library for working with executable and object formats is also included.")
368 (license gpl3+)
369 (home-page "http://www.gnu.org/software/binutils/")))
370
371 (define-public glibc
372 (package
373 (name "glibc")
374 (version "2.19")
375 (source (origin
376 (method url-fetch)
377 (uri (string-append "mirror://gnu/glibc/glibc-"
378 version ".tar.xz"))
379 (sha256
380 (base32
381 "18m2dssd6ja5arxmdxinc90xvpqcsnqjfwmjl2as07j0i3srff9d"))
382 (snippet
383 ;; Disable 'ldconfig' and /etc/ld.so.cache. The latter is
384 ;; required on LFS distros to avoid loading the distro's libc.so
385 ;; instead of ours.
386 '(substitute* "sysdeps/unix/sysv/linux/configure"
387 (("use_ldconfig=yes")
388 "use_ldconfig=no")))
389 (modules '((guix build utils)))
390 (patches (list (search-patch "glibc-ldd-x86_64.patch")))))
391 (build-system gnu-build-system)
392
393 ;; Glibc's <limits.h> refers to <linux/limit.h>, for instance, so glibc
394 ;; users should automatically pull Linux headers as well.
395 (propagated-inputs `(("linux-headers" ,linux-libre-headers)))
396
397 ;; Store the locales separately (~100 MiB). Note that "out" retains a
398 ;; reference to them anyway, so there's no space savings here.
399 ;; TODO: Eventually we may want to add a $LOCALE_ARCHIVE search path like
400 ;; Nixpkgs does.
401 (outputs '("out" "locales" "debug"))
402
403 (arguments
404 `(#:out-of-source? #t
405 #:configure-flags
406 (list "--enable-add-ons"
407 "--sysconfdir=/etc"
408 (string-append "--localedir=" (assoc-ref %outputs "locales")
409 "/share/locale")
410
411 ;; `--localedir' is not honored, so work around it.
412 ;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
413 (string-append "libc_cv_localedir="
414 (assoc-ref %outputs "locales")
415 "/share/locale")
416
417 (string-append "--with-headers="
418 (assoc-ref %build-inputs "linux-headers")
419 "/include")
420
421 ;; The default is to assume a 2.4 Linux interface, but we'll
422 ;; always use something newer. See "kernel-features.h" in the
423 ;; GNU libc for details.
424 "--enable-kernel=2.6.30"
425
426 ;; Use our Bash instead of /bin/sh.
427 (string-append "BASH_SHELL="
428 (assoc-ref %build-inputs "bash")
429 "/bin/bash")
430
431 ;; XXX: Work around "undefined reference to `__stack_chk_guard'".
432 "libc_cv_ssp=no")
433
434 #:tests? #f ; XXX
435 #:phases (alist-cons-before
436 'configure 'pre-configure
437 (lambda* (#:key inputs outputs #:allow-other-keys)
438 (let* ((out (assoc-ref outputs "out"))
439 (bin (string-append out "/bin")))
440 ;; Use `pwd', not `/bin/pwd'.
441 (substitute* "configure"
442 (("/bin/pwd") "pwd"))
443
444 ;; Install the rpc data base file under `$out/etc/rpc'.
445 ;; FIXME: Use installFlags = [ "sysconfdir=$(out)/etc" ];
446 (substitute* "sunrpc/Makefile"
447 (("^\\$\\(inst_sysconfdir\\)/rpc(.*)$" _ suffix)
448 (string-append out "/etc/rpc" suffix "\n"))
449 (("^install-others =.*$")
450 (string-append "install-others = " out "/etc/rpc\n")))
451
452 (substitute* "Makeconfig"
453 ;; According to
454 ;; <http://www.linuxfromscratch.org/lfs/view/stable/chapter05/glibc.html>,
455 ;; linking against libgcc_s is not needed with GCC
456 ;; 4.7.1.
457 ((" -lgcc_s") ""))
458
459 ;; Copy a statically-linked Bash in the output, with
460 ;; no references to other store paths.
461 (mkdir-p bin)
462 (copy-file (string-append (assoc-ref inputs "static-bash")
463 "/bin/bash")
464 (string-append bin "/bash"))
465 (remove-store-references (string-append bin "/bash"))
466 (chmod (string-append bin "/bash") #o555)
467
468 ;; Keep a symlink, for `patch-shebang' resolution.
469 (with-directory-excursion bin
470 (symlink "bash" "sh"))
471
472 ;; Have `system' use that Bash.
473 (substitute* "sysdeps/posix/system.c"
474 (("#define[[:blank:]]+SHELL_PATH.*$")
475 (format #f "#define SHELL_PATH \"~a/bin/bash\"\n"
476 out)))
477
478 ;; Same for `popen'.
479 (substitute* "libio/iopopen.c"
480 (("/bin/sh")
481 (string-append out "/bin/bash")))
482
483 ;; Make sure we don't retain a reference to the
484 ;; bootstrap Perl.
485 (substitute* "malloc/mtrace.pl"
486 (("^#!.*")
487 ;; The shebang can be omitted, because there's the
488 ;; "bilingual" eval/exec magic at the top of the file.
489 "")
490 (("exec @PERL@")
491 "exec perl"))))
492 (alist-cons-after
493 'install 'install-locales
494 (lambda _
495 (zero? (system* "make" "localedata/install-locales")))
496 %standard-phases))))
497
498 (inputs `(("static-bash" ,(static-package bash-light))))
499
500 ;; To build the manual, we need Texinfo and Perl.
501 (native-inputs `(("texinfo" ,texinfo)
502 ("perl" ,perl)))
503
504 (synopsis "The GNU C Library")
505 (description
506 "Any Unix-like operating system needs a C library: the library which
507 defines the \"system calls\" and other basic facilities such as open, malloc,
508 printf, exit...
509
510 The GNU C library is used as the C library in the GNU system and most systems
511 with the Linux kernel.")
512 (license lgpl2.0+)
513 (home-page "http://www.gnu.org/software/libc/")))
514
515 (define-public tzdata
516 (package
517 (name "tzdata")
518 (version "2014a")
519 (source (origin
520 (method url-fetch)
521 (uri (string-append
522 "http://www.iana.org/time-zones/repository/releases/tzdata"
523 version ".tar.gz"))
524 (sha256
525 (base32
526 "1cg843ajz4g16axpz56zvalwsbp1s764na2bk4fb44ayx162bzvw"))))
527 (build-system gnu-build-system)
528 (arguments
529 '(#:tests? #f
530 #:make-flags (let ((out (assoc-ref %outputs "out"))
531 (tmp (getenv "TMPDIR")))
532 (list (string-append "TOPDIR=" out)
533 (string-append "TZDIR=" out "/share/zoneinfo")
534
535 ;; Discard zic, dump, and tzselect, already
536 ;; provided by glibc.
537 (string-append "ETCDIR=" tmp "/etc")
538
539 ;; Likewise for the C library routines.
540 (string-append "LIBDIR=" tmp "/lib")
541 (string-append "MANDIR=" tmp "/man")
542
543 "AWK=awk"
544 "CC=gcc"))
545 #:modules ((guix build utils)
546 (guix build gnu-build-system)
547 (srfi srfi-1))
548 #:phases
549 (alist-replace
550 'unpack
551 (lambda* (#:key source inputs #:allow-other-keys)
552 (and (zero? (system* "tar" "xvf" source))
553 (zero? (system* "tar" "xvf" (assoc-ref inputs "tzcode")))))
554 (alist-cons-after
555 'install 'post-install
556 (lambda* (#:key outputs #:allow-other-keys)
557 ;; Move data in the right place.
558 (let ((out (assoc-ref outputs "out")))
559 (copy-recursively (string-append out "/share/zoneinfo-posix")
560 (string-append out "/share/zoneinfo/posix"))
561 (copy-recursively (string-append out "/share/zoneinfo-leaps")
562 (string-append out "/share/zoneinfo/right"))
563 (delete-file-recursively (string-append out "/share/zoneinfo-posix"))
564 (delete-file-recursively (string-append out "/share/zoneinfo-leaps"))))
565 (alist-delete 'configure %standard-phases)))))
566 (inputs `(("tzcode" ,(origin
567 (method url-fetch)
568 (uri (string-append
569 "http://www.iana.org/time-zones/repository/releases/tzcode"
570 version ".tar.gz"))
571 (sha256
572 (base32
573 "1xfkqi1q8cnxqbv8azdj5pqlzhkjz6xag09f1z0s8rxi86jkpf85"))))))
574 (home-page "http://www.iana.org/time-zones")
575 (synopsis "Database of current and historical time zones")
576 (description "The Time Zone Database (often called tz or zoneinfo)
577 contains code and data that represent the history of local time for many
578 representative locations around the globe. It is updated periodically to
579 reflect changes made by political bodies to time zone boundaries, UTC offsets,
580 and daylight-saving rules.")
581 (license public-domain)))
582
583 \f
584 ;;;
585 ;;; Bootstrap packages.
586 ;;;
587
588 (define gnu-make-boot0
589 (package-with-bootstrap-guile
590 (package (inherit gnu-make)
591 (name "make-boot0")
592 (location (source-properties->location (current-source-location)))
593 (arguments
594 `(#:guile ,%bootstrap-guile
595 #:implicit-inputs? #f
596 #:tests? #f ; cannot run "make check"
597 ,@(substitute-keyword-arguments (package-arguments gnu-make)
598 ((#:phases phases)
599 `(alist-replace
600 'build (lambda _
601 ;; Don't attempt to build 'guile.c' since we don't
602 ;; have Guile here.
603 (substitute* "build.sh"
604 (("guile\\.\\$\\{OBJEXT\\}") ""))
605 (zero? (system* "./build.sh")))
606 (alist-replace
607 'install (lambda* (#:key outputs #:allow-other-keys)
608 (let* ((out (assoc-ref outputs "out"))
609 (bin (string-append out "/bin")))
610 (mkdir-p bin)
611 (copy-file "make"
612 (string-append bin "/make"))))
613 ,phases))))))
614 (native-inputs '()) ; no need for 'pkg-config'
615 (inputs %bootstrap-inputs))))
616
617 (define diffutils-boot0
618 (package-with-bootstrap-guile
619 (let ((p (package-with-explicit-inputs diffutils
620 `(("make" ,gnu-make-boot0)
621 ,@%bootstrap-inputs)
622 #:guile %bootstrap-guile)))
623 (package (inherit p)
624 (location (source-properties->location (current-source-location)))
625 (arguments `(#:tests? #f ; the test suite needs diffutils
626 ,@(package-arguments p)))))))
627
628 (define findutils-boot0
629 (package-with-bootstrap-guile
630 (package-with-explicit-inputs findutils
631 `(("make" ,gnu-make-boot0)
632 ("diffutils" ,diffutils-boot0) ; for tests
633 ,@%bootstrap-inputs)
634 (current-source-location)
635 #:guile %bootstrap-guile)))
636
637
638 (define %boot0-inputs
639 `(("make" ,gnu-make-boot0)
640 ("diffutils" ,diffutils-boot0)
641 ("findutils" ,findutils-boot0)
642 ,@%bootstrap-inputs))
643
644 (define* (nix-system->gnu-triplet
645 #:optional (system (%current-system)) (vendor "unknown"))
646 "Return an a guess of the GNU triplet corresponding to Nix system
647 identifier SYSTEM."
648 (let* ((dash (string-index system #\-))
649 (arch (substring system 0 dash))
650 (os (substring system (+ 1 dash))))
651 (string-append arch
652 "-" vendor "-"
653 (if (string=? os "linux")
654 "linux-gnu"
655 os))))
656
657 (define* (boot-triplet #:optional (system (%current-system)))
658 ;; Return the triplet used to create the cross toolchain needed in the
659 ;; first bootstrapping stage.
660 (nix-system->gnu-triplet system "guix"))
661
662 ;; Following Linux From Scratch, build a cross-toolchain in stage 0. That
663 ;; toolchain actually targets the same OS and arch, but it has the advantage
664 ;; of being independent of the libc and tools in %BOOTSTRAP-INPUTS, since
665 ;; GCC-BOOT0 (below) is built without any reference to the target libc.
666
667 (define binutils-boot0
668 (package-with-bootstrap-guile
669 (package (inherit binutils)
670 (name "binutils-cross-boot0")
671 (arguments
672 `(#:guile ,%bootstrap-guile
673 #:implicit-inputs? #f
674 ,@(substitute-keyword-arguments (package-arguments binutils)
675 ((#:configure-flags cf)
676 `(cons ,(string-append "--target=" (boot-triplet))
677 ,cf)))))
678 (inputs %boot0-inputs))))
679
680 (define gcc-boot0
681 (package-with-bootstrap-guile
682 (package (inherit gcc-4.8)
683 (name "gcc-cross-boot0")
684 (arguments
685 `(#:guile ,%bootstrap-guile
686 #:implicit-inputs? #f
687 #:modules ((guix build gnu-build-system)
688 (guix build utils)
689 (ice-9 regex)
690 (srfi srfi-1)
691 (srfi srfi-26))
692 ,@(substitute-keyword-arguments (package-arguments gcc-4.8)
693 ((#:configure-flags flags)
694 `(append (list ,(string-append "--target=" (boot-triplet))
695
696 ;; No libc yet.
697 "--without-headers"
698
699 ;; Disable features not needed at this stage.
700 "--disable-shared"
701 "--enable-languages=c,c++"
702
703 ;; libstdc++ cannot be built at this stage
704 ;; ("Link tests are not allowed after
705 ;; GCC_NO_EXECUTABLES.").
706 "--disable-libstdc++-v3"
707
708 "--disable-threads"
709 "--disable-libmudflap"
710 "--disable-libatomic"
711 "--disable-libsanitizer"
712 "--disable-libitm"
713 "--disable-libgomp"
714 "--disable-libssp"
715 "--disable-libquadmath"
716 "--disable-decimal-float")
717 (remove (cut string-match "--enable-languages.*" <>)
718 ,flags)))
719 ((#:phases phases)
720 `(alist-cons-after
721 'unpack 'unpack-gmp&co
722 (lambda* (#:key inputs #:allow-other-keys)
723 (let ((gmp (assoc-ref %build-inputs "gmp-source"))
724 (mpfr (assoc-ref %build-inputs "mpfr-source"))
725 (mpc (assoc-ref %build-inputs "mpc-source")))
726
727 ;; To reduce the set of pre-built bootstrap inputs, build
728 ;; GMP & co. from GCC.
729 (for-each (lambda (source)
730 (or (zero? (system* "tar" "xvf" source))
731 (error "failed to unpack tarball"
732 source)))
733 (list gmp mpfr mpc))
734
735 ;; Create symlinks like `gmp' -> `gmp-x.y.z'.
736 ,@(map (lambda (lib)
737 ;; Drop trailing letters, as gmp-6.0.0a unpacks
738 ;; into gmp-6.0.0.
739 `(symlink ,(string-trim-right
740 (package-full-name lib)
741 char-set:letter)
742 ,(package-name lib)))
743 (list gmp mpfr mpc))))
744 (alist-cons-after
745 'install 'symlink-libgcc_eh
746 (lambda* (#:key outputs #:allow-other-keys)
747 (let ((out (assoc-ref outputs "lib")))
748 ;; Glibc wants to link against libgcc_eh, so provide
749 ;; it.
750 (with-directory-excursion
751 (string-append out "/lib/gcc/"
752 ,(boot-triplet)
753 "/" ,(package-version gcc-4.8))
754 (symlink "libgcc.a" "libgcc_eh.a"))))
755 ,phases))))))
756
757 (inputs `(("gmp-source" ,(package-source gmp))
758 ("mpfr-source" ,(package-source mpfr))
759 ("mpc-source" ,(package-source mpc))
760 ("binutils-cross" ,binutils-boot0)
761
762 ;; Call it differently so that the builder can check whether
763 ;; the "libc" input is #f.
764 ("libc-native" ,@(assoc-ref %boot0-inputs "libc"))
765 ,@(alist-delete "libc" %boot0-inputs)))
766
767 ;; No need for Texinfo at this stage.
768 (native-inputs (alist-delete "texinfo"
769 (package-native-inputs gcc-4.8))))))
770
771 (define perl-boot0
772 (package-with-bootstrap-guile
773 (package-with-explicit-inputs perl
774 %boot0-inputs
775 (current-source-location)
776 #:guile %bootstrap-guile)))
777
778 (define (linux-libre-headers-boot0)
779 "Return Linux-Libre header files for the bootstrap environment."
780 ;; Note: this is wrapped in a thunk to nicely handle circular dependencies
781 ;; between (gnu packages linux) and this module.
782 (package-with-bootstrap-guile
783 (package (inherit linux-libre-headers)
784 (arguments `(#:guile ,%bootstrap-guile
785 #:implicit-inputs? #f
786 ,@(package-arguments linux-libre-headers)))
787 (native-inputs
788 `(("perl" ,perl-boot0)
789 ,@%boot0-inputs)))))
790
791 (define texinfo-boot0
792 ;; Texinfo used to build libc's manual.
793 ;; We build without ncurses because it fails to build at this stage, and
794 ;; because we don't need the stand-alone Info reader.
795 ;; Also, use %BOOT0-INPUTS to avoid building Perl once more.
796 (let ((texinfo (package (inherit texinfo)
797 (inputs (alist-delete "ncurses" (package-inputs texinfo))))))
798 (package-with-bootstrap-guile
799 (package-with-explicit-inputs texinfo %boot0-inputs
800 (current-source-location)
801 #:guile %bootstrap-guile))))
802
803 (define %boot1-inputs
804 ;; 2nd stage inputs.
805 `(("gcc" ,gcc-boot0)
806 ("binutils-cross" ,binutils-boot0)
807
808 ;; Keep "binutils" here because the cross-gcc invokes `as', not the
809 ;; cross-`as'.
810 ,@%boot0-inputs))
811
812 (define glibc-final-with-bootstrap-bash
813 ;; The final libc, "cross-built". If everything went well, the resulting
814 ;; store path has no dependencies. Actually, the really-final libc is
815 ;; built just below; the only difference is that this one uses the
816 ;; bootstrap Bash.
817 (package-with-bootstrap-guile
818 (package (inherit glibc)
819 (name "glibc-intermediate")
820 (arguments
821 `(#:guile ,%bootstrap-guile
822 #:implicit-inputs? #f
823
824 ,@(substitute-keyword-arguments (package-arguments glibc)
825 ((#:configure-flags flags)
826 `(append (list ,(string-append "--host=" (boot-triplet))
827 ,(string-append "--build="
828 (nix-system->gnu-triplet))
829
830 ;; Build Sun/ONC RPC support. In particular,
831 ;; install rpc/*.h.
832 "--enable-obsolete-rpc")
833 ,flags))
834 ((#:phases phases)
835 `(alist-cons-before
836 'configure 'pre-configure
837 (lambda* (#:key inputs #:allow-other-keys)
838 ;; Don't clobber CPATH with the bootstrap libc.
839 (setenv "NATIVE_CPATH" (getenv "CPATH"))
840 (unsetenv "CPATH")
841
842 ;; 'rpcgen' needs native libc headers to be built.
843 (substitute* "sunrpc/Makefile"
844 (("sunrpc-CPPFLAGS =.*" all)
845 (string-append "CPATH = $(NATIVE_CPATH)\n"
846 "export CPATH\n"
847 all "\n"))))
848 ,phases)))))
849 (propagated-inputs `(("linux-headers" ,(linux-libre-headers-boot0))))
850 (native-inputs
851 `(("texinfo" ,texinfo-boot0)
852 ("perl" ,perl-boot0)))
853 (inputs
854 `(;; The boot inputs. That includes the bootstrap libc. We don't want
855 ;; it in $CPATH, hence the 'pre-configure' phase above.
856 ,@%boot1-inputs
857
858 ;; A native GCC is needed to build `cross-rpcgen'.
859 ("native-gcc" ,@(assoc-ref %boot0-inputs "gcc"))
860
861 ;; Here, we use the bootstrap Bash, which is not satisfactory
862 ;; because we don't want to depend on bootstrap tools.
863 ("static-bash" ,@(assoc-ref %boot0-inputs "bash")))))))
864
865 (define (cross-gcc-wrapper gcc binutils glibc bash)
866 "Return a wrapper for the pseudo-cross toolchain GCC/BINUTILS/GLIBC
867 that makes it available under the native tool names."
868 (package (inherit gcc-4.8)
869 (name (string-append (package-name gcc) "-wrapped"))
870 (source #f)
871 (build-system trivial-build-system)
872 (outputs '("out"))
873 (arguments
874 `(#:guile ,%bootstrap-guile
875 #:modules ((guix build utils))
876 #:builder (begin
877 (use-modules (guix build utils))
878
879 (let* ((binutils (assoc-ref %build-inputs "binutils"))
880 (gcc (assoc-ref %build-inputs "gcc"))
881 (libc (assoc-ref %build-inputs "libc"))
882 (bash (assoc-ref %build-inputs "bash"))
883 (out (assoc-ref %outputs "out"))
884 (bindir (string-append out "/bin"))
885 (triplet ,(boot-triplet)))
886 (define (wrap-program program)
887 ;; GCC-BOOT0 is a libc-less cross-compiler, so it
888 ;; needs to be told where to find the crt files and
889 ;; the dynamic linker.
890 (call-with-output-file program
891 (lambda (p)
892 (format p "#!~a/bin/bash
893 exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%"
894 bash
895 gcc triplet program
896 libc libc
897 ,(glibc-dynamic-linker))))
898
899 (chmod program #o555))
900
901 (mkdir-p bindir)
902 (with-directory-excursion bindir
903 (for-each (lambda (tool)
904 (symlink (string-append binutils "/bin/"
905 triplet "-" tool)
906 tool))
907 '("ar" "ranlib"))
908 (for-each wrap-program '("gcc" "g++")))))))
909 (native-inputs
910 `(("binutils" ,binutils)
911 ("gcc" ,gcc)
912 ("libc" ,glibc)
913 ("bash" ,bash)))
914 (inputs '())))
915
916 (define static-bash-for-glibc
917 ;; A statically-linked Bash to be embedded in GLIBC-FINAL, for use by
918 ;; system(3) & co.
919 (let* ((gcc (cross-gcc-wrapper gcc-boot0 binutils-boot0
920 glibc-final-with-bootstrap-bash
921 (car (assoc-ref %boot1-inputs "bash"))))
922 (bash (package (inherit bash-light)
923 (arguments
924 `(#:guile ,%bootstrap-guile
925 ,@(package-arguments bash-light))))))
926 (package-with-bootstrap-guile
927 (package-with-explicit-inputs (static-package bash)
928 `(("gcc" ,gcc)
929 ("libc" ,glibc-final-with-bootstrap-bash)
930 ,@(fold alist-delete %boot1-inputs
931 '("gcc" "libc")))
932 (current-source-location)))))
933
934 (define-public glibc-final
935 ;; The final glibc, which embeds the statically-linked Bash built above.
936 (package (inherit glibc-final-with-bootstrap-bash)
937 (name "glibc")
938 (inputs `(("static-bash" ,static-bash-for-glibc)
939 ,@(alist-delete
940 "static-bash"
941 (package-inputs glibc-final-with-bootstrap-bash))))
942
943 ;; The final libc only refers to itself, but the 'debug' output contains
944 ;; references to GCC-BOOT0 and to the Linux headers. XXX: Would be great
945 ;; if 'allowed-references' were per-output.
946 (arguments
947 `(#:allowed-references
948 ,(cons* `(,gcc-boot0 "lib") (linux-libre-headers-boot0)
949 (package-outputs glibc-final-with-bootstrap-bash))
950
951 ,@(package-arguments glibc-final-with-bootstrap-bash)))))
952
953 (define gcc-boot0-wrapped
954 ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the
955 ;; non-cross names.
956 (cross-gcc-wrapper gcc-boot0 binutils-boot0 glibc-final
957 (car (assoc-ref %boot1-inputs "bash"))))
958
959 (define %boot2-inputs
960 ;; 3rd stage inputs.
961 `(("libc" ,glibc-final)
962 ("gcc" ,gcc-boot0-wrapped)
963 ,@(fold alist-delete %boot1-inputs '("libc" "gcc"))))
964
965 (define binutils-final
966 (package-with-bootstrap-guile
967 (package (inherit binutils)
968 (arguments
969 `(#:guile ,%bootstrap-guile
970 #:implicit-inputs? #f
971 #:allowed-references ("out" ,glibc-final)
972 ,@(package-arguments binutils)))
973 (inputs %boot2-inputs))))
974
975 (define libstdc++
976 ;; Intermediate libstdc++ that will allow us to build the final GCC
977 ;; (remember that GCC-BOOT0 cannot build libstdc++.)
978 (package-with-bootstrap-guile
979 (package (inherit gcc-4.8)
980 (name "libstdc++")
981 (arguments
982 `(#:guile ,%bootstrap-guile
983 #:implicit-inputs? #f
984
985 #:out-of-source? #t
986 #:phases (alist-cons-before
987 'configure 'chdir
988 (lambda _
989 (chdir "libstdc++-v3"))
990 %standard-phases)
991 #:configure-flags `("--disable-shared"
992 "--disable-libstdcxx-threads"
993 "--disable-libstdcxx-pch"
994 ,(string-append "--with-gxx-include-dir="
995 (assoc-ref %outputs "out")
996 "/include"
997 ;; "/include/c++/"
998 ;; ,(package-version gcc-4.8)
999 ))))
1000 (outputs '("out"))
1001 (inputs %boot2-inputs)
1002 (native-inputs '())
1003 (propagated-inputs '())
1004 (synopsis "GNU C++ standard library (intermediate)"))))
1005
1006 (define-public gcc-final
1007 ;; The final GCC.
1008 (package (inherit gcc-boot0)
1009 (name "gcc")
1010 (location (source-properties->location (current-source-location)))
1011 (arguments
1012 `(#:guile ,%bootstrap-guile
1013 #:implicit-inputs? #f
1014
1015 #:allowed-references ("out" "lib" ,glibc-final)
1016
1017 ;; Build again GMP & co. within GCC's build process, because it's hard
1018 ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus
1019 ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.)
1020 ,@(substitute-keyword-arguments (package-arguments gcc-boot0)
1021 ((#:configure-flags boot-flags)
1022 (let loop ((args (package-arguments gcc-4.8)))
1023 (match args
1024 ((#:configure-flags normal-flags _ ...)
1025 normal-flags)
1026 ((_ rest ...)
1027 (loop rest)))))
1028 ((#:make-flags flags)
1029 ;; Since $LIBRARY_PATH and $CPATH are not honored, add the
1030 ;; relevant flags.
1031 `(cons (string-append "CPPFLAGS=-I"
1032 (assoc-ref %build-inputs "libstdc++")
1033 "/include")
1034 (map (lambda (flag)
1035 (if (string-prefix? "LDFLAGS=" flag)
1036 (string-append flag " -L"
1037 (assoc-ref %build-inputs "libstdc++")
1038 "/lib")
1039 flag))
1040 ,flags)))
1041 ((#:phases phases)
1042 `(alist-delete 'symlink-libgcc_eh ,phases)))))
1043
1044 ;; This time we want Texinfo, so we get the manual.
1045 (native-inputs `(("texinfo" ,texinfo-boot0)
1046 ,@(package-native-inputs gcc-boot0)))
1047
1048 (inputs `(("gmp-source" ,(package-source gmp))
1049 ("mpfr-source" ,(package-source mpfr))
1050 ("mpc-source" ,(package-source mpc))
1051 ("binutils" ,binutils-final)
1052 ("libstdc++" ,libstdc++)
1053 ,@%boot2-inputs))))
1054
1055 (define ld-wrapper-boot3
1056 ;; A linker wrapper that uses the bootstrap Guile.
1057 (package
1058 (name "ld-wrapper-boot3")
1059 (version "0")
1060 (source #f)
1061 (build-system trivial-build-system)
1062 (inputs `(("binutils" ,binutils-final)
1063 ("guile" ,%bootstrap-guile)
1064 ("bash" ,@(assoc-ref %boot2-inputs "bash"))
1065 ("wrapper" ,(search-path %load-path
1066 "gnu/packages/ld-wrapper.scm"))))
1067 (arguments
1068 `(#:guile ,%bootstrap-guile
1069 #:modules ((guix build utils))
1070 #:builder (begin
1071 (use-modules (guix build utils)
1072 (system base compile))
1073
1074 (let* ((out (assoc-ref %outputs "out"))
1075 (bin (string-append out "/bin"))
1076 (ld (string-append bin "/ld"))
1077 (go (string-append bin "/ld.go")))
1078
1079 (setvbuf (current-output-port) _IOLBF)
1080 (format #t "building ~s/bin/ld wrapper in ~s~%"
1081 (assoc-ref %build-inputs "binutils")
1082 out)
1083
1084 (mkdir-p bin)
1085 (copy-file (assoc-ref %build-inputs "wrapper") ld)
1086 (substitute* ld
1087 (("@GUILE@")
1088 (string-append (assoc-ref %build-inputs "guile")
1089 "/bin/guile"))
1090 (("@BASH@")
1091 (string-append (assoc-ref %build-inputs "bash")
1092 "/bin/bash"))
1093 (("@LD@")
1094 (string-append (assoc-ref %build-inputs "binutils")
1095 "/bin/ld")))
1096 (chmod ld #o555)
1097 (compile-file ld #:output-file go)))))
1098 (synopsis "The linker wrapper")
1099 (description
1100 "The linker wrapper (or `ld-wrapper') wraps the linker to add any
1101 missing `-rpath' flags, and to detect any misuse of libraries outside of the
1102 store.")
1103 (home-page #f)
1104 (license gpl3+)))
1105
1106 (define %boot3-inputs
1107 ;; 4th stage inputs.
1108 `(("gcc" ,gcc-final)
1109 ("ld-wrapper" ,ld-wrapper-boot3)
1110 ,@(alist-delete "gcc" %boot2-inputs)))
1111
1112 (define bash-final
1113 ;; Link with `-static-libgcc' to make sure we don't retain a reference
1114 ;; to the bootstrap GCC.
1115 (package-with-bootstrap-guile
1116 (package-with-explicit-inputs (static-libgcc-package bash)
1117 %boot3-inputs
1118 (current-source-location)
1119 #:guile %bootstrap-guile)))
1120
1121 (define %boot4-inputs
1122 ;; Now use the final Bash.
1123 `(("bash" ,bash-final)
1124 ,@(alist-delete "bash" %boot3-inputs)))
1125
1126 (define-public guile-final
1127 (package-with-bootstrap-guile
1128 (package-with-explicit-inputs guile-2.0/fixed
1129 %boot4-inputs
1130 (current-source-location)
1131 #:guile %bootstrap-guile)))
1132
1133 (define gnu-make-final
1134 ;; The final GNU Make, which uses the final Guile.
1135 (package-with-bootstrap-guile
1136 (package-with-explicit-inputs gnu-make
1137 `(("guile" ,guile-final)
1138 ,@%boot4-inputs)
1139 (current-source-location))))
1140
1141 (define-public ld-wrapper
1142 ;; The final `ld' wrapper, which uses the final Guile.
1143 (package (inherit ld-wrapper-boot3)
1144 (name "ld-wrapper")
1145 (inputs `(("guile" ,guile-final)
1146 ("bash" ,bash-final)
1147 ,@(fold alist-delete (package-inputs ld-wrapper-boot3)
1148 '("guile" "bash"))))))
1149
1150 (define coreutils-final
1151 ;; The final Coreutils. Treat them specially because some packages, such as
1152 ;; Findutils, keep a reference to the Coreutils they were built with.
1153 (package-with-bootstrap-guile
1154 (package-with-explicit-inputs coreutils
1155 %boot4-inputs
1156 (current-source-location)
1157
1158 ;; Use the final Guile, linked against the
1159 ;; final libc with working iconv, so that
1160 ;; 'substitute*' works well when touching
1161 ;; test files in Gettext.
1162 #:guile guile-final)))
1163
1164 (define grep-final
1165 ;; The final grep. Gzip holds a reference to it (via zgrep), so it must be
1166 ;; built before gzip.
1167 (package-with-bootstrap-guile
1168 (package-with-explicit-inputs grep
1169 %boot4-inputs
1170 (current-source-location)
1171 #:guile guile-final)))
1172
1173 (define %boot5-inputs
1174 ;; Now use the final Coreutils.
1175 `(("coreutils" ,coreutils-final)
1176 ("grep" ,grep-final)
1177 ,@%boot4-inputs))
1178
1179 (define-public %final-inputs
1180 ;; Final derivations used as implicit inputs by 'gnu-build-system'. We
1181 ;; still use 'package-with-bootstrap-guile' so that the bootstrap tools are
1182 ;; used for origins that have patches, thereby avoiding circular
1183 ;; dependencies.
1184 (let ((finalize (compose package-with-bootstrap-guile
1185 (cut package-with-explicit-inputs <> %boot5-inputs
1186 (current-source-location)))))
1187 `(,@(map (match-lambda
1188 ((name package)
1189 (list name (finalize package))))
1190 `(("tar" ,tar)
1191 ("gzip" ,gzip)
1192 ("bzip2" ,bzip2)
1193 ("xz" ,xz)
1194 ("diffutils" ,diffutils)
1195 ("patch" ,patch)
1196 ("sed" ,sed)
1197 ("findutils" ,findutils)
1198 ("gawk" ,gawk)))
1199 ("grep" ,grep-final)
1200 ("coreutils" ,coreutils-final)
1201 ("make" ,gnu-make-final)
1202 ("bash" ,bash-final)
1203 ("ld-wrapper" ,ld-wrapper)
1204 ("binutils" ,binutils-final)
1205 ("gcc" ,gcc-final)
1206 ("libc" ,glibc-final))))
1207
1208 (define-public canonical-package
1209 (let ((name->package (fold (lambda (input result)
1210 (match input
1211 ((_ package)
1212 (vhash-cons (package-full-name package)
1213 package result))))
1214 vlist-null
1215 `(("guile" ,guile-final)
1216 ,@%final-inputs))))
1217 (lambda (package)
1218 "Return the 'canonical' variant of PACKAGE---i.e., if PACKAGE is one of
1219 the implicit inputs of 'gnu-build-system', return that one, otherwise return
1220 PACKAGE.
1221
1222 The goal is to avoid duplication in cases like GUILE-FINAL vs. GUILE-2.0,
1223 COREUTILS-FINAL vs. COREUTILS, etc."
1224 ;; XXX: This doesn't handle dependencies of the final inputs, such as
1225 ;; libunistring, GMP, etc.
1226 (match (vhash-assoc (package-full-name package) name->package)
1227 ((_ . canon)
1228 ;; In general we want CANON, except if we're cross-compiling: CANON
1229 ;; uses explicit inputs, so it is "anchored" in the bootstrapped
1230 ;; process, with dependencies on things that cannot be
1231 ;; cross-compiled.
1232 (if (%current-target-system)
1233 package
1234 canon))
1235 (_ package)))))
1236
1237 \f
1238 ;;;
1239 ;;; GCC toolchain.
1240 ;;;
1241
1242 (define (gcc-toolchain gcc)
1243 "Return a complete toolchain for GCC."
1244 (package
1245 (name "gcc-toolchain")
1246 (version (package-version gcc))
1247 (source #f)
1248 (build-system trivial-build-system)
1249 (arguments
1250 '(#:modules ((guix build union))
1251 #:builder (begin
1252 (use-modules (ice-9 match)
1253 (guix build union))
1254
1255 (match %build-inputs
1256 (((names . directories) ...)
1257 (union-build (assoc-ref %outputs "out")
1258 directories)))
1259
1260 (union-build (assoc-ref %outputs "debug")
1261 (list (assoc-ref %build-inputs
1262 "libc-debug"))))))
1263 (license (package-license gcc))
1264 (synopsis "Complete GCC tool chain for C/C++ development")
1265 (description
1266 "This package provides a complete GCC tool chain for C/C++ development to
1267 be installed in user profiles. This includes GCC, as well as libc (headers
1268 and binaries, plus debugging symbols in the 'debug' output), and Binutils.")
1269 (home-page "http://gcc.gnu.org/")
1270 (outputs '("out" "debug"))
1271
1272 ;; The main raison d'être of this "meta-package" is (1) to conveniently
1273 ;; install everything that we need, and (2) to make sure ld-wrapper comes
1274 ;; before Binutils' ld in the user's profile.
1275 (inputs `(("gcc" ,gcc)
1276 ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
1277 ("binutils" ,binutils-final)
1278 ("libc" ,glibc-final)
1279 ("libc-debug" ,glibc-final "debug")))))
1280
1281 (define-public gcc-toolchain-4.8
1282 (gcc-toolchain gcc-final))
1283
1284 (define-public gcc-toolchain-4.9
1285 (gcc-toolchain gcc-4.9))
1286
1287 ;;; base.scm ends here