summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-06-21 00:25:54 +0200
committerLudovic Courtès <ludo@gnu.org>2013-06-21 00:25:54 +0200
commit56c092ce94cee893898f71ce61e443dd121cccdb (patch)
treee0323ffa05b55605112e2ce46500ee13c7707a48
parentd501fad11cfbd69245a4d5e2d632a0ab37985b55 (diff)
build-system/gnu: Unify with (guix build-system gnu-cross-build).
* guix/build/gnu-build-system.scm (set-paths): Add `native-inputs' and `native-search-paths' keyword parameters. Honor them. (configure): Add `target' and `native-inputs' keyword parameters. Look for Bash in NATIVE-INPUTS or INPUTS. Pass `--host' when TARGET is true. (strip): Add `strip-command' keyword parameter. Use it. * guix/build/gnu-cross-build.scm: Remove. * Makefile.am (MODULES): Adjust accordingly. * gnu/packages/acl.scm, gnu/packages/attr.scm, gnu/packages/base.scm, gnu/packages/bash.scm, gnu/packages/gawk.scm, gnu/packages/gettext.scm, gnu/packages/guile.scm, gnu/packages/libffi.scm, gnu/packages/libsigsegv.scm, gnu/packages/linux.scm, gnu/packages/ncurses.scm, gnu/packages/readline.scm, guix/build-system/gnu.scm: Replace `%standard-cross-phases' by `%standard-phases'. Remove references to (guix build gnu-cross-build).
-rw-r--r--Makefile.am1
-rw-r--r--gnu/packages/acl.scm2
-rw-r--r--gnu/packages/attr.scm2
-rw-r--r--gnu/packages/base.scm4
-rw-r--r--gnu/packages/bash.scm9
-rw-r--r--gnu/packages/gawk.scm4
-rw-r--r--gnu/packages/gettext.scm2
-rw-r--r--gnu/packages/guile.scm4
-rw-r--r--gnu/packages/libffi.scm9
-rw-r--r--gnu/packages/libsigsegv.scm4
-rw-r--r--gnu/packages/linux.scm10
-rw-r--r--gnu/packages/ncurses.scm2
-rw-r--r--gnu/packages/readline.scm4
-rw-r--r--guix/build-system/gnu.scm6
-rw-r--r--guix/build/gnu-build-system.scm45
-rw-r--r--guix/build/gnu-cross-build.scm138
16 files changed, 54 insertions, 192 deletions
diff --git a/Makefile.am b/Makefile.am
index 418b63a3777..9faa6544ea1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -59,7 +59,6 @@ MODULES = \
59 guix/build/download.scm \ 59 guix/build/download.scm \
60 guix/build/cmake-build-system.scm \ 60 guix/build/cmake-build-system.scm \
61 guix/build/gnu-build-system.scm \ 61 guix/build/gnu-build-system.scm \
62 guix/build/gnu-cross-build.scm \
63 guix/build/perl-build-system.scm \ 62 guix/build/perl-build-system.scm \
64 guix/build/python-build-system.scm \ 63 guix/build/python-build-system.scm \
65 guix/build/utils.scm \ 64 guix/build/utils.scm \
diff --git a/gnu/packages/acl.scm b/gnu/packages/acl.scm
index 54c9116baf8..b7604dcea6f 100644
--- a/gnu/packages/acl.scm
+++ b/gnu/packages/acl.scm
@@ -46,7 +46,7 @@
46 (lambda _ 46 (lambda _
47 (patch-makefile-SHELL "include/buildmacros")) 47 (patch-makefile-SHELL "include/buildmacros"))
48 ,(if (%current-target-system) 48 ,(if (%current-target-system)
49 '%standard-cross-phases 49 '%standard-phases
50 '(alist-replace 'check 50 '(alist-replace 'check
51 (lambda _ 51 (lambda _
52 (system* "make" "tests" "-C" "test") 52 (system* "make" "tests" "-C" "test")
diff --git a/gnu/packages/attr.scm b/gnu/packages/attr.scm
index 3fb15d235fc..2ce50296ac3 100644
--- a/gnu/packages/attr.scm
+++ b/gnu/packages/attr.scm
@@ -55,7 +55,7 @@
55 55
56 ;; When building natively, adjust the test cases. 56 ;; When building natively, adjust the test cases.
57 ,(if (%current-target-system) 57 ,(if (%current-target-system)
58 '%standard-cross-phases 58 '%standard-phases
59 '(alist-replace 'check 59 '(alist-replace 'check
60 (lambda _ 60 (lambda _
61 ;; Use the right shell. 61 ;; Use the right shell.
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 85380549ff8..95052775c55 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -293,9 +293,7 @@ The tools supplied with this package are:
293 (substitute* (find-files "tests" "\\.sh$") 293 (substitute* (find-files "tests" "\\.sh$")
294 (("#!/bin/sh") 294 (("#!/bin/sh")
295 (format #f "#!~a/bin/bash" bash))))) 295 (format #f "#!~a/bin/bash" bash)))))
296 ,(if (%current-target-system) 296 %standard-phases)))
297 '%standard-cross-phases
298 '%standard-phases))))
299 (synopsis "Core GNU utilities (file, text, shell)") 297 (synopsis "Core GNU utilities (file, text, shell)")
300 (description 298 (description
301 "The GNU Core Utilities are the basic file, shell and text manipulation 299 "The GNU Core Utilities are the basic file, shell and text manipulation
diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index bf51403f1ae..aa3f397a529 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
@@ -82,9 +82,7 @@
82 82
83 #:phases (alist-cons-after 'install 'post-install 83 #:phases (alist-cons-after 'install 'post-install
84 ,post-install-phase 84 ,post-install-phase
85 ,(if (%current-target-system) 85 %standard-phases)))
86 '%standard-cross-phases
87 '%standard-phases))))
88 (synopsis "The GNU Bourne-Again SHell") 86 (synopsis "The GNU Bourne-Again SHell")
89 (description 87 (description
90 "Bash is the shell, or command language interpreter, that will appear in 88 "Bash is the shell, or command language interpreter, that will appear in
@@ -106,10 +104,7 @@ modification.")
106 (let ((args `(#:modules ((guix build gnu-build-system) 104 (let ((args `(#:modules ((guix build gnu-build-system)
107 (guix build utils) 105 (guix build utils)
108 (srfi srfi-1) 106 (srfi srfi-1)
109 (srfi srfi-26) 107 (srfi srfi-26))
110 ,@(if (%current-target-system)
111 '((guix build gnu-cross-build))
112 '()))
113 ,@(package-arguments bash)))) 108 ,@(package-arguments bash))))
114 (substitute-keyword-arguments args 109 (substitute-keyword-arguments args
115 ((#:configure-flags flags) 110 ((#:configure-flags flags)
diff --git a/gnu/packages/gawk.scm b/gnu/packages/gawk.scm
index 444fa5e5564..1b19f7bfd25 100644
--- a/gnu/packages/gawk.scm
+++ b/gnu/packages/gawk.scm
@@ -50,9 +50,7 @@
50 (substitute* "io.c" 50 (substitute* "io.c"
51 (("/bin/sh") 51 (("/bin/sh")
52 (string-append bash "/bin/bash"))))) 52 (string-append bash "/bin/bash")))))
53 ,(if (%current-target-system) 53 %standard-phases)))
54 '%standard-cross-phases
55 '%standard-phases))))
56 (inputs `(("libsigsegv" ,libsigsegv) 54 (inputs `(("libsigsegv" ,libsigsegv)
57 55
58 ;; TODO: On next core-updates, make Bash input unconditional. 56 ;; TODO: On next core-updates, make Bash input unconditional.
diff --git a/gnu/packages/gettext.scm b/gnu/packages/gettext.scm
index e22b1ba6ff2..c838f9c0a6e 100644
--- a/gnu/packages/gettext.scm
+++ b/gnu/packages/gettext.scm
@@ -39,7 +39,7 @@
39 (arguments 39 (arguments
40 `(#:patches (list (assoc-ref %build-inputs "patch/gets")) 40 `(#:patches (list (assoc-ref %build-inputs "patch/gets"))
41 #:phases ,(if (%current-target-system) 41 #:phases ,(if (%current-target-system)
42 '%standard-cross-phases 42 '%standard-phases
43 '(alist-cons-before 43 '(alist-cons-before
44 'check 'patch-tests 44 'check 'patch-tests
45 (lambda* (#:key inputs #:allow-other-keys) 45 (lambda* (#:key inputs #:allow-other-keys)
diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
index b53f3eb7704..c4eca3e3508 100644
--- a/gnu/packages/guile.scm
+++ b/gnu/packages/guile.scm
@@ -158,9 +158,7 @@ extensible. It supports many SRFIs.")
158 (substitute* "module/ice-9/popen.scm" 158 (substitute* "module/ice-9/popen.scm"
159 (("/bin/sh") 159 (("/bin/sh")
160 (string-append bash "/bin/bash"))))) 160 (string-append bash "/bin/bash")))))
161 ,(if (%current-target-system) 161 %standard-phases)
162 '%standard-cross-phases
163 '%standard-phases))
164 162
165 ,@(if (%current-target-system) 163 ,@(if (%current-target-system)
166 '(#:configure-flags '("CC_FOR_BUILD=gcc")) 164 '(#:configure-flags '("CC_FOR_BUILD=gcc"))
diff --git a/gnu/packages/libffi.scm b/gnu/packages/libffi.scm
index f7d4a8c908a..fdebab74337 100644
--- a/gnu/packages/libffi.scm
+++ b/gnu/packages/libffi.scm
@@ -49,15 +49,10 @@
49 "0ln4jbpb6clcsdpb9niqk0frgx4k0xki96wiv067ig0q4cajb7aq")))) 49 "0ln4jbpb6clcsdpb9niqk0frgx4k0xki96wiv067ig0q4cajb7aq"))))
50 (build-system gnu-build-system) 50 (build-system gnu-build-system)
51 (arguments `(#:modules ((guix build utils) (guix build gnu-build-system) 51 (arguments `(#:modules ((guix build utils) (guix build gnu-build-system)
52 (ice-9 ftw) (srfi srfi-26) 52 (ice-9 ftw) (srfi srfi-26))
53 ,@(if (%current-target-system)
54 '((guix build gnu-cross-build))
55 '()))
56 #:phases (alist-cons-after 'install 'post-install 53 #:phases (alist-cons-after 'install 'post-install
57 ,post-install-phase 54 ,post-install-phase
58 ,(if (%current-target-system) 55 %standard-phases)))
59 '%standard-cross-phases
60 '%standard-phases))))
61 (synopsis "Foreign function call interface library") 56 (synopsis "Foreign function call interface library")
62 (description 57 (description
63 "The libffi library provides a portable, high level programming interface 58 "The libffi library provides a portable, high level programming interface
diff --git a/gnu/packages/libsigsegv.scm b/gnu/packages/libsigsegv.scm
index 4689b3d8b5d..62fb40737ac 100644
--- a/gnu/packages/libsigsegv.scm
+++ b/gnu/packages/libsigsegv.scm
@@ -49,9 +49,7 @@
49 (lambda _ 49 (lambda _
50 (substitute* "src/fault-linux-mips-old.h" 50 (substitute* "src/fault-linux-mips-old.h"
51 (("#include <asm/sigcontext\\.h>") ""))) 51 (("#include <asm/sigcontext\\.h>") "")))
52 ,(if (%current-target-system) 52 %standard-phases))
53 '%standard-cross-phases
54 '%standard-phases)))
55 '())) 53 '()))
56 (description 54 (description
57"GNU libsigsegv is a library for handling page faults in user mode. A page 55"GNU libsigsegv is a library for handling page faults in user mode. A page
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 0bc9fbcb5e3..dde53e9f5d8 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -80,18 +80,12 @@
80 (arguments 80 (arguments
81 `(#:modules ((guix build gnu-build-system) 81 `(#:modules ((guix build gnu-build-system)
82 (guix build utils) 82 (guix build utils)
83 (srfi srfi-1) 83 (srfi srfi-1))
84 ,@(if (%current-target-system)
85 '((guix build gnu-cross-build))
86 '()))
87 #:phases (alist-replace 84 #:phases (alist-replace
88 'build ,(build-phase (%current-system)) 85 'build ,(build-phase (%current-system))
89 (alist-replace 86 (alist-replace
90 'install ,install-phase 87 'install ,install-phase
91 (alist-delete 'configure 88 (alist-delete 'configure %standard-phases)))
92 ,(if (%current-target-system)
93 '%standard-cross-phases
94 '%standard-phases))))
95 #:tests? #f)) 89 #:tests? #f))
96 (synopsis "GNU Linux-Libre kernel headers") 90 (synopsis "GNU Linux-Libre kernel headers")
97 (description "Headers of the Linux-Libre kernel.") 91 (description "Headers of the Linux-Libre kernel.")
diff --git a/gnu/packages/ncurses.scm b/gnu/packages/ncurses.scm
index c1badae8a38..e5a9bce0f1e 100644
--- a/gnu/packages/ncurses.scm
+++ b/gnu/packages/ncurses.scm
@@ -116,7 +116,7 @@
116 ,cross-pre-install-phase 116 ,cross-pre-install-phase
117 (alist-cons-after 117 (alist-cons-after
118 'install 'post-install ,post-install-phase 118 'install 'post-install ,post-install-phase
119 %standard-cross-phases))) 119 %standard-phases)))
120 120
121 `(alist-cons-after ; native build 121 `(alist-cons-after ; native build
122 'install 'post-install ,post-install-phase 122 'install 'post-install ,post-install-phase
diff --git a/gnu/packages/readline.scm b/gnu/packages/readline.scm
index 1fb43769712..8857666fcc4 100644
--- a/gnu/packages/readline.scm
+++ b/gnu/packages/readline.scm
@@ -61,9 +61,7 @@
61 #:phases (alist-cons-after 61 #:phases (alist-cons-after
62 'install 'post-install 62 'install 'post-install
63 ,post-install-phase 63 ,post-install-phase
64 ,(if (%current-target-system) 64 %standard-phases)))
65 '%standard-cross-phases
66 '%standard-phases))))
67 (synopsis "Edit command lines while typing, with history support") 65 (synopsis "Edit command lines while typing, with history support")
68 (description 66 (description
69 "The GNU Readline library provides a set of functions for use by 67 "The GNU Readline library provides a set of functions for use by
diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm
index 35590aa3da8..b72239d13e4 100644
--- a/guix/build-system/gnu.scm
+++ b/guix/build-system/gnu.scm
@@ -340,14 +340,12 @@ inputs."
340 (strip-flags ''("--strip-debug")) 340 (strip-flags ''("--strip-debug"))
341 (strip-directories ''("lib" "lib64" "libexec" 341 (strip-directories ''("lib" "lib64" "libexec"
342 "bin" "sbin")) 342 "bin" "sbin"))
343 (phases '%standard-cross-phases) 343 (phases '%standard-phases)
344 (system (%current-system)) 344 (system (%current-system))
345 (implicit-inputs? #t) ; useful when bootstrapping 345 (implicit-inputs? #t)
346 (imported-modules '((guix build gnu-build-system) 346 (imported-modules '((guix build gnu-build-system)
347 (guix build gnu-cross-build)
348 (guix build utils))) 347 (guix build utils)))
349 (modules '((guix build gnu-build-system) 348 (modules '((guix build gnu-build-system)
350 (guix build gnu-cross-build)
351 (guix build utils)))) 349 (guix build utils))))
352 "Cross-build NAME for TARGET, where TARGET is a GNU triplet. INPUTS are 350 "Cross-build NAME for TARGET, where TARGET is a GNU triplet. INPUTS are
353cross-built inputs, and NATIVE-INPUTS are inputs that run on the build 351cross-built inputs, and NATIVE-INPUTS are inputs that run on the build
diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 47820aa02ee..4245f2aefdb 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -48,15 +48,28 @@
48 #f 48 #f
49 dir)) 49 dir))
50 50
51(define* (set-paths #:key inputs (search-paths '()) 51(define* (set-paths #:key target inputs native-inputs
52 (search-paths '()) (native-search-paths '())
52 #:allow-other-keys) 53 #:allow-other-keys)
53 (define input-directories 54 (define input-directories
54 (match inputs 55 (match inputs
55 (((_ . dir) ...) 56 (((_ . dir) ...)
56 dir))) 57 dir)))
57 58
59 (define native-input-directories
60 (match native-inputs
61 (((_ . dir) ...)
62 dir)
63 (#f ; not cross compiling
64 '())))
65
66 ;; When cross building, $PATH must refer only to native (host) inputs since
67 ;; target inputs are not executable.
58 (set-path-environment-variable "PATH" '("bin" "sbin") 68 (set-path-environment-variable "PATH" '("bin" "sbin")
59 input-directories) 69 (append native-input-directories
70 (if target
71 '()
72 input-directories)))
60 73
61 (for-each (match-lambda 74 (for-each (match-lambda
62 ((env-var (directories ...) separator) 75 ((env-var (directories ...) separator)
@@ -65,6 +78,15 @@
65 #:separator separator))) 78 #:separator separator)))
66 search-paths) 79 search-paths)
67 80
81 (when native-search-paths
82 ;; Search paths for native inputs, when cross building.
83 (for-each (match-lambda
84 ((env-var (directories ...) separator)
85 (set-path-environment-variable env-var directories
86 native-input-directories
87 #:separator separator)))
88 native-search-paths))
89
68 ;; Dump the environment variables as a shell script, for handy debugging. 90 ;; Dump the environment variables as a shell script, for handy debugging.
69 (system "export > environment-variables")) 91 (system "export > environment-variables"))
70 92
@@ -102,7 +124,8 @@ makefiles."
102 (append patch-flags (list "--input" p))))) 124 (append patch-flags (list "--input" p)))))
103 patches)) 125 patches))
104 126
105(define* (configure #:key inputs outputs (configure-flags '()) out-of-source? 127(define* (configure #:key target native-inputs inputs outputs
128 (configure-flags '()) out-of-source?
106 #:allow-other-keys) 129 #:allow-other-keys)
107 (define (package-name) 130 (define (package-name)
108 (let* ((out (assoc-ref outputs "out")) 131 (let* ((out (assoc-ref outputs "out"))
@@ -119,7 +142,7 @@ makefiles."
119 (libdir (assoc-ref outputs "lib")) 142 (libdir (assoc-ref outputs "lib"))
120 (includedir (assoc-ref outputs "include")) 143 (includedir (assoc-ref outputs "include"))
121 (docdir (assoc-ref outputs "doc")) 144 (docdir (assoc-ref outputs "doc"))
122 (bash (or (and=> (assoc-ref inputs "bash") 145 (bash (or (and=> (assoc-ref (or native-inputs inputs) "bash")
123 (cut string-append <> "/bin/bash")) 146 (cut string-append <> "/bin/bash"))
124 "/bin/sh")) 147 "/bin/sh"))
125 (flags `(,(string-append "CONFIG_SHELL=" bash) 148 (flags `(,(string-append "CONFIG_SHELL=" bash)
@@ -148,6 +171,9 @@ makefiles."
148 (list (string-append "--docdir=" docdir 171 (list (string-append "--docdir=" docdir
149 "/doc/" (package-name))) 172 "/doc/" (package-name)))
150 '()) 173 '())
174 ,@(if target ; cross building
175 (list (string-append "--host=" target))
176 '())
151 ,@configure-flags)) 177 ,@configure-flags))
152 (abs-srcdir (getcwd)) 178 (abs-srcdir (getcwd))
153 (srcdir (if out-of-source? 179 (srcdir (if out-of-source?
@@ -230,17 +256,20 @@ makefiles."
230 bindirs))) 256 bindirs)))
231 #t) 257 #t)
232 258
233(define* (strip #:key outputs (strip-binaries? #t) 259(define* (strip #:key target outputs (strip-binaries? #t)
260 (strip-command (if target
261 (string-append target "-strip")
262 "strip"))
234 (strip-flags '("--strip-debug")) 263 (strip-flags '("--strip-debug"))
235 (strip-directories '("lib" "lib64" "libexec" 264 (strip-directories '("lib" "lib64" "libexec"
236 "bin" "sbin")) 265 "bin" "sbin"))
237 #:allow-other-keys) 266 #:allow-other-keys)
238 (define (strip-dir dir) 267 (define (strip-dir dir)
239 (format #t "stripping binaries in ~s with flags ~s~%" 268 (format #t "stripping binaries in ~s with ~s and flags ~s~%"
240 dir strip-flags) 269 dir strip-command strip-flags)
241 (file-system-fold (const #t) 270 (file-system-fold (const #t)
242 (lambda (path stat result) ; leaf 271 (lambda (path stat result) ; leaf
243 (zero? (apply system* "strip" 272 (zero? (apply system* strip-command
244 (append strip-flags (list path))))) 273 (append strip-flags (list path)))))
245 (const #t) ; down 274 (const #t) ; down
246 (const #t) ; up 275 (const #t) ; up
diff --git a/guix/build/gnu-cross-build.scm b/guix/build/gnu-cross-build.scm
deleted file mode 100644
index dab60684ac1..00000000000
--- a/guix/build/gnu-cross-build.scm
+++ /dev/null
@@ -1,138 +0,0 @@
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (guix build gnu-cross-build)
20 #:use-module (guix build utils)
21 #:use-module ((guix build gnu-build-system)
22 #:renamer (symbol-prefix-proc 'build:))
23 #:use-module (ice-9 ftw)
24 #:use-module (ice-9 match)
25 #:use-module (srfi srfi-1)
26 #:export (%standard-cross-phases
27 gnu-cross-build))
28
29;;; Commentary:
30;;;
31;;; Extension of `gnu-build-system.scm' to support cross-compilation.
32;;;
33;;; Code:
34
35(define* (set-paths #:key inputs native-inputs
36 (search-paths '()) (native-search-paths '())
37 #:allow-other-keys)
38 (define input-directories
39 (match inputs
40 (((_ . dir) ...)
41 dir)))
42
43 (define native-input-directories
44 (match native-inputs
45 (((_ . dir) ...)
46 dir)))
47
48 ;; $PATH must refer only to native (host) inputs since target inputs are not
49 ;; executable.
50 (set-path-environment-variable "PATH" '("bin" "sbin")
51 native-input-directories)
52
53 ;; Search paths for target inputs.
54 (for-each (match-lambda
55 ((env-var (directories ...) separator)
56 (set-path-environment-variable env-var directories
57 input-directories
58 #:separator separator)))
59 search-paths)
60
61 ;; Search paths for native inputs.
62 (for-each (match-lambda
63 ((env-var (directories ...) separator)
64 (set-path-environment-variable env-var directories
65 native-input-directories
66 #:separator separator)))
67 native-search-paths)
68
69 ;; Dump the environment variables as a shell script, for handy debugging.
70 (system "export > environment-variables"))
71
72(define* (configure #:key
73 inputs outputs (configure-flags '()) out-of-source?
74 target native-inputs
75 #:allow-other-keys)
76 (format #t "configuring for cross-compilation to `~a'~%" target)
77 (apply (assoc-ref build:%standard-phases 'configure)
78 #:configure-flags (cons (string-append "--host=" target)
79 configure-flags)
80
81 ;; XXX: The underlying `configure' phase looks for Bash among
82 ;; #:inputs, so fool it this way.
83 #:inputs native-inputs
84
85 #:outputs outputs
86 #:out-of-source? out-of-source?
87 '()))
88
89(define* (strip #:key target outputs (strip-binaries? #t)
90 (strip-flags '("--strip-debug"))
91 (strip-directories '("lib" "lib64" "libexec"
92 "bin" "sbin"))
93 #:allow-other-keys)
94 ;; TODO: The only difference with `strip' in gnu-build-system.scm is the
95 ;; name of the strip command; factorize it.
96
97 (define (strip-dir dir)
98 (format #t "stripping binaries in ~s with flags ~s~%"
99 dir strip-flags)
100 (file-system-fold (const #t)
101 (lambda (path stat result) ; leaf
102 (zero? (apply system*
103 (string-append target "-strip")
104 (append strip-flags (list path)))))
105 (const #t) ; down
106 (const #t) ; up
107 (const #t) ; skip
108 (lambda (path stat errno result)
109 (format (current-error-port)
110 "strip: failed to access `~a': ~a~%"
111 path (strerror errno))
112 #f)
113 #t
114 dir))
115
116 (or (not strip-binaries?)
117 (every strip-dir
118 (append-map (match-lambda
119 ((_ . dir)
120 (filter-map (lambda (d)
121 (let ((sub (string-append dir "/" d)))
122 (and (directory-exists? sub) sub)))
123 strip-directories)))
124 outputs))))
125
126(define %standard-cross-phases
127 ;; The standard phases when cross-building.
128 (let ((replacements `((set-paths ,set-paths)
129 (configure ,configure)
130 (strip ,strip))))
131 (fold (lambda (replacement phases)
132 (match replacement
133 ((name proc)
134 (alist-replace name proc phases))))
135 (alist-delete 'check build:%standard-phases)
136 replacements)))
137
138;;; gnu-cross-build.scm ends here