xen-blkback: fix persistent grants negotiation
[linux-2.6-microblaze.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 := $(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
21 suffix-y                                :=
22 suffix-$(CONFIG_MODULE_COMPRESS_GZIP)   := .gz
23 suffix-$(CONFIG_MODULE_COMPRESS_XZ)     := .xz
24 suffix-$(CONFIG_MODULE_COMPRESS_ZSTD)   := .zst
25
26 modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules))
27
28 __modinst: $(modules)
29         @:
30
31 #
32 # Installation
33 #
34 quiet_cmd_install = INSTALL $@
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
55
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)
66 sig-key := $(if $(wildcard $(CONFIG_MODULE_SIG_KEY)),,$(srctree)/)$(CONFIG_MODULE_SIG_KEY)
67 quiet_cmd_sign = SIGN    $@
68       cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(sig-key) certs/signing_key.x509 $@ \
69                  $(if $(KBUILD_EXTMOD),|| true)
70 else
71 quiet_cmd_sign :=
72       cmd_sign := :
73 endif
74
75 ifeq ($(modules_sign_only),)
76
77 $(dst)/%.ko: $(extmod_prefix)%.ko FORCE
78         $(call cmd,install)
79         $(call cmd,strip)
80         $(call cmd,sign)
81
82 else
83
84 $(dst)/%.ko: FORCE
85         $(call cmd,sign)
86
87 endif
88
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 $<
96 quiet_cmd_zstd = ZSTD    $@
97       cmd_zstd = $(ZSTD) -T0 --rm -f -q $<
98
99 $(dst)/%.ko.gz: $(dst)/%.ko FORCE
100         $(call cmd,gzip)
101
102 $(dst)/%.ko.xz: $(dst)/%.ko FORCE
103         $(call cmd,xz)
104
105 $(dst)/%.ko.zst: $(dst)/%.ko FORCE
106         $(call cmd,zstd)
107
108 PHONY += FORCE
109 FORCE:
110
111 .PHONY: $(PHONY)