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