3
5
Fork 0
mirror of git://git.savannah.gnu.org/guix.git synced 2023-12-14 03:33:07 +01:00

gnu: make-arm-trusted-firmware: Simplify build.

Reuse knowledge from recent U-Boot modifications to streamline the package
definition.

* gnu/packages/firmware.scm (make-arm-trusted-firmware): Change optional
argument ARCH to keyword TRIPLET.  Default to aarch64-linux-gnu.
[arguments]: Use gexps.  Add a #:target argument.  Streamline how the
CROSS_COMPILE make flag is computed.
[native-inputs]: Delete field.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
Maxim Cournoyer 2023-01-11 09:40:36 -05:00
parent ea0d3e1ec4
commit 4276283b30
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -8,7 +8,7 @@
;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020, 2021, 2022 Marius Bakke <marius@gnu.org>
;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@ -944,7 +944,14 @@ Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
(string-append fmw "/ovmf_arm.bin")))))))))
(supported-systems %supported-systems)))
(define* (make-arm-trusted-firmware platform #:optional (arch "aarch64"))
(define* (make-arm-trusted-firmware platform
#:key (triplet "aarch64-linux-gnu"))
(let ((native-build? (lambda ()
;; Note: %current-system is a *triplet*, unlike its
;; name would suggest.
(or (not triplet) ;disable cross-compilation
(string=? (%current-system)
(gnu-triplet->nix-system triplet))))))
(package
(name (string-append "arm-trusted-firmware-" platform))
(version "2.8")
@ -962,48 +969,29 @@ Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
(snippet
#~(begin
(use-modules (guix build utils))
;; Remove binary blobs which do not contain source or proper license.
;; Remove binary blobs which do not contain source or proper
;; license.
(for-each (lambda (file)
(delete-file file))
(find-files "." "\\.bin$"))))))
(build-system gnu-build-system)
(arguments
`(#:phases
(modify-phases %standard-phases
(list
#:target (and (not (native-build?)) triplet)
#:phases
#~(modify-phases %standard-phases
(delete 'configure) ;no configure script
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))
(bin (find-files "." "\\.(bin|elf)$")))
(for-each
(lambda (file)
(install-file file out))
bin)))))
#:make-flags (list (string-append "PLAT=" ,platform)
,@(if (and (not (string-prefix? "aarch64"
(%current-system)))
(string-prefix? "aarch64" arch))
`("CROSS_COMPILE=aarch64-linux-gnu-")
'())
,@(if (and (not (string-prefix? "armhf"
(%current-system)))
(string-prefix? "armhf" arch))
`("CROSS_COMPILE=arm-linux-gnueabihf-")
(lambda _
(for-each (lambda (file)
(install-file file #$output))
(find-files "." "\\.(bin|elf)$")))))
#:make-flags #~(list (string-append "PLAT=" #$platform)
#$@(if (not (native-build?))
(list (string-append "CROSS_COMPILE=" triplet "-"))
'())
"DEBUG=1")
#:tests? #f)) ; no tests
(native-inputs
(let ((system (%current-system)))
(cond
((and (not (string-prefix? "aarch64" system))
(string-prefix? "aarch64" arch))
(list (cross-gcc "aarch64-linux-gnu")
(cross-binutils "aarch64-linux-gnu")))
((and (not (string-prefix? "armhf" system))
(string-prefix? "armhf" arch))
(list (cross-gcc "arm-linux-gnueabihf")
(cross-binutils "arm-linux-gnueabihf")))
(else '()))))
#:tests? #f)) ;no test suite
(home-page "https://www.trustedfirmware.org/")
(synopsis "Implementation of \"secure world software\"")
(description
@ -1019,7 +1007,7 @@ such as:
@item Software Delegated Exception Interface (SDEI)
@end enumerate\n")
(license (list license:bsd-3
license:bsd-2)))) ; libfdt
license:bsd-2))))) ; libfdt
(define-public arm-trusted-firmware-sun50i-a64
(let ((base (make-arm-trusted-firmware "sun50i_a64")))