summary refs log tree commit diff
path: root/gnu/packages/cross-base.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/cross-base.scm')
-rw-r--r--gnu/packages/cross-base.scm55
1 files changed, 46 insertions, 9 deletions
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 8d0b41180b..14cb365099 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -1,13 +1,14 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013-2018, 2020, 2023 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
-;;; Copyright © 2016, 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2016, 2019, 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2019, 2020, 2021 Marius Bakke <marius@gnu.org>
 ;;; Copyright © 2019 Carl Dong <contact@carldong.me>
 ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2023 Josselin Poiret <dev@jpoiret.xyz>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -374,6 +375,24 @@ target that libc."
     (inherit gnumach-headers)
     (name (string-append (package-name gnumach-headers)
                          "-cross-" target))
+    (arguments
+     (substitute-keyword-arguments (package-arguments gnumach-headers)
+       ((#:phases phases #~%standard-phases)
+        #~(modify-phases #$phases
+            ;; Cheat by setting the host_cpu variable manually, since using
+            ;; --host= would require a working cross-compiler, which we don't
+            ;; have yet.
+            (add-after 'unpack 'substitute-host-cpu
+              (lambda _
+                (substitute* "configure.ac"
+                  (("AC_CANONICAL_HOST")
+                   #$(string-append
+                      "host_cpu="
+                      (match target
+                        ((? target-x86-32?)
+                         "i386")
+                        ((? target-x86-64?)
+                         "x86_64")))))))))))
     (native-inputs
      (modify-inputs (package-native-inputs gnumach-headers)
        (prepend xgcc xbinutils)))))
@@ -492,7 +511,11 @@ the base compiler.  Use XBINUTILS as the associated cross-Binutils."
                                               hurd "/include")))
                    (for-each (cut setenv <> cpath)
                              ',%gcc-cross-include-paths)
-                   #t)))))))
+                   #t)))))
+         ((#:configure-flags flags)
+          `(cons* ,(string-append "--build=" (%current-system))
+                  ,(string-append "--host=" target)
+                  ,flags))))
 
       (propagated-inputs `(("gnumach-headers" ,xgnumach-headers)
                            ("hurd-headers" ,xhurd-headers)))
@@ -518,21 +541,35 @@ the base compiler.  Use XBINUTILS as the associated cross-Binutils."
                   ,(string-append "--host=" target)
                   ,flags))
          ((#:phases phases)
-          `(modify-phases ,phases
+          #~(modify-phases #$phases
+              (add-after 'unpack 'delete-shared-target
+                ;; Cannot create shared libraries due to missing crt1.o
+                (lambda _
+                  (substitute* "Makeconf"
+                    (("(targets := \\$\\(libname\\)\\.a) \\$\\(libname\\)\\.so" all static)
+                     static)
+                    (("\\$\\(DESTDIR\\)\\$\\(libdir\\)/\\$\\(libname\\)\\.so\\.\\$\\(hurd-version\\)")
+                     "")
+                    (("^libs: .*\\.so\\..*" all)
+                     (string-append "# " all)))))
              (add-before 'configure 'set-cross-headers-path
                (lambda* (#:key inputs #:allow-other-keys)
                  (let* ((glibc-headers (assoc-ref inputs "cross-glibc-hurd-headers"))
-                        (cpath (string-append glibc-headers "/include")))
+                        (mach-headers (assoc-ref inputs "cross-gnumach-headers"))
+                        (cpath (string-append glibc-headers "/include"
+                                              ":" mach-headers "/include")))
                    (for-each (cut setenv <> cpath)
-                             ',%gcc-cross-include-paths)
+                             '#$%gcc-cross-include-paths)
                    #t)))))))
 
-      (inputs `(("cross-glibc-hurd-headers" ,xglibc/hurd-headers)))
+      (inputs `(("cross-glibc-hurd-headers" ,xglibc/hurd-headers)
+                ("cross-gnumach-headers" ,xgnumach-headers)))
 
       (native-inputs `(("cross-gcc" ,xgcc)
                        ("cross-binutils" ,xbinutils)
                        ("cross-mig" ,xmig)
-                       ,@(alist-delete "mig"(package-native-inputs hurd-minimal))))))
+                       ,@(alist-delete "mig"
+                                       (package-native-inputs hurd-minimal))))))
 
   (define xhurd-core-headers
     (package
@@ -555,7 +592,7 @@ the base compiler.  Use XBINUTILS as the associated cross-Binutils."
 
 (define* (cross-libc/deprecated target
                                 #:optional
-                                (libc glibc)
+                                (libc (libc-for-target target))
                                 (xgcc (cross-gcc target))
                                 (xbinutils (cross-binutils target))
                                 (xheaders (cross-kernel-headers target)))
@@ -568,7 +605,7 @@ the base compiler.  Use XBINUTILS as the associated cross-Binutils."
 
 (define* (cross-libc* target
                       #:key
-                      (libc glibc)
+                      (libc (libc-for-target target))
                       (xgcc (cross-gcc target))
                       (xbinutils (cross-binutils target))
                       (xheaders (cross-kernel-headers target)))