unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob 501a2215a1e4067a4bb9c5b6ef1edf53412be626 8328 bytes (raw)
name: guix/build/cross-base.scm 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
 
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guix build cross-base)
  #:use-module (guix licenses)
  #:use-module (gnu packages)
  #:use-module (guix packages)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system trivial)
  #:use-module (guix build utils)
  #:use-module (guix utils)
  #:use-module (gnu packages base)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages hurd)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:use-module (ice-9 match)
  #:use-module (ice-9 regex)
  #:export (cross-mig)
  #:export (cross-kernel-headers)
  #:export (cross-libc-for-target))

(define (cross-mig target xgcc xbinutils)
  "Return MiG cross-built for TARGET."

  (define xgnumach-headers
    (package (inherit gnumach-headers)
      (name (string-append (package-name gnumach-headers)
                           "-cross-" target))

      (native-inputs `(("cross-gcc" ,xgcc)
                       ("cross-binutils" ,xbinutils)
                       ,@(package-native-inputs gnumach-headers)))))

  (package (inherit mig)
    (name (string-append "mig-cross"))
    (arguments
     `(#:modules ((guix build gnu-build-system)
                  (guix build utils)
                  (srfi srfi-26))
       #:phases (alist-cons-before
                 'configure 'set-cross-headers-path
                 (lambda* (#:key inputs #:allow-other-keys)
                   (let* ((mach (assoc-ref inputs "cross-gnumach-headers"))
                          (cpath (string-append mach "/include")))
                     (for-each (cut setenv <> cpath)
                               '("CROSS_C_INCLUDE_PATH"
                                 "CROSS_CPLUS_INCLUDE_PATH"
                                 "CROSS_OBJC_INCLUDE_PATH"
                                 "CROSS_OBJCPLUS_INCLUDE_PATH"))))
                 %standard-phases)
       #:configure-flags (list ,(string-append "--target=" target))
       ,@(package-arguments mig)))

    (propagated-inputs `(("cross-gnumach-headers" ,xgnumach-headers)))
    (native-inputs `(("cross-gcc" ,xgcc)
                     ("cross-binutils" ,xbinutils)
                     ,@(package-native-inputs mig)))))



(define (cross-kernel-headers target xgcc xbinutils)
  "Return headers depending on TARGET."

  (define xlinux-headers
    (package (inherit linux-libre-headers)
      (name (string-append (package-name linux-libre-headers)
                           "-cross-" target))
      (arguments
       (substitute-keyword-arguments
           `(#:implicit-cross-inputs? #f
             ,@(package-arguments linux-libre-headers))
         ((#:phases phases)
          `(alist-replace
            'build
            (lambda _
              (setenv "ARCH" ,(system->linux-architecture target))
              (format #t "`ARCH' set to `~a' (cross compiling)~%" (getenv "ARCH"))
              (and (zero? (system* "make" "defconfig"))
                   (zero? (system* "make" "mrproper" "headers_check"))))
            ,phases))))
      (native-inputs `(("cross-gcc" ,xgcc)
                       ("cross-binutils" ,xbinutils)
                       ,@(package-native-inputs linux-libre-headers)))))

  (define xgnumach-headers
    (package (inherit gnumach-headers)
      (name (string-append (package-name gnumach-headers)
                           "-cross-" target))

      (native-inputs `(("cross-gcc" ,xgcc)
                       ("cross-binutils" ,xbinutils)
                       ,@(package-native-inputs gnumach-headers)))))

  (define xhurd-headers
    (package (inherit hurd-headers)
      (name (string-append (package-name hurd-headers)
                           "-cross-" target))

      (native-inputs `(("cross-gcc" ,xgcc)
                       ("cross-binutils" ,xbinutils)
                       ("cross-mig" ,(cross-mig target xgcc xbinutils))
                       ,@(alist-delete "mig"(package-native-inputs hurd-headers))))))

  (define xglibc/hurd-headers
    (package (inherit glibc/hurd-headers)
      (name (string-append (package-name glibc/hurd-headers)
                           "-cross-" target))

      (arguments
       (substitute-keyword-arguments
           `(#:modules ((guix build gnu-build-system)
                        (guix build utils)
                        (srfi srfi-26))
             ,@(package-arguments glibc/hurd-headers))
         ((#:phases phases)
          `(alist-cons-before
            'pre-configure 'set-cross-headers-path
            (lambda* (#:key inputs #:allow-other-keys)
              (let* ((mach (assoc-ref inputs "gnumach-headers"))
                     (hurd (assoc-ref inputs "hurd-headers"))
                     (cpath (string-append mach "/include:"
                                           hurd "/include")))
                (for-each (cut setenv <> cpath)
                          '("CROSS_C_INCLUDE_PATH"
                            "CROSS_CPLUS_INCLUDE_PATH"
                            "CROSS_OBJC_INCLUDE_PATH"
                            "CROSS_OBJCPLUS_INCLUDE_PATH"))))
            ,phases))))

      (propagated-inputs `(("gnumach-headers" ,xgnumach-headers)
                           ("hurd-headers" ,xhurd-headers)))

      (native-inputs `(("cross-gcc" ,xgcc)
                       ("cross-binutils" ,xbinutils)
                       ("cross-mig" ,(cross-mig target xgcc xbinutils))
                       ,@(alist-delete "mig"(package-native-inputs glibc/hurd-headers))))))

  (define xhurd-minimal
    (package (inherit hurd-minimal)
      (name (string-append (package-name hurd-minimal)
                           "-cross-" target))
      (arguments
       (substitute-keyword-arguments
           `(#:modules ((guix build gnu-build-system)
                        (guix build utils)
                        (srfi srfi-26))
             ,@(package-arguments hurd-minimal))
         ((#:phases phases)
          `(alist-cons-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")))
                (for-each (cut setenv <> cpath)
                          '("CROSS_C_INCLUDE_PATH"
                            "CROSS_CPLUS_INCLUDE_PATH"
                            "CROSS_OBJC_INCLUDE_PATH"
                            "CROSS_OBJCPLUS_INCLUDE_PATH"))))
            ,phases))))

      (inputs `(("cross-glibc-hurd-headers" ,xglibc/hurd-headers)))

      (native-inputs `(("cross-gcc" ,xgcc)
                       ("cross-binutils" ,xbinutils)
                       ("cross-mig" ,(cross-mig target xgcc xbinutils))
                       ,@(alist-delete "mig"(package-native-inputs hurd-minimal))))))

  (define xhurd-core-headers
    (package (inherit hurd-core-headers)
      (name (string-append (package-name hurd-core-headers)
                           "-cross-" target))

      (inputs `(("gnumach-headers" ,xgnumach-headers)
                ("hurd-headers" ,xhurd-headers)
                ("hurd-minimal" ,xhurd-minimal)))

      (native-inputs `(("cross-gcc" ,xgcc)
                       ("cross-binutils" ,xbinutils)
                       ,@(package-native-inputs hurd-core-headers)))))

  (match target
    ((or "i586-pc-gnu" "i586-gnu") xhurd-core-headers)
    (_ xlinux-headers)))

(define (cross-libc-for-target target)
  "Return libc depending on TARGET."
  (match target
    ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
    (_ glibc/linux)))

debug log:

solving 501a221 ...
found 501a221 in https://yhetil.org/guix-devel/6bf591cf-2ea4-01fc-bd13-23ae60864714@gmail.com/

applying [1/1] https://yhetil.org/guix-devel/6bf591cf-2ea4-01fc-bd13-23ae60864714@gmail.com/
diff --git a/guix/build/cross-base.scm b/guix/build/cross-base.scm
new file mode 100644
index 0000000..501a221

Checking patch guix/build/cross-base.scm...
Applied patch guix/build/cross-base.scm cleanly.

index at:
100644 501a2215a1e4067a4bb9c5b6ef1edf53412be626	guix/build/cross-base.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).