gnu: make-bootstrap: Allow cross-compilation of the bootstrap tarballs.

* gnu/packages/make-bootstrap.scm (package-with-relocatable-glibc): Turn
  `inputs' into a thunk.  Add `native-inputs', and pass it to
  `package-with-explicit-inputs'.
  (%static-inputs): Add %BASH-STATIC as an input to gawk when cross
  building.
  (%glibc-stripped): When cross compiling,
  use (glibc-for-bootstrap (cross-libc)) as the basis.
  (%gcc-static): Base on GCC-4.7, not GCC-FINAL.
  (tarball-package): TAR and XZ are native inputs.  Choose the tarball
  file name based on (%current-target-system) too.
This commit is contained in:
Ludovic Courtès 2013-06-25 23:39:14 +02:00
parent a3cff41dd1
commit a410a0105d
1 changed files with 108 additions and 77 deletions

View File

@ -24,6 +24,7 @@
#:use-module (guix build-system gnu)
#:use-module ((gnu packages) #:select (search-patch))
#:use-module (gnu packages base)
#:use-module (gnu packages cross-base)
#:use-module (gnu packages bash)
#:use-module (gnu packages compression)
#:use-module (gnu packages gawk)
@ -49,7 +50,7 @@
;;;
;;; Code:
(define* (glibc-for-bootstrap #:optional (base glibc-final))
(define* (glibc-for-bootstrap #:optional (base glibc))
"Return a libc deriving from BASE whose `system' and `popen' functions looks
for `sh' in $PATH, and without nscd, and with static NSS modules."
(package (inherit base)
@ -71,17 +72,39 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
"Return a variant of P that uses the libc as defined by
`glibc-for-bootstrap'."
(define inputs
(define (cross-bootstrap-libc)
(let ((target (%current-target-system)))
(glibc-for-bootstrap
;; `cross-libc' already returns a cross libc, so clear
;; %CURRENT-TARGET-SYSTEM.
(parameterize ((%current-target-system #f))
(cross-libc target)))))
;; Standard inputs with the above libc and corresponding GCC.
(define (inputs)
(if (%current-target-system) ; is this package cross built?
`(("cross-libc" ,(cross-bootstrap-libc)))
'()))
(define (native-inputs)
(if (%current-target-system)
(let ((target (%current-target-system)))
`(("cross-gcc" ,(cross-gcc target
(cross-binutils target)
(cross-bootstrap-libc)))
("cross-binutils" ,(cross-binutils target))
,@%final-inputs))
`(("libc" ,(glibc-for-bootstrap))
("gcc" ,(package-with-explicit-inputs
gcc-4.7
("gcc" ,(package (inherit gcc-4.7)
(inputs
`(("libc",(glibc-for-bootstrap))
,@(alist-delete "libc" %final-inputs))
(current-source-location)))
,@(fold alist-delete %final-inputs '("libc" "gcc"))))
,@(package-inputs gcc-4.7)))))
,@(fold alist-delete %final-inputs '("libc" "gcc")))))
(package-with-explicit-inputs p inputs
(current-source-location)))
(current-source-location)
#:native-inputs native-inputs))
(define %bash-static
(static-package bash-light))
@ -140,7 +163,10 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(substitute* "configure"
(("-export-dynamic") "")))
,phases)))))
(inputs `(("patch/sh" ,(search-patch "gawk-shell.patch"))))))
(inputs `(("patch/sh" ,(search-patch "gawk-shell.patch"))
,@(if (%current-target-system)
`(("bash" ,%bash-static))
'())))))
(finalize (compose static-package
package-with-relocatable-glibc)))
`(,@(map (match-lambda
@ -155,12 +181,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
("sed" ,sed)
("grep" ,grep)
("gawk" ,gawk)))
("bash" ,%bash-static)
;; ("ld-wrapper" ,ld-wrapper)
;; ("binutils" ,binutils-final)
;; ("gcc" ,gcc-final)
;; ("libc" ,glibc-final)
)))
("bash" ,%bash-static))))
(define %static-binaries
(package
@ -330,7 +351,12 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(copy-recursively (string-append linux "/include/asm-generic")
(string-append incdir "/asm-generic"))
#t))))
(inputs `(("libc" ,glibc)
(inputs `(("libc" ,(let ((target (%current-target-system)))
(if target
(glibc-for-bootstrap
(parameterize ((%current-target-system #f))
(cross-libc target)))
glibc)))
("linux-headers" ,linux-libre-headers)))
;; Only one output.
@ -339,7 +365,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(define %gcc-static
;; A statically-linked GCC, with stripped-down functionality.
(package-with-relocatable-glibc
(package (inherit gcc-final)
(package (inherit gcc-4.7)
(name "gcc-static")
(arguments
`(#:modules ((guix build utils)
@ -347,7 +373,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(srfi srfi-1)
(srfi srfi-26)
(ice-9 regex))
,@(substitute-keyword-arguments (package-arguments gcc-final)
,@(substitute-keyword-arguments (package-arguments gcc-4.7)
((#:guile _) #f)
((#:implicit-inputs? _) #t)
((#:configure-flags flags)
@ -367,7 +393,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(inputs `(("gmp-source" ,(package-source gmp))
("mpfr-source" ,(package-source mpfr))
("mpc-source" ,(package-source mpc))
("binutils" ,binutils-final)
("binutils" ,binutils)
,@(package-inputs gcc-4.7))))))
(define %gcc-stripped
@ -428,7 +454,10 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
`(;; When `configure' checks for ltdl availability, it
;; doesn't try to link using libtool, and thus fails
;; because of a missing -ldl. Work around that.
#:configure-flags '("LDFLAGS=-ldl")
#:configure-flags '("LDFLAGS=-ldl"
,@(if (%current-target-system)
'("CC_FOR_BUILD=gcc")
'()))
#:phases (alist-cons-before
'configure 'static-guile
@ -492,9 +521,9 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(location (source-properties->location (current-source-location)))
(name (string-append (package-name pkg) "-tarball"))
(build-system trivial-build-system)
(inputs `(("tar" ,tar)
("xz" ,xz)
("input" ,pkg)))
(native-inputs `(("tar" ,tar)
("xz" ,xz)))
(inputs `(("input" ,pkg)))
(arguments
(let ((name (package-name pkg))
(version (package-version pkg)))
@ -512,7 +541,9 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
(zero? (system* "tar" "cJvf"
(string-append out "/"
,name "-" ,version
"-" ,(%current-system)
"-"
,(or (%current-target-system)
(%current-system))
".tar.xz")
"."))))))))))