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