1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2017 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
3 ;;; Copyright © 2015, 2019 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (guix build make-bootstrap)
22 #:use-module (srfi srfi-1)
23 #:use-module (srfi srfi-11)
24 #:use-module (srfi srfi-19)
25 #:use-module (srfi srfi-26)
26 #:use-module (guix build utils)
27 #:export (copy-linux-headers
32 ;; This module provides facilities to build the bootstrap binaries.
36 (define (copy-linux-headers output kernel-headers)
37 "Copy to OUTPUT the subset of KERNEL-HEADERS that is needed when producing a
40 (let* ((incdir (string-append output "/include")))
43 ;; Copy some of the Linux-Libre headers that glibc headers
45 (mkdir (string-append incdir "/linux"))
46 (for-each (lambda (file)
47 (install-file (pk 'src (string-append kernel-headers "/include/linux/" file))
48 (pk 'dest (string-append incdir "/linux"))))
53 "if_addr.h" ; for 2.16.0
54 "if_ether.h" ; for 2.2.5
55 "if_link.h" ; for 2.16.0
59 "neighbour.h" ; for 2.16.0
60 "netlink.h" ; for 2.16.0
62 "prctl.h" ; for 2.16.0
64 "rtnetlink.h" ; for 2.16.0
69 "sysinfo.h" ; for 2.2.5
71 "version.h" ; for 2.2.5
74 (copy-recursively (string-append kernel-headers "/include/asm")
75 (string-append incdir "/asm"))
76 (copy-recursively (string-append kernel-headers "/include/asm-generic")
77 (string-append incdir "/asm-generic"))
78 (copy-recursively (string-append kernel-headers "/include/linux/byteorder")
79 (string-append incdir "/linux/byteorder"))
82 (define (make-stripped-libc output libc kernel-headers)
83 "Copy to OUTPUT the subset of LIBC and KERNEL-HEADERS that is needed
84 when producing a bootstrap libc."
86 (define (copy-mach-headers output kernel-headers)
87 (let* ((incdir (string-append output "/include")))
88 (copy-recursively (string-append libc "/include") incdir)
90 (copy-recursively (string-append kernel-headers "/include/mach")
91 (string-append incdir "/mach"))
94 (define (copy-libc+linux-headers output kernel-headers)
95 (let* ((incdir (string-append output "/include")))
96 (copy-recursively (string-append libc "/include") incdir)
97 (copy-linux-headers output kernel-headers)))
99 (define %libc-object-files-rx "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|\
100 util).*\\.so(\\..*)?|lib(machuser|hurduser).so.*|(libc(rt|)|libpthread)\
103 (setvbuf (current-output-port) 'line)
104 (let* ((libdir (string-append output "/lib")))
106 (for-each (lambda (file)
107 (let ((target (string-append libdir "/"
109 (copy-file file target)
110 (remove-store-references target)))
111 (find-files (string-append libc "/lib") %libc-object-files-rx))
114 (if (directory-exists? (string-append kernel-headers "/include/mach"))
115 (copy-mach-headers output kernel-headers)
116 (copy-libc+linux-headers output kernel-headers)))