Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / hurd.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2015, 2016, 2017 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
3 ;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
6 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
7 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
14 ;;;
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23 (define-module (gnu packages hurd)
24 #:use-module (guix licenses)
25 #:use-module (guix download)
26 #:use-module (guix packages)
27 #:use-module (gnu packages)
28 #:use-module (guix utils)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix build-system trivial)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages flex)
33 #:use-module (gnu packages bison)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages base)
36 #:use-module (gnu packages texinfo)
37 #:use-module (guix git-download)
38 #:export (hurd-system?
39 hurd-target?
40 hurd-triplet?))
41
42 (define (hurd-triplet? triplet)
43 (and (string-suffix? "-gnu" triplet)
44 (not (string-contains triplet "linux"))))
45
46 (define (hurd-target?)
47 "Return true if the cross-compilation target or the current system is
48 GNU/Hurd."
49 (or (and=> (%current-target-system) hurd-triplet?)
50 (and (not (%current-target-system))
51 (and=> (%current-system) hurd-triplet?))))
52
53 (define (hurd-system?)
54 "Return true if the current system is the Hurd."
55 (and=> (%current-system) hurd-triplet?))
56
57 (define (hurd-source-url version)
58 (string-append "mirror://gnu/hurd/hurd-"
59 version ".tar.gz"))
60
61 (define-public gnumach-headers
62 (let ((commit "097f9cf735ffa1212b828682ad92f0f6c5f1c552")
63 (revision "1"))
64 (package
65 (name "gnumach-headers")
66 (version (git-version "1.8" revision commit))
67 (source
68 (origin
69 (method git-fetch)
70 (uri (git-reference
71 (url "https://git.savannah.gnu.org/git/hurd/gnumach.git")
72 (commit commit)))
73 (file-name (git-file-name "gnumach" version))
74 (sha256
75 (base32
76 "0q36z7k02bykrld90zaxbhyzxlmwlqqs4divgir6ix38zsp6icqk"))))
77 (build-system gnu-build-system)
78 (arguments
79 `(#:phases
80 (modify-phases %standard-phases
81 (replace 'install
82 (lambda _
83 (invoke "make" "install-data")))
84 (delete 'build))
85
86 ;; GNU Mach supports only IA32 currently, so cheat so that we can at
87 ;; least install its headers.
88 ,@(if (%current-target-system)
89 '()
90 ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-06/msg00042.html>
91 ;; <http://lists.gnu.org/archive/html/guix-devel/2015-06/msg00716.html>
92 '(#:configure-flags '("--build=i586-pc-gnu"
93 "--host=i686-linux-gnu")))
94
95 #:tests? #f))
96 (native-inputs
97 `(("autoconf" ,autoconf)
98 ("automake" ,automake)
99 ("texinfo" ,texinfo-4)))
100 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/gnumach.html")
101 (synopsis "GNU Mach kernel headers")
102 (description
103 "Headers of the GNU Mach kernel.")
104 (license gpl2+))))
105
106 (define-public mig
107 (package
108 (name "mig")
109 (version "1.8")
110 (source
111 (origin
112 (method url-fetch)
113 (uri (string-append "mirror://gnu/mig/mig-"
114 version ".tar.gz"))
115 (sha256
116 (base32
117 "1gyda8sq6b379nx01hkpbd85lz39irdvz2b9wbr63gicicx8i706"))))
118 (build-system gnu-build-system)
119 ;; Flex is needed both at build and run time.
120 (inputs `(("gnumach-headers" ,gnumach-headers)
121 ("flex" ,flex)))
122 (native-inputs
123 `(("flex" ,flex)
124 ("bison" ,bison)))
125 (arguments `(#:tests? #f))
126 (home-page "https://www.gnu.org/software/hurd/microkernel/mach/mig/gnu_mig.html")
127 (synopsis "Mach 3.0 interface generator for the Hurd")
128 (description
129 "GNU MIG is the GNU distribution of the Mach 3.0 interface generator
130 MIG, as maintained by the GNU Hurd developers for the GNU project.
131 You need this tool to compile the GNU Mach and GNU Hurd distributions,
132 and to compile the GNU C library for the Hurd. Also, you will need it
133 for other software in the GNU system that uses Mach-based inter-process
134 communication.")
135 (license gpl2+)))
136
137 (define-public hurd-headers
138 ;; Resort to a post-0.9 snapshot that provides the 'file_utimens' and
139 ;; 'file_exec_paths' RPCs that glibc 2.28 expects.
140 (let ((revision "1")
141 (commit "91a51672ff4cfe1f1a0712b4c542ded3081c825b"))
142 (package
143 (name "hurd-headers")
144 (version (git-version "0.9" revision commit))
145 (source (origin
146 (method git-fetch)
147 (uri (git-reference
148 (url "https://git.savannah.gnu.org/git/hurd/hurd.git")
149 (commit commit)))
150 (sha256
151 (base32
152 "16k9wkahz9wasviijz53n6i13nmiwa9fs64ikf1jqh8rl60hw7cz"))
153 (file-name (git-file-name name version))))
154 (build-system gnu-build-system)
155 (native-inputs
156 `(("mig" ,mig)
157 ("autoconf" ,autoconf)
158 ("automake" ,automake)))
159 (arguments
160 `(#:phases
161 (modify-phases %standard-phases
162 (replace 'install
163 (lambda _
164 (invoke "make" "install-headers" "no_deps=t")))
165 (delete 'build))
166
167 #:configure-flags '( ;; Pretend we're on GNU/Hurd; 'configure' wants
168 ;; that.
169 ,@(if (%current-target-system)
170 '()
171 '("--host=i586-pc-gnu"))
172
173 ;; Reduce set of dependencies.
174 "--without-parted"
175 "--disable-ncursesw"
176 "--disable-test"
177 "--without-libbz2"
178 "--without-libcrypt"
179 "--without-libz"
180 ;; Skip the clnt_create check because it expects
181 ;; a working glibc causing a circular dependency.
182 "ac_cv_search_clnt_create=no"
183
184 ;; Annihilate the checks for the 'file_exec_paths'
185 ;; & co. libc functions to avoid "link tests are
186 ;; not allowed after AC_NO_EXECUTABLES" error.
187 "ac_cv_func_file_exec_paths=no"
188 "ac_cv_func_exec_exec_paths=no"
189 "ac_cv_func__hurd_exec_paths=no"
190 "ac_cv_func_file_futimens=no")
191
192 #:tests? #f))
193 (home-page "https://www.gnu.org/software/hurd/hurd.html")
194 (synopsis "GNU Hurd headers")
195 (description
196 "This package provides C headers of the GNU Hurd, used to build the GNU C
197 Library and other user programs.")
198 (license gpl2+))))
199
200 (define-public hurd-minimal
201 (package (inherit hurd-headers)
202 (name "hurd-minimal")
203 (inputs `(("glibc-hurd-headers" ,glibc/hurd-headers)))
204 (arguments
205 (substitute-keyword-arguments (package-arguments hurd-headers)
206 ((#:phases _)
207 '(modify-phases %standard-phases
208 (replace 'install
209 (lambda* (#:key outputs #:allow-other-keys)
210 (let ((out (assoc-ref outputs "out")))
211 ;; We need to copy libihash.a to the output directory manually,
212 ;; since there is no target for that in the makefile.
213 (mkdir-p (string-append out "/include"))
214 (copy-file "libihash/ihash.h"
215 (string-append out "/include/ihash.h"))
216 (mkdir-p (string-append out "/lib"))
217 (copy-file "libihash/libihash.a"
218 (string-append out "/lib/libihash.a"))
219 #t)))
220 (replace 'build
221 (lambda _
222 ;; Install <assert-backtrace.h> & co.
223 (invoke "make" "-Clibshouldbeinlibc"
224 "../include/assert-backtrace.h")
225
226 ;; Build libihash.
227 (invoke "make" "-Clibihash" "libihash.a")))))))
228 (home-page "https://www.gnu.org/software/hurd/hurd.html")
229 (synopsis "GNU Hurd libraries")
230 (description
231 "This package provides libihash, needed to build the GNU C
232 Library for GNU/Hurd.")
233 (license gpl2+)))
234
235 (define-public hurd-core-headers
236 (package
237 (name "hurd-core-headers")
238 (version (package-version hurd-headers))
239 (source #f)
240 (build-system trivial-build-system)
241 (arguments
242 '(#:modules ((guix build union))
243 #:builder (begin
244 (use-modules (ice-9 match)
245 (guix build union))
246 (match %build-inputs
247 (((names . directories) ...)
248 (union-build (assoc-ref %outputs "out")
249 directories)
250 #t)))))
251 (inputs `(("gnumach-headers" ,gnumach-headers)
252 ("hurd-headers" ,hurd-headers)
253 ("hurd-minimal" ,hurd-minimal)))
254 (synopsis "Union of the Hurd headers and libraries")
255 (description
256 "This package contains the union of the Mach and Hurd headers and the
257 Hurd-minimal package which are needed for both glibc and GCC.")
258 (home-page (package-home-page hurd-headers))
259 (license (package-license hurd-headers))))
260
261 (define-public gnumach
262 (package
263 (inherit gnumach-headers)
264 (name "gnumach")
265 (arguments
266 `(#:phases (modify-phases %standard-phases
267 (add-after 'install 'produce-image
268 (lambda* (#:key outputs #:allow-other-keys)
269 (let* ((out (assoc-ref outputs "out"))
270 (boot (string-append out "/boot")))
271 (invoke "make" "gnumach.gz")
272 (install-file "gnumach.gz" boot)
273 #t))))))
274 (native-inputs
275 `(("mig" ,mig)
276 ("perl" ,perl)))
277 (supported-systems (cons "i686-linux" %hurd-systems))
278 (synopsis "Microkernel of the GNU system")
279 (description
280 "GNU Mach is the microkernel upon which a GNU Hurd system is based.")))
281
282 (define-public hurd
283 (package
284 (name "hurd")
285 (version (package-version hurd-headers))
286 (source (origin (inherit (package-source hurd-headers))
287 (patches (search-patches "hurd-cross.patch"))))
288 (arguments
289 `(#:phases
290 (modify-phases %standard-phases
291 (add-before 'build 'pre-build
292 (lambda _
293 ;; Don't change the ownership of any file at this time.
294 (substitute* '("daemons/Makefile" "utils/Makefile")
295 (("-o root -m 4755") ""))
296 #t)))
297 #:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
298 %output "/lib")
299 "--disable-ncursesw"
300 "--without-libbz2"
301 "--without-libz"
302 "--without-parted")))
303 (build-system gnu-build-system)
304 (inputs `(("glibc-hurd-headers" ,glibc/hurd-headers)))
305 (native-inputs
306 `(("autoconf" ,autoconf)
307 ("automake" ,automake)
308 ("mig" ,mig)
309 ("perl" ,perl)
310 ("texinfo" ,texinfo-4)))
311 (supported-systems %hurd-systems)
312 (home-page "https://www.gnu.org/software/hurd/hurd.html")
313 (synopsis "The kernel servers for the GNU operating system")
314 (description
315 "The Hurd is the kernel for the GNU system, a replacement and
316 augmentation of standard Unix kernels. It is a collection of protocols for
317 system interaction (file systems, networks, authentication), and servers
318 implementing them.")
319 (license gpl2+)))