1 # SPDX-License-Identifier: GPL-2.0
2 # ==========================================================================
4 # ==========================================================================
9 include include/config/auto.conf
10 include $(srctree)/scripts/Kbuild.include
12 modules := $(sort $(shell cat $(MODORDER)))
14 ifeq ($(KBUILD_EXTMOD),)
15 dst := $(MODLIB)/kernel
17 INSTALL_MOD_DIR ?= extra
18 dst := $(MODLIB)/$(INSTALL_MOD_DIR)
22 suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz
23 suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz
24 suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst
26 modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules))
34 quiet_cmd_install = INSTALL $@
35 cmd_install = mkdir -p $(dir $@); cp $< $@
39 # INSTALL_MOD_STRIP, if defined, will cause modules to be stripped after they
40 # are installed. If INSTALL_MOD_STRIP is '1', then the default option
41 # --strip-debug will be used. Otherwise, INSTALL_MOD_STRIP value will be used
42 # as the options to the strip command.
43 ifdef INSTALL_MOD_STRIP
45 ifeq ($(INSTALL_MOD_STRIP),1)
46 strip-option := --strip-debug
48 strip-option := $(INSTALL_MOD_STRIP)
51 quiet_cmd_strip = STRIP $@
52 cmd_strip = $(STRIP) $(strip-option) $@
63 # Don't stop modules_install even if we can't sign external modules.
65 ifeq ($(CONFIG_MODULE_SIG_ALL),y)
66 sig-key := $(if $(wildcard $(CONFIG_MODULE_SIG_KEY)),,$(srctree)/)$(CONFIG_MODULE_SIG_KEY)
67 quiet_cmd_sign = SIGN $@
68 cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(sig-key) certs/signing_key.x509 $@ \
69 $(if $(KBUILD_EXTMOD),|| true)
75 ifeq ($(modules_sign_only),)
77 $(dst)/%.ko: $(extmod_prefix)%.ko FORCE
92 quiet_cmd_gzip = GZIP $@
93 cmd_gzip = $(KGZIP) -n -f $<
95 cmd_xz = $(XZ) --lzma2=dict=2MiB -f $<
96 quiet_cmd_zstd = ZSTD $@
97 cmd_zstd = $(ZSTD) -T0 --rm -f -q $<
99 $(dst)/%.ko.gz: $(dst)/%.ko FORCE
102 $(dst)/%.ko.xz: $(dst)/%.ko FORCE
105 $(dst)/%.ko.zst: $(dst)/%.ko FORCE