This patch adds a cross-kernel-headers package wrapper which returns
the headers for the current  target system. It's either the xlinux-headers
for linux, or a union of Mach + Hurd headers with the hurd-minimal libs.

Tested it for both Linux and Hurd.

Manolis
From ff3604b86fa555ec963cc138b1230bcd2edaa864 Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <[email protected]>
Date: Tue, 21 Jul 2015 12:08:18 +0300
Subject: [PATCH] gnu: cross-base: Add cross-kernel-headers package for
 cross-gcc.

* gnu/packages/cross-base.scm (cross-gcc): Add cross-kernel-headers package
  which return the headers needed for each kernel. Replace "xlinux-headers"
  input with "xkernel-headers" input.
---
 gnu/packages/cross-base.scm | 56 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 53 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 18b0661..67355d5 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -226,6 +226,57 @@ may be either a libc package or #f.)"
   "Return a cross-compiler for TARGET, where TARGET is a GNU triplet.  Use
 XBINUTILS as the associated cross-Binutils.  If LIBC is false, then build a
 GCC that does not target a libc; otherwise, target that libc."
+  
+  (define (cross-kernel-headers target libc)
+    "Return headers depending on TARGET."
+    (match target
+      ("i586-pc-gnu"
+       (package
+         ;; This package is a union of the Mach and Hurd headers and the
+         ;; Hurd-minimal package which are needed for the cross-gcc.
+         (name "cross-kernel-headers")
+         (version "0")
+         (source #f)
+         (build-system gnu-build-system)
+         (inputs
+          `(("cross-gnumach-headers" ,@(assoc-ref (package-propagated-inputs libc)
+                                             "cross-gnumach-headers"))
+            ("cross-hurd-headers" ,@(assoc-ref (package-propagated-inputs libc)
+                                          "cross-hurd-headers"))
+            ("cross-hurd-minimal" ,@(assoc-ref (package-propagated-inputs libc)
+                                          "cross-hurd-minimal"))))
+         (arguments
+          `(#:phases (alist-delete
+                      'unpack
+                      (alist-delete
+                       'configure
+                       (alist-delete
+                        'build
+                        (alist-replace
+                         'install
+                         (lambda* (#:key inputs outputs #:allow-other-keys)
+                           (let* ((out  (assoc-ref outputs "out"))
+                                  (incdir (string-append out "/include"))
+                                  (libdir (string-append out "/lib"))
+                                  (mach (assoc-ref inputs "cross-gnumach-headers"))
+                                  (hurd (assoc-ref inputs "cross-hurd-headers"))
+                                  (hurd-minimal (assoc-ref inputs "cross-hurd-minimal")))
+                             (mkdir-p incdir)
+                             (mkdir-p libdir)
+                             (copy-recursively (string-append mach "/include") incdir)
+                             (copy-recursively (string-append hurd "/include") incdir)
+                             (copy-recursively (string-append hurd-minimal "/lib") libdir)
+                             #t))
+                         %standard-phases))))
+
+            #:tests? #f))
+         (home-page #f)
+         (synopsis #f)
+         (description #f)
+         (license gpl2+)))
+      (_
+       (assoc-ref (package-propagated-inputs libc) "linux-headers"))))
+  
   (package (inherit %xgcc)
     (name (string-append "gcc-cross-"
                          (if libc "" "sans-libc-")
@@ -267,9 +318,8 @@ GCC that does not target a libc; otherwise, target that libc."
                                (alist-delete "libc" %final-inputs))))
            (if libc
                `(("libc" ,libc)
-                 ("xlinux-headers"                ;the target headers
-                  ,@(assoc-ref (package-propagated-inputs libc)
-                               "linux-headers"))
+                 ("xkernel-headers"                ;the target headers
+                  ,(cross-kernel-headers target libc))
                  ,@inputs)
                inputs))))
 
-- 
2.4.6

Reply via email to