Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 # ==========================================================================
0003 # Installing modules
0004 # ==========================================================================
0005 
0006 PHONY := __modinst
0007 __modinst:
0008 
0009 include include/config/auto.conf
0010 include $(srctree)/scripts/Kbuild.include
0011 
0012 modules := $(sort $(shell cat $(MODORDER)))
0013 
0014 ifeq ($(KBUILD_EXTMOD),)
0015 dst := $(MODLIB)/kernel
0016 else
0017 INSTALL_MOD_DIR ?= extra
0018 dst := $(MODLIB)/$(INSTALL_MOD_DIR)
0019 endif
0020 
0021 $(foreach x, % :, $(if $(findstring $x, $(dst)), \
0022         $(error module installation path cannot contain '$x')))
0023 
0024 suffix-y                                :=
0025 suffix-$(CONFIG_MODULE_COMPRESS_GZIP)   := .gz
0026 suffix-$(CONFIG_MODULE_COMPRESS_XZ)     := .xz
0027 suffix-$(CONFIG_MODULE_COMPRESS_ZSTD)   := .zst
0028 
0029 modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules))
0030 
0031 __modinst: $(modules)
0032         @:
0033 
0034 #
0035 # Installation
0036 #
0037 quiet_cmd_install = INSTALL $@
0038       cmd_install = mkdir -p $(dir $@); cp $< $@
0039 
0040 # Strip
0041 #
0042 # INSTALL_MOD_STRIP, if defined, will cause modules to be stripped after they
0043 # are installed. If INSTALL_MOD_STRIP is '1', then the default option
0044 # --strip-debug will be used. Otherwise, INSTALL_MOD_STRIP value will be used
0045 # as the options to the strip command.
0046 ifdef INSTALL_MOD_STRIP
0047 
0048 ifeq ($(INSTALL_MOD_STRIP),1)
0049 strip-option := --strip-debug
0050 else
0051 strip-option := $(INSTALL_MOD_STRIP)
0052 endif
0053 
0054 quiet_cmd_strip = STRIP   $@
0055       cmd_strip = $(STRIP) $(strip-option) $@
0056 
0057 else
0058 
0059 quiet_cmd_strip =
0060       cmd_strip = :
0061 
0062 endif
0063 
0064 #
0065 # Signing
0066 # Don't stop modules_install even if we can't sign external modules.
0067 #
0068 ifeq ($(CONFIG_MODULE_SIG_ALL),y)
0069 sig-key := $(if $(wildcard $(CONFIG_MODULE_SIG_KEY)),,$(srctree)/)$(CONFIG_MODULE_SIG_KEY)
0070 quiet_cmd_sign = SIGN    $@
0071       cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(sig-key) certs/signing_key.x509 $@ \
0072                  $(if $(KBUILD_EXTMOD),|| true)
0073 else
0074 quiet_cmd_sign :=
0075       cmd_sign := :
0076 endif
0077 
0078 ifeq ($(modules_sign_only),)
0079 
0080 $(dst)/%.ko: $(extmod_prefix)%.ko FORCE
0081         $(call cmd,install)
0082         $(call cmd,strip)
0083         $(call cmd,sign)
0084 
0085 else
0086 
0087 $(dst)/%.ko: FORCE
0088         $(call cmd,sign)
0089 
0090 endif
0091 
0092 #
0093 # Compression
0094 #
0095 quiet_cmd_gzip = GZIP    $@
0096       cmd_gzip = $(KGZIP) -n -f $<
0097 quiet_cmd_xz = XZ      $@
0098       cmd_xz = $(XZ) --lzma2=dict=2MiB -f $<
0099 quiet_cmd_zstd = ZSTD    $@
0100       cmd_zstd = $(ZSTD) -T0 --rm -f -q $<
0101 
0102 $(dst)/%.ko.gz: $(dst)/%.ko FORCE
0103         $(call cmd,gzip)
0104 
0105 $(dst)/%.ko.xz: $(dst)/%.ko FORCE
0106         $(call cmd,xz)
0107 
0108 $(dst)/%.ko.zst: $(dst)/%.ko FORCE
0109         $(call cmd,zstd)
0110 
0111 PHONY += FORCE
0112 FORCE:
0113 
0114 .PHONY: $(PHONY)