diff mbox series

[bug#49025,v4,core-updates,34/36] libelf: Use the cross-compiler when cross-compiling.

Message ID 20210619150458.12057-35-maximedevos@telenet.be
State Accepted
Headers show
Series Support cross-compilation with meson | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

M June 19, 2021, 3:04 p.m. UTC
* gnu/packages/elf.scm
  (libelf)[arguments]<#:phases>{delete-configure}: Regenerate
  the configure script when cross-compiling.
  (libelf)[arguments]<#:phases>{configure}: Do not replace
  when cross-compiling.
  (libelf)[native-inputs]: Add autoconf when cross-compiling.
---
 gnu/packages/elf.scm | 48 +++++++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/gnu/packages/elf.scm b/gnu/packages/elf.scm
index 0309dd95b5..66c2334e5c 100644
--- a/gnu/packages/elf.scm
+++ b/gnu/packages/elf.scm
@@ -9,6 +9,7 @@ 
 ;;; Copyright © 2020 Mark Wielaard <mark@klomp.org>
 ;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
 ;;; Copyright © 2021 Leo Le Bouter <lle-bout@zaclys.net>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -32,6 +33,7 @@ 
   #:use-module (guix build-system gnu)
   #:use-module ((guix licenses) #:select (gpl3+ lgpl3+ lgpl2.0+))
   #:use-module (gnu packages)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages gcc)
@@ -205,22 +207,36 @@  static analysis of the ELF binaries at hand.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (replace 'configure
-           (lambda* (#:key outputs #:allow-other-keys)
-             ;; This old `configure' script doesn't support
-             ;; variables passed as arguments.
-             (let ((out (assoc-ref outputs "out")))
-               (setenv "CONFIG_SHELL" (which "bash"))
-               (invoke "./configure"
-                       (string-append "--prefix=" out)
-                       ,@(if (string=? "powerpc64le-linux"
-                                       (%current-system))
-                             '("--host=powerpc64le-unknown-linux-gnu")
-                             '())
-                       ,@(if (string=? "aarch64-linux"
-                                       (%current-system))
-                             '("--host=aarch64-unknown-linux-gnu")
-                             '()))))))))
+         ,(if (%current-target-system)
+              ;; This old 'configure' script doesn't
+              ;; support cross-compilation well. E.g., it fails
+              ;; to find the cross-compiler.
+              `(add-before 'bootstrap 'delete-configure
+                 (lambda _
+                   (delete-file "configure")))
+              `(replace 'configure
+                 ;; This old `configure' script doesn't support
+                 ;; variables passed as arguments. TODO: would
+                 ;; simply regenerating 'configure' work
+                 ;; well enough, even if compiling natively
+                 ;; on powerpc or aarch64?
+                 (lambda* (#:key outputs #:allow-other-keys)
+                   (let ((out (assoc-ref outputs "out")))
+                     (setenv "CONFIG_SHELL" (which "bash"))
+                     (invoke "./configure"
+                             (string-append "--prefix=" out)
+                             ,@(if (string=? "powerpc64le-linux"
+                                             (%current-system))
+                                   '("--host=powerpc64le-unknown-linux-gnu")
+                                   '())
+                             ,@(if (string=? "aarch64-linux"
+                                             (%current-system))
+                                   '("--host=aarch64-unknown-linux-gnu")
+                                   '())))))))))
+    (native-inputs
+     (if (%current-target-system)
+         `(("autoconf" ,autoconf))
+         '()))
     (home-page (string-append "https://web.archive.org/web/20181111033959/"
                               "http://www.mr511.de/software/english.html"))
     (synopsis "ELF object file access library")