Commit | Line | Data |
---|---|---|
ce631299 DM |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2019 Danny Milosavljevic <dannym@scratchpost.org> | |
3 | ;;; | |
4 | ;;; This file is part of GNU Guix. | |
5 | ;;; | |
6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
7 | ;;; under the terms of the GNU General Public License as published by | |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
9 | ;;; your option) any later version. | |
10 | ;;; | |
11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | ;;; GNU General Public License for more details. | |
15 | ;;; | |
16 | ;;; You should have received a copy of the GNU General Public License | |
17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
18 | ||
19 | (define-module (guix build linux-module-build-system) | |
20 | #:use-module ((guix build gnu-build-system) #:prefix gnu:) | |
21 | #:use-module (guix build utils) | |
22 | #:use-module (ice-9 ftw) | |
23 | #:use-module (ice-9 match) | |
24 | #:use-module (srfi srfi-1) | |
25 | #:use-module (srfi srfi-26) | |
26 | #:export (%standard-phases | |
27 | linux-module-build)) | |
28 | ||
29 | ;; Commentary: | |
30 | ;; | |
31 | ;; Builder-side code of linux-module build. | |
32 | ;; | |
33 | ;; Code: | |
34 | ||
ce631299 DM |
35 | (define* (build #:key inputs make-flags #:allow-other-keys) |
36 | (apply invoke "make" "-C" | |
37 | (string-append (assoc-ref inputs "linux-module-builder") | |
38 | "/lib/modules/build") | |
39 | (string-append "M=" (getcwd)) | |
40 | (or make-flags '()))) | |
41 | ||
42 | ;; This block was copied from make-linux-libre--only took the "modules_install" | |
43 | ;; part. | |
44 | (define* (install #:key inputs native-inputs outputs #:allow-other-keys) | |
45 | (let* ((out (assoc-ref outputs "out")) | |
46 | (moddir (string-append out "/lib/modules")) | |
47 | (kmod (assoc-ref (or native-inputs inputs) "kmod"))) | |
48 | ;; Install kernel modules | |
49 | (mkdir-p moddir) | |
50 | (invoke "make" "-C" | |
51 | (string-append (assoc-ref inputs "linux-module-builder") | |
52 | "/lib/modules/build") | |
53 | (string-append "M=" (getcwd)) | |
54 | (string-append "DEPMOD=" kmod "/bin/depmod") | |
55 | (string-append "MODULE_DIR=" moddir) | |
56 | (string-append "INSTALL_PATH=" out) | |
57 | (string-append "INSTALL_MOD_PATH=" out) | |
58 | "INSTALL_MOD_STRIP=1" | |
59 | "modules_install"))) | |
60 | ||
61 | (define %standard-phases | |
62 | (modify-phases gnu:%standard-phases | |
88e13c25 | 63 | (delete 'configure) |
ce631299 DM |
64 | (replace 'build build) |
65 | (replace 'install install))) | |
66 | ||
67 | (define* (linux-module-build #:key inputs (phases %standard-phases) | |
68 | #:allow-other-keys #:rest args) | |
69 | "Build the given package, applying all of PHASES in order, with a Linux kernel in attendance." | |
70 | (apply gnu:gnu-build | |
71 | #:inputs inputs #:phases phases | |
72 | args)) | |
73 | ||
74 | ;;; linux-module-build-system.scm ends here |