utils: Define 'target-hurd?' predicate.

It behaves similarily to the other target-...? procedures.
The usage of hurd-triplet? / target-hurd? in libgc appears
incorrect to me, as (%current-system) is normally never false.

* gnu/packages/hurd.scm (hurd-triplet?): Move to ...
* guix/util.scm (target-hurd?): ... here, let its argument
  default to (%current-target-system) or (%current-system),
  and write a docstring.
* gnu/packages/hurd.scm
  (hurd-target?, hurd-system?): Use target-hurd? instead of
  hurd-triplet?.
* gnu/packages/bdw-gc.scm (libgc): Likewise.
* gnu/packages/cross-base.scm
  (cross-libc)[arguments]<#:configure-flags>: Likewise.
  (cross-libc)[arguments]<#:phases>: Likewise.
  (cross-libc)[arguments]<#:native-inputs>: Likewise.
* gnu/packages/make-boostrap.scm
  (%glibc-stripped)[inputs]: Likewise.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
This commit is contained in:
Maxime Devos 2021-07-14 13:12:47 +02:00 committed by Mathieu Othacehe
parent ef71965c16
commit 637a1e7dcc
No known key found for this signature in database
GPG key ID: 8354763531769CA6
5 changed files with 16 additions and 13 deletions

View file

@ -56,8 +56,8 @@ (define-public libgc
;; to configure script. See bug report and discussion:
;; <https://lists.opendylan.org/pipermail/bdwgc/2017-April/006275.html>
;; <https://lists.gnu.org/archive/html/bug-hurd/2017-01/msg00008.html>
,@(if (hurd-triplet? (or (%current-system)
(%current-target-system)))
,@(if (target-hurd? (or (%current-system)
(%current-target-system)))
'("--disable-gcj-support")
'()))))
(native-inputs `(("pkg-config" ,pkg-config)))

View file

@ -505,7 +505,7 @@ (define* (cross-libc target
,@(package-arguments libc))
((#:configure-flags flags)
`(cons ,(string-append "--host=" target)
,(if (hurd-triplet? target)
,(if (target-hurd? target)
`(cons "--disable-werror" ,flags)
flags)))
((#:phases phases)
@ -519,7 +519,7 @@ (define* (cross-libc target
(setenv "CROSS_LIBRARY_PATH"
(string-append kernel "/lib")) ; for Hurd's libihash
#t)))
,@(if (hurd-triplet? target)
,@(if (target-hurd? target)
'((add-after 'install 'augment-libc.so
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")))
@ -536,7 +536,7 @@ (define* (cross-libc target
(native-inputs `(("cross-gcc" ,xgcc)
("cross-binutils" ,xbinutils)
,@(if (hurd-triplet? target)
,@(if (target-hurd? target)
`(("cross-mig"
,@(assoc-ref (package-native-inputs xheaders)
"cross-mig")))

View file

@ -51,20 +51,16 @@ (define-module (gnu packages hurd)
hurd-target?
hurd-triplet?))
(define (hurd-triplet? triplet)
(and (string-suffix? "-gnu" triplet)
(not (string-contains triplet "linux"))))
(define (hurd-target?)
"Return true if the cross-compilation target or the current system is
GNU/Hurd."
(or (and=> (%current-target-system) hurd-triplet?)
(or (and=> (%current-target-system) target-hurd?)
(and (not (%current-target-system))
(and=> (%current-system) hurd-triplet?))))
(and=> (%current-system) target-hurd?))))
(define (hurd-system?)
"Return true if the current system is the Hurd."
(and=> (%current-system) hurd-triplet?))
(and=> (%current-system) target-hurd?))
(define (hurd-source-url version)
(string-append "mirror://gnu/hurd/hurd-"

View file

@ -439,7 +439,7 @@ (define (%glibc-stripped)
(assoc-ref %build-inputs "kernel-headers")))))
(inputs `(("kernel-headers"
,(if (or (and (%current-target-system)
(hurd-triplet? (%current-target-system)))
(target-hurd? (%current-target-system)))
(string-suffix? "-hurd" (%current-system)))
gnumach-headers
linux-libre-headers))

View file

@ -85,6 +85,7 @@ (define-module (guix utils)
%current-target-system
package-name->name+version
target-linux?
target-hurd?
target-mingw?
target-arm32?
target-aarch64?
@ -639,6 +640,12 @@ (define* (target-linux? #:optional (target (or (%current-target-system)
"Does the operating system of TARGET use the Linux kernel?"
(->bool (string-contains target "linux")))
(define* (target-hurd? #:optional (target (or (%current-target-system)
(%current-system))))
"Does TARGET represent the GNU(/Hurd) system?"
(and (string-suffix? "-gnu" target)
(not (string-contains target "linux"))))
(define* (target-mingw? #:optional (target (%current-target-system)))
(and target
(string-suffix? "-mingw32" target)))