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