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