Subject: [PATCH 3/9] gnu: make-uboot-package: Simplify build.

From: Maxim Cournoyer <[email-masked]>
Date: Tue, 20 Dec 2022 13:34:21 -0500

* gnu/packages/bootloaders.scm (make-u-boot-package) <same-arch?>: Rename
procedure to 'native-build?'.
[native-inputs]: Remove field.
[arguments]: Specify the #:target argument, when not natively building.
Adjust for the above renaming.
---

 gnu/packages/bootloaders.scm | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index bc9f32c9aa..6893d12745 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -790,9 +790,11 @@ (define*-public (make-u-boot-package board triplet
 NAME-SUFFIX is appended to the package name, while APPEND-DESCRIPTION is
 appended to the package description.  U-BOOT can be used when a fork or a
 different version of U-Boot must be used."
-  (let ((same-arch? (lambda ()
-                      (string=? (%current-system)
-                                (gnu-triplet->nix-system triplet)))))
+  (let ((native-build? (lambda ()
+                         ;; Note: %current-target-system is a *triplet*, unlike
+                         ;; its name would suggest.
+                         (string=? (%current-system)
+                                   (gnu-triplet->nix-system triplet)))))
     (package
       (inherit u-boot)
       (name (string-append "u-boot-"
@@ -803,16 +805,11 @@ (define*-public (make-u-boot-package board triplet
                        (string-append (package-description u-boot)
                                       "\n\n" append-description)
                        (package-description u-boot)))
-      (native-inputs
-       ;; Note: leave the native u-boot inputs first, so that a user can
-       ;; override the cross-gcc and cross-binutils packages.
-       `(,@(package-native-inputs u-boot)
-         ,@(if (not (same-arch?))
-               `(("cross-gcc" ,(cross-gcc triplet))
-                 ("cross-binutils" ,(cross-binutils triplet)))
-               `())))
+      (build-system gnu-build-system)
       (arguments
        (substitute-keyword-arguments (package-arguments u-boot)
+         ((#:target _ #f)
+          (and (not (native-build?)) triplet))
          ((#:modules modules '())
           `((ice-9 ftw)
             (srfi srfi-1)
@@ -829,7 +826,7 @@ (define*-public (make-u-boot-package board triplet
          ((#:make-flags make-flags '())
           #~(list "HOSTCC=gcc"
                   "KBUILD_VERBOSE=1"
-                  #$@(if (not (same-arch?))
+                  #$@(if (not (native-build?))
                          (list (string-append "CROSS_COMPILE=" triplet "-"))
                          '())
                   #$@make-flags))
-- 
2.38.1