1 # SPDX-License-Identifier: GPL-2.0 1 # SPDX-License-Identifier: GPL-2.0 2 # ============================================ 2 # ========================================================================== 3 # Installing modules 3 # Installing modules 4 # ============================================ 4 # ========================================================================== 5 5 6 PHONY := __modinst 6 PHONY := __modinst 7 __modinst: 7 __modinst: 8 8 9 include include/config/auto.conf 9 include include/config/auto.conf 10 include $(srctree)/scripts/Kbuild.include 10 include $(srctree)/scripts/Kbuild.include 11 11 12 install-y := << 13 << 14 ifeq ($(KBUILD_EXTMOD)$(sign-only),) << 15 << 16 # remove the old directory and symlink << 17 $(shell rm -fr $(MODLIB)/kernel $(MODLIB)/buil << 18 << 19 install-$(CONFIG_MODULES) += $(addprefix $(MOD << 20 << 21 $(MODLIB)/build: FORCE << 22 $(call cmd,symlink) << 23 << 24 quiet_cmd_symlink = SYMLINK $@ << 25 cmd_symlink = ln -s $(CURDIR) $@ << 26 << 27 $(MODLIB)/modules.order: modules.order FORCE << 28 $(call cmd,install_modorder) << 29 << 30 quiet_cmd_install_modorder = INSTALL $@ << 31 cmd_install_modorder = sed 's:^\(.*\)\.o << 32 << 33 # Install modules.builtin(.modinfo,.ranges) ev << 34 install-y += $(addprefix $(MODLIB)/, modules.b << 35 << 36 install-$(CONFIG_BUILTIN_MODULE_RANGES) += $(M << 37 << 38 $(addprefix $(MODLIB)/, modules.builtin module << 39 $(call cmd,install) << 40 << 41 endif << 42 << 43 modules := $(call read-file, $(MODORDER)) 12 modules := $(call read-file, $(MODORDER)) 44 13 45 ifeq ($(KBUILD_EXTMOD),) 14 ifeq ($(KBUILD_EXTMOD),) 46 dst := $(MODLIB)/kernel 15 dst := $(MODLIB)/kernel 47 else 16 else 48 INSTALL_MOD_DIR ?= updates 17 INSTALL_MOD_DIR ?= updates 49 dst := $(MODLIB)/$(INSTALL_MOD_DIR) 18 dst := $(MODLIB)/$(INSTALL_MOD_DIR) 50 endif 19 endif 51 20 52 $(foreach x, % :, $(if $(findstring $x, $(dst) 21 $(foreach x, % :, $(if $(findstring $x, $(dst)), \ 53 $(error module installation path canno 22 $(error module installation path cannot contain '$x'))) 54 23 55 suffix-y := 24 suffix-y := 56 ifdef CONFIG_MODULE_COMPRESS_ALL << 57 suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz 25 suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz 58 suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz 26 suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz 59 suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zs 27 suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst 60 endif << 61 28 62 modules := $(patsubst $(extmod_prefix)%.o, $(d 29 modules := $(patsubst $(extmod_prefix)%.o, $(dst)/%.ko$(suffix-y), $(modules)) 63 install-$(CONFIG_MODULES) += $(modules) << 64 30 65 __modinst: $(install-y) !! 31 __modinst: $(modules) 66 @: 32 @: 67 33 68 # 34 # 69 # Installation 35 # Installation 70 # 36 # 71 quiet_cmd_install = INSTALL $@ 37 quiet_cmd_install = INSTALL $@ 72 cmd_install = cp $< $@ !! 38 cmd_install = mkdir -p $(dir $@); cp $< $@ 73 39 74 # Strip 40 # Strip 75 # 41 # 76 # INSTALL_MOD_STRIP, if defined, will cause mo 42 # INSTALL_MOD_STRIP, if defined, will cause modules to be stripped after they 77 # are installed. If INSTALL_MOD_STRIP is '1', 43 # are installed. If INSTALL_MOD_STRIP is '1', then the default option 78 # --strip-debug will be used. Otherwise, INSTA 44 # --strip-debug will be used. Otherwise, INSTALL_MOD_STRIP value will be used 79 # as the options to the strip command. 45 # as the options to the strip command. 80 ifdef INSTALL_MOD_STRIP 46 ifdef INSTALL_MOD_STRIP 81 47 82 ifeq ($(INSTALL_MOD_STRIP),1) 48 ifeq ($(INSTALL_MOD_STRIP),1) 83 strip-option := --strip-debug 49 strip-option := --strip-debug 84 else 50 else 85 strip-option := $(INSTALL_MOD_STRIP) 51 strip-option := $(INSTALL_MOD_STRIP) 86 endif 52 endif 87 53 88 quiet_cmd_strip = STRIP $@ 54 quiet_cmd_strip = STRIP $@ 89 cmd_strip = $(STRIP) $(strip-option) $@ 55 cmd_strip = $(STRIP) $(strip-option) $@ 90 56 91 else 57 else 92 58 93 quiet_cmd_strip = 59 quiet_cmd_strip = 94 cmd_strip = : 60 cmd_strip = : 95 61 96 endif 62 endif 97 63 98 # 64 # 99 # Signing 65 # Signing 100 # Don't stop modules_install even if we can't 66 # Don't stop modules_install even if we can't sign external modules. 101 # 67 # >> 68 ifeq ($(CONFIG_MODULE_SIG_ALL),y) 102 ifeq ($(filter pkcs11:%, $(CONFIG_MODULE_SIG_K 69 ifeq ($(filter pkcs11:%, $(CONFIG_MODULE_SIG_KEY)),) 103 sig-key := $(if $(wildcard $(CONFIG_MODULE_SIG 70 sig-key := $(if $(wildcard $(CONFIG_MODULE_SIG_KEY)),,$(srctree)/)$(CONFIG_MODULE_SIG_KEY) 104 else 71 else 105 sig-key := $(CONFIG_MODULE_SIG_KEY) 72 sig-key := $(CONFIG_MODULE_SIG_KEY) 106 endif 73 endif 107 quiet_cmd_sign = SIGN $@ 74 quiet_cmd_sign = SIGN $@ 108 cmd_sign = scripts/sign-file $(CONFIG_MO 75 cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \ 109 $(if $(KBUILD_EXTMOD),|| true 76 $(if $(KBUILD_EXTMOD),|| true) 110 !! 77 else 111 ifeq ($(sign-only),) << 112 << 113 # During modules_install, modules are signed o << 114 ifndef CONFIG_MODULE_SIG_ALL << 115 quiet_cmd_sign := 78 quiet_cmd_sign := 116 cmd_sign := : 79 cmd_sign := : 117 endif 80 endif 118 81 119 # Create necessary directories !! 82 ifeq ($(modules_sign_only),) 120 $(foreach dir, $(sort $(dir $(install-y))), $( << 121 83 122 $(dst)/%.ko: $(extmod_prefix)%.ko FORCE 84 $(dst)/%.ko: $(extmod_prefix)%.ko FORCE 123 $(call cmd,install) 85 $(call cmd,install) 124 $(call cmd,strip) 86 $(call cmd,strip) 125 $(call cmd,sign) 87 $(call cmd,sign) 126 88 127 ifdef CONFIG_MODULES << 128 __modinst: depmod << 129 << 130 PHONY += depmod << 131 depmod: $(install-y) << 132 $(call cmd,depmod) << 133 << 134 quiet_cmd_depmod = DEPMOD $(MODLIB) << 135 cmd_depmod = $(srctree)/scripts/depmod.s << 136 endif << 137 << 138 else 89 else 139 90 140 $(dst)/%.ko: FORCE 91 $(dst)/%.ko: FORCE 141 $(call cmd,sign) 92 $(call cmd,sign) 142 93 143 endif 94 endif 144 95 145 # 96 # 146 # Compression 97 # Compression 147 # 98 # 148 quiet_cmd_gzip = GZIP $@ 99 quiet_cmd_gzip = GZIP $@ 149 cmd_gzip = $(KGZIP) -n -f $< 100 cmd_gzip = $(KGZIP) -n -f $< 150 quiet_cmd_xz = XZ $@ 101 quiet_cmd_xz = XZ $@ 151 cmd_xz = $(XZ) --check=crc32 --lzma2=dic !! 102 cmd_xz = $(XZ) --lzma2=dict=2MiB -f $< 152 quiet_cmd_zstd = ZSTD $@ 103 quiet_cmd_zstd = ZSTD $@ 153 cmd_zstd = $(ZSTD) --rm -f -q $< !! 104 cmd_zstd = $(ZSTD) -T0 --rm -f -q $< 154 105 155 $(dst)/%.ko.gz: $(dst)/%.ko FORCE 106 $(dst)/%.ko.gz: $(dst)/%.ko FORCE 156 $(call cmd,gzip) 107 $(call cmd,gzip) 157 108 158 $(dst)/%.ko.xz: $(dst)/%.ko FORCE 109 $(dst)/%.ko.xz: $(dst)/%.ko FORCE 159 $(call cmd,xz) 110 $(call cmd,xz) 160 111 161 $(dst)/%.ko.zst: $(dst)/%.ko FORCE 112 $(dst)/%.ko.zst: $(dst)/%.ko FORCE 162 $(call cmd,zstd) 113 $(call cmd,zstd) 163 114 164 PHONY += FORCE 115 PHONY += FORCE 165 FORCE: 116 FORCE: 166 117 167 .PHONY: $(PHONY) 118 .PHONY: $(PHONY)
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.