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/Makefile.lib 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,.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)) << 44 << 45 ifeq ($(KBUILD_EXTMOD),) << 46 dst := $(MODLIB)/kernel << 47 else << 48 INSTALL_MOD_DIR ?= updates << 49 dst := $(MODLIB)/$(INSTALL_MOD_DIR) << 50 endif << 51 << 52 $(foreach x, % :, $(if $(findstring $x, $(dst) << 53 $(error module installation path canno << 54 << 55 suffix-y := << 56 ifdef CONFIG_MODULE_COMPRESS_ALL << 57 suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz << 58 suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz << 59 suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zs << 60 endif << 61 << 62 modules := $(patsubst $(extmod_prefix)%.o, $(d << 63 install-$(CONFIG_MODULES) += $(modules) << 64 << 65 __modinst: $(install-y) << 66 @: << 67 << 68 # << 69 # Installation << 70 # << 71 quiet_cmd_install = INSTALL $@ << 72 cmd_install = cp $< $@ << 73 << 74 # Strip << 75 # << 76 # INSTALL_MOD_STRIP, if defined, will cause mo << 77 # are installed. If INSTALL_MOD_STRIP is '1', << 78 # --strip-debug will be used. Otherwise, INSTA << 79 # as the options to the strip command. << 80 ifdef INSTALL_MOD_STRIP << 81 << 82 ifeq ($(INSTALL_MOD_STRIP),1) << 83 strip-option := --strip-debug << 84 else << 85 strip-option := $(INSTALL_MOD_STRIP) << 86 endif << 87 << 88 quiet_cmd_strip = STRIP $@ << 89 cmd_strip = $(STRIP) $(strip-option) $@ << 90 << 91 else << 92 << 93 quiet_cmd_strip = << 94 cmd_strip = : << 95 << 96 endif << 97 << 98 # << 99 # Signing << 100 # Don't stop modules_install even if we can't << 101 # 10 # 102 ifeq ($(filter pkcs11:%, $(CONFIG_MODULE_SIG_K << 103 sig-key := $(if $(wildcard $(CONFIG_MODULE_SIG << 104 else << 105 sig-key := $(CONFIG_MODULE_SIG_KEY) << 106 endif << 107 quiet_cmd_sign = SIGN $@ << 108 cmd_sign = scripts/sign-file $(CONFIG_MO << 109 $(if $(KBUILD_EXTMOD),|| true << 110 << 111 ifeq ($(sign-only),) << 112 << 113 # During modules_install, modules are signed o << 114 ifndef CONFIG_MODULE_SIG_ALL << 115 quiet_cmd_sign := << 116 cmd_sign := : << 117 endif << 118 11 119 # Create necessary directories !! 12 __modules := $(shell cat /dev/null $(wildcard $(MODVERDIR)/*.mod)) 120 $(foreach dir, $(sort $(dir $(install-y))), $( !! 13 modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) 121 14 122 $(dst)/%.ko: $(extmod_prefix)%.ko FORCE !! 15 ifneq ($(filter-out $(modules),$(__modules)),) 123 $(call cmd,install) !! 16 $(warning *** Uh-oh, you have stale module entries. You messed with SUBDIRS, do not complain if something goes wrong.) 124 $(call cmd,strip) << 125 $(call cmd,sign) << 126 << 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 17 endif 137 18 138 else !! 19 .PHONY: $(modules) >> 20 __modinst: $(modules) >> 21 @: 139 22 140 $(dst)/%.ko: FORCE !! 23 # Modules built within the kernel tree 141 $(call cmd,sign) << 142 24 143 endif !! 25 quiet_cmd_modules_install = INSTALL $@ >> 26 cmd_modules_install = mkdir -p $(MODLIB)/kernel/$(@D); \ >> 27 cp $@ $(MODLIB)/kernel/$(@D) 144 28 145 # !! 29 $(filter-out ../% /%,$(modules)): 146 # Compression !! 30 $(call cmd,modules_install) 147 # << 148 quiet_cmd_gzip = GZIP $@ << 149 cmd_gzip = $(KGZIP) -n -f $< << 150 quiet_cmd_xz = XZ $@ << 151 cmd_xz = $(XZ) --check=crc32 --lzma2=dic << 152 quiet_cmd_zstd = ZSTD $@ << 153 cmd_zstd = $(ZSTD) --rm -f -q $< << 154 << 155 $(dst)/%.ko.gz: $(dst)/%.ko FORCE << 156 $(call cmd,gzip) << 157 << 158 $(dst)/%.ko.xz: $(dst)/%.ko FORCE << 159 $(call cmd,xz) << 160 31 161 $(dst)/%.ko.zst: $(dst)/%.ko FORCE !! 32 # Modules built outside just go into extra 162 $(call cmd,zstd) << 163 33 164 PHONY += FORCE !! 34 quiet_cmd_modules_install_extra = INSTALL $(obj-m:.o=.ko) 165 FORCE: !! 35 cmd_modules_install_extra = mkdir -p $(MODLIB)/extra; \ >> 36 cp $@ $(MODLIB)/extra 166 37 167 .PHONY: $(PHONY) !! 38 $(filter ../% /%,$(modules)): >> 39 $(call cmd,modules_install_extra)
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.