1 # SPDX-License-Identifier: GPL-2.0 << 2 # ============================================ 1 # ========================================================================== 3 # Installing modules 2 # Installing modules 4 # ============================================ 3 # ========================================================================== 5 4 6 PHONY := __modinst 5 PHONY := __modinst 7 __modinst: 6 __modinst: 8 7 9 include include/config/auto.conf !! 8 include scripts/Kbuild.include 10 include $(srctree)/scripts/Kbuild.include << 11 9 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)) << 42 << 43 ifeq ($(KBUILD_EXTMOD),) << 44 dst := $(MODLIB)/kernel << 45 else << 46 INSTALL_MOD_DIR ?= updates << 47 dst := $(MODLIB)/$(INSTALL_MOD_DIR) << 48 endif << 49 << 50 $(foreach x, % :, $(if $(findstring $x, $(dst) << 51 $(error module installation path canno << 52 << 53 suffix-y := << 54 suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz << 55 suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz << 56 suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zs << 57 << 58 modules := $(patsubst $(extmod_prefix)%.o, $(d << 59 install-$(CONFIG_MODULES) += $(modules) << 60 << 61 __modinst: $(install-y) << 62 @: << 63 << 64 # << 65 # Installation << 66 # 10 # 67 quiet_cmd_install = INSTALL $@ << 68 cmd_install = cp $< $@ << 69 << 70 # Strip << 71 # << 72 # INSTALL_MOD_STRIP, if defined, will cause mo << 73 # are installed. If INSTALL_MOD_STRIP is '1', << 74 # --strip-debug will be used. Otherwise, INSTA << 75 # as the options to the strip command. << 76 ifdef INSTALL_MOD_STRIP << 77 << 78 ifeq ($(INSTALL_MOD_STRIP),1) << 79 strip-option := --strip-debug << 80 else << 81 strip-option := $(INSTALL_MOD_STRIP) << 82 endif << 83 << 84 quiet_cmd_strip = STRIP $@ << 85 cmd_strip = $(STRIP) $(strip-option) $@ << 86 << 87 else << 88 11 89 quiet_cmd_strip = !! 12 __modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard $(MODVERDIR)/*.mod))) 90 cmd_strip = : !! 13 modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) 91 14 92 endif !! 15 PHONY += $(modules) 93 !! 16 __modinst: $(modules) 94 # !! 17 @: 95 # Signing << 96 # Don't stop modules_install even if we can't << 97 # << 98 ifeq ($(filter pkcs11:%, $(CONFIG_MODULE_SIG_K << 99 sig-key := $(if $(wildcard $(CONFIG_MODULE_SIG << 100 else << 101 sig-key := $(CONFIG_MODULE_SIG_KEY) << 102 endif << 103 quiet_cmd_sign = SIGN $@ << 104 cmd_sign = scripts/sign-file $(CONFIG_MO << 105 $(if $(KBUILD_EXTMOD),|| true << 106 << 107 ifeq ($(sign-only),) << 108 << 109 # During modules_install, modules are signed o << 110 ifndef CONFIG_MODULE_SIG_ALL << 111 quiet_cmd_sign := << 112 cmd_sign := : << 113 endif << 114 << 115 # Create necessary directories << 116 $(foreach dir, $(sort $(dir $(install-y))), $( << 117 << 118 $(dst)/%.ko: $(extmod_prefix)%.ko FORCE << 119 $(call cmd,install) << 120 $(call cmd,strip) << 121 $(call cmd,sign) << 122 << 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 << 135 18 136 $(dst)/%.ko: FORCE !! 19 # Don't stop modules_install if we can't sign external modules. 137 $(call cmd,sign) !! 20 quiet_cmd_modules_install = INSTALL $@ >> 21 cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@) ; $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) 138 22 139 endif !! 23 # Modules built outside the kernel source tree go into extra by default >> 24 INSTALL_MOD_DIR ?= extra >> 25 ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D)) 140 26 141 # !! 27 modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) 142 # Compression << 143 # << 144 quiet_cmd_gzip = GZIP $@ << 145 cmd_gzip = $(KGZIP) -n -f $< << 146 quiet_cmd_xz = XZ $@ << 147 cmd_xz = $(XZ) --check=crc32 --lzma2=dic << 148 quiet_cmd_zstd = ZSTD $@ << 149 cmd_zstd = $(ZSTD) -T0 --rm -f -q $< << 150 << 151 $(dst)/%.ko.gz: $(dst)/%.ko FORCE << 152 $(call cmd,gzip) << 153 28 154 $(dst)/%.ko.xz: $(dst)/%.ko FORCE !! 29 $(modules): 155 $(call cmd,xz) !! 30 $(call cmd,modules_install,$(MODLIB)/$(modinst_dir)) 156 31 157 $(dst)/%.ko.zst: $(dst)/%.ko FORCE << 158 $(call cmd,zstd) << 159 32 160 PHONY += FORCE !! 33 # Declare the contents of the .PHONY variable as phony. We keep that 161 FORCE: !! 34 # information in a variable se we can use it in if_changed and friends. 162 35 163 .PHONY: $(PHONY) 36 .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.