Commit | Line | Data |
---|---|---|
b2441318 | 1 | # SPDX-License-Identifier: GPL-2.0 |
1da177e4 LT |
2 | # ========================================================================== |
3 | # Installing modules | |
4 | # ========================================================================== | |
5 | ||
4f193362 | 6 | PHONY := __modinst |
1da177e4 LT |
7 | __modinst: |
8 | ||
65ce9c38 | 9 | include include/config/auto.conf |
3204a7fb | 10 | include $(srctree)/scripts/Kbuild.include |
1da177e4 | 11 | |
ccae4cfa MY |
12 | modules := $(sort $(shell cat $(MODORDER))) |
13 | ||
14 | ifeq ($(KBUILD_EXTMOD),) | |
15 | dst := $(MODLIB)/kernel | |
16 | else | |
17 | INSTALL_MOD_DIR ?= extra | |
18 | dst := $(MODLIB)/$(INSTALL_MOD_DIR) | |
19 | endif | |
20 | ||
65ce9c38 MY |
21 | suffix-y := |
22 | suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz | |
23 | suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz | |
c3d7ef37 | 24 | suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst |
65ce9c38 MY |
25 | |
26 | modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules)) | |
1da177e4 | 27 | |
1da177e4 LT |
28 | __modinst: $(modules) |
29 | @: | |
30 | ||
65ce9c38 MY |
31 | # |
32 | # Installation | |
33 | # | |
ccae4cfa | 34 | quiet_cmd_install = INSTALL $@ |
65ce9c38 MY |
35 | cmd_install = mkdir -p $(dir $@); cp $< $@ |
36 | ||
37 | # Strip | |
38 | # | |
39 | # INSTALL_MOD_STRIP, if defined, will cause modules to be stripped after they | |
40 | # are installed. If INSTALL_MOD_STRIP is '1', then the default option | |
41 | # --strip-debug will be used. Otherwise, INSTALL_MOD_STRIP value will be used | |
42 | # as the options to the strip command. | |
43 | ifdef INSTALL_MOD_STRIP | |
44 | ||
45 | ifeq ($(INSTALL_MOD_STRIP),1) | |
46 | strip-option := --strip-debug | |
47 | else | |
48 | strip-option := $(INSTALL_MOD_STRIP) | |
49 | endif | |
50 | ||
51 | quiet_cmd_strip = STRIP $@ | |
52 | cmd_strip = $(STRIP) $(strip-option) $@ | |
53 | ||
54 | else | |
ccae4cfa | 55 | |
65ce9c38 MY |
56 | quiet_cmd_strip = |
57 | cmd_strip = : | |
58 | ||
59 | endif | |
60 | ||
61 | # | |
62 | # Signing | |
63 | # Don't stop modules_install even if we can't sign external modules. | |
64 | # | |
65 | ifeq ($(CONFIG_MODULE_SIG_ALL),y) | |
4db9c2e3 | 66 | sig-key := $(if $(wildcard $(CONFIG_MODULE_SIG_KEY)),,$(srctree)/)$(CONFIG_MODULE_SIG_KEY) |
65ce9c38 | 67 | quiet_cmd_sign = SIGN $@ |
4db9c2e3 | 68 | cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(sig-key) certs/signing_key.x509 $@ \ |
65ce9c38 MY |
69 | $(if $(KBUILD_EXTMOD),|| true) |
70 | else | |
71 | quiet_cmd_sign := | |
72 | cmd_sign := : | |
73 | endif | |
74 | ||
961ab4a3 MY |
75 | ifeq ($(modules_sign_only),) |
76 | ||
65ce9c38 | 77 | $(dst)/%.ko: $(extmod_prefix)%.ko FORCE |
ccae4cfa | 78 | $(call cmd,install) |
65ce9c38 MY |
79 | $(call cmd,strip) |
80 | $(call cmd,sign) | |
81 | ||
961ab4a3 MY |
82 | else |
83 | ||
84 | $(dst)/%.ko: FORCE | |
85 | $(call cmd,sign) | |
86 | ||
87 | endif | |
88 | ||
65ce9c38 MY |
89 | # |
90 | # Compression | |
91 | # | |
92 | quiet_cmd_gzip = GZIP $@ | |
93 | cmd_gzip = $(KGZIP) -n -f $< | |
94 | quiet_cmd_xz = XZ $@ | |
95 | cmd_xz = $(XZ) --lzma2=dict=2MiB -f $< | |
c3d7ef37 PG |
96 | quiet_cmd_zstd = ZSTD $@ |
97 | cmd_zstd = $(ZSTD) -T0 --rm -f -q $< | |
65ce9c38 MY |
98 | |
99 | $(dst)/%.ko.gz: $(dst)/%.ko FORCE | |
100 | $(call cmd,gzip) | |
101 | ||
102 | $(dst)/%.ko.xz: $(dst)/%.ko FORCE | |
103 | $(call cmd,xz) | |
ccae4cfa | 104 | |
c3d7ef37 PG |
105 | $(dst)/%.ko.zst: $(dst)/%.ko FORCE |
106 | $(call cmd,zstd) | |
107 | ||
ccae4cfa MY |
108 | PHONY += FORCE |
109 | FORCE: | |
4f193362 | 110 | |
4f193362 | 111 | .PHONY: $(PHONY) |