Linux Audio

Check our new training course

Embedded Linux training

Mar 31-Apr 8, 2025
Register
Loading...
v4.17
 1# SPDX-License-Identifier: GPL-2.0
 2# ==========================================================================
 3# Installing modules
 4# ==========================================================================
 5
 6PHONY := __modinst
 7__modinst:
 8
 9include scripts/Kbuild.include
 
10
11#
 
 
 
 
 
 
 
12
13__modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
14modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
 
 
 
 
15
16PHONY += $(modules)
17__modinst: $(modules)
18	@:
19
20# Don't stop modules_install if we can't sign external modules.
21quiet_cmd_modules_install = INSTALL $@
22      cmd_modules_install = \
23    mkdir -p $(2) ; \
24    cp $@ $(2) ; \
25    $(mod_strip_cmd) $(2)/$(notdir $@) ; \
26    $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) && \
27    $(mod_compress_cmd) $(2)/$(notdir $@)
28
29# Modules built outside the kernel source tree go into extra by default
30INSTALL_MOD_DIR ?= extra
31ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
33modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
35$(modules):
36	$(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
37
 
 
38
39# Declare the contents of the .PHONY variable as phony.  We keep that
40# information in a variable so we can use it in if_changed and friends.
41
42.PHONY: $(PHONY)
v5.14.15
  1# SPDX-License-Identifier: GPL-2.0
  2# ==========================================================================
  3# Installing modules
  4# ==========================================================================
  5
  6PHONY := __modinst
  7__modinst:
  8
  9include include/config/auto.conf
 10include $(srctree)/scripts/Kbuild.include
 11
 12modules := $(sort $(shell cat $(MODORDER)))
 13
 14ifeq ($(KBUILD_EXTMOD),)
 15dst := $(MODLIB)/kernel
 16else
 17INSTALL_MOD_DIR ?= extra
 18dst := $(MODLIB)/$(INSTALL_MOD_DIR)
 19endif
 20
 21suffix-y				:=
 22suffix-$(CONFIG_MODULE_COMPRESS_GZIP)	:= .gz
 23suffix-$(CONFIG_MODULE_COMPRESS_XZ)	:= .xz
 24suffix-$(CONFIG_MODULE_COMPRESS_ZSTD)	:= .zst
 25
 26modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules))
 27
 
 28__modinst: $(modules)
 29	@:
 30
 31quiet_cmd_none =
 32      cmd_none = :
 
 
 
 
 
 
 33
 34#
 35# Installation
 36#
 37quiet_cmd_install = INSTALL $@
 38      cmd_install = mkdir -p $(dir $@); cp $< $@
 39
 40# Strip
 41#
 42# INSTALL_MOD_STRIP, if defined, will cause modules to be stripped after they
 43# are installed. If INSTALL_MOD_STRIP is '1', then the default option
 44# --strip-debug will be used. Otherwise, INSTALL_MOD_STRIP value will be used
 45# as the options to the strip command.
 46ifdef INSTALL_MOD_STRIP
 47
 48ifeq ($(INSTALL_MOD_STRIP),1)
 49strip-option := --strip-debug
 50else
 51strip-option := $(INSTALL_MOD_STRIP)
 52endif
 53
 54quiet_cmd_strip = STRIP   $@
 55      cmd_strip = $(STRIP) $(strip-option) $@
 56
 57else
 58
 59quiet_cmd_strip =
 60      cmd_strip = :
 61
 62endif
 63
 64#
 65# Signing
 66# Don't stop modules_install even if we can't sign external modules.
 67#
 68ifeq ($(CONFIG_MODULE_SIG_ALL),y)
 69quiet_cmd_sign = SIGN    $@
 70$(eval $(call config_filename,MODULE_SIG_KEY))
 71      cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY) certs/signing_key.x509 $@ \
 72                 $(if $(KBUILD_EXTMOD),|| true)
 73else
 74quiet_cmd_sign :=
 75      cmd_sign := :
 76endif
 77
 78ifeq ($(modules_sign_only),)
 79
 80$(dst)/%.ko: $(extmod_prefix)%.ko FORCE
 81	$(call cmd,install)
 82	$(call cmd,strip)
 83	$(call cmd,sign)
 84
 85else
 86
 87$(dst)/%.ko: FORCE
 88	$(call cmd,sign)
 89
 90endif
 91
 92#
 93# Compression
 94#
 95quiet_cmd_gzip = GZIP    $@
 96      cmd_gzip = $(KGZIP) -n -f $<
 97quiet_cmd_xz = XZ      $@
 98      cmd_xz = $(XZ) --lzma2=dict=2MiB -f $<
 99quiet_cmd_zstd = ZSTD    $@
100      cmd_zstd = $(ZSTD) -T0 --rm -f -q $<
101
102$(dst)/%.ko.gz: $(dst)/%.ko FORCE
103	$(call cmd,gzip)
104
105$(dst)/%.ko.xz: $(dst)/%.ko FORCE
106	$(call cmd,xz)
107
108$(dst)/%.ko.zst: $(dst)/%.ko FORCE
109	$(call cmd,zstd)
110
111PHONY += FORCE
112FORCE:
113
114.PHONY: $(PHONY)