janneke pushed a commit to branch wip-hurd-vm
in repository guix.
commit 6e057f7c049c65c31b3a9349de6d0c847e89e897
Author: Jan (janneke) Nieuwenhuizen <[email protected]>
AuthorDate: Sat Apr 18 19:50:06 2020 +0200
gnu: automake: Support cross-build.
Automake cannot be cross-built properly: it lacks the concept of
<tool>-for-build. It runs the host `autoconf' during build.
* gnu/packages/autotools.scm (automake)[inputs]: When cross-building, add
autoconf and perl. [native-inputs]: when cross-building, use -for-build
names.
[arguments]: When cross-building, add `patch-non-shebang-references' phase
to
substitute autoconf and perl.
---
gnu/packages/autotools.scm | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/gnu/packages/autotools.scm b/gnu/packages/autotools.scm
index fa3ced1..38db317 100644
--- a/gnu/packages/autotools.scm
+++ b/gnu/packages/autotools.scm
@@ -287,15 +287,21 @@ output is indexed in many ways to simplify browsing.")
(patches
(search-patches "automake-skip-amhello-tests.patch"))))
(build-system gnu-build-system)
+ (inputs
+ ;; TODO: remove `if' in the next rebuild cycle.
+ (if (%current-target-system)
+ `(("autoconf" ,autoconf-wrapper)
+ ("perl" ,perl))
+ '()))
(native-inputs
`(("autoconf" ,autoconf-wrapper)
- ("perl" ,perl)))
+ ("perl" ,perl)))
(native-search-paths
(list (search-path-specification
(variable "ACLOCAL_PATH")
(files '("share/aclocal")))))
(arguments
- '(#:modules ((guix build gnu-build-system)
+ `(#:modules ((guix build gnu-build-system)
(guix build utils)
(srfi srfi-1)
(srfi srfi-26)
@@ -324,6 +330,25 @@ output is indexed in many ways to simplify browsing.")
(string-append "exit 77\n" all "\n")))
#t))
+ ,@(if (%current-target-system)
+ ;; `patch-shebangs' patches shebangs only, and the Perl
+ ;; scripts use a re-exec feature that references the build
+ ;; hosts' perl. Also, M4 store references hide in the
+ ;; scripts.
+ `((add-after 'install 'patch-non-shebang-references
+ (lambda* (#:key build inputs outputs #:allow-other-keys)
+ (let ((autoconf (assoc-ref inputs "autoconf"))
+ (perl (assoc-ref inputs "perl"))
+ (out (assoc-ref outputs "out"))
+ (store-directory (%store-directory)))
+ (substitute* (find-files (string-append out "/bin"))
+ (((string-append store-directory
"/[^/]*-autoconf-[^/]*"))
+ autoconf)
+ (((string-append store-directory
"/[^/]*-perl-[^/]*"))
+ perl))
+ #t))))
+ '())
+
;; Files like `install-sh', `mdate.sh', etc. must use
;; #!/bin/sh, otherwise users could leak erroneous shebangs
;; in the wild. See <http://bugs.gnu.org/14201> for an