b24413180f560 (Greg Kroah-Hartman 2017-11-01 15:07:57 +0100 1) # SPDX-License-Identifier: GPL-2.0
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 2) # ==========================================================================
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 3) # Installing modules
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 4) # ==========================================================================
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 5)
4f1933620f571 (Paul Smith 2006-03-05 17:14:10 -0500 6) PHONY := __modinst
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 7) __modinst:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 8)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 9) include include/config/auto.conf
3204a7fb98a3b (Masahiro Yamada 2021-02-28 15:10:26 +0900 10) include $(srctree)/scripts/Kbuild.include
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 11)
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 12) modules := $(sort $(shell cat $(MODORDER)))
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 13)
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 14) ifeq ($(KBUILD_EXTMOD),)
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 15) dst := $(MODLIB)/kernel
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 16) else
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 17) INSTALL_MOD_DIR ?= extra
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 18) dst := $(MODLIB)/$(INSTALL_MOD_DIR)
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 19) endif
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 20)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 21) suffix-y :=
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 22) suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 23) suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz
c3d7ef377eb25 (Piotr Gorski 2021-04-07 18:09:27 +0200 24) suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 25)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 26) modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules))
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 27)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 28) __modinst: $(modules)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 29) @:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 30)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 31) quiet_cmd_none =
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 32) cmd_none = :
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 33)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 34) #
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 35) # Installation
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 36) #
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 37) quiet_cmd_install = INSTALL $@
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 38) cmd_install = mkdir -p $(dir $@); cp $< $@
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 39)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 40) # Strip
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 41) #
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 42) # INSTALL_MOD_STRIP, if defined, will cause modules to be stripped after they
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 43) # are installed. If INSTALL_MOD_STRIP is '1', then the default option
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 44) # --strip-debug will be used. Otherwise, INSTALL_MOD_STRIP value will be used
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 45) # as the options to the strip command.
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 46) ifdef INSTALL_MOD_STRIP
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 47)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 48) ifeq ($(INSTALL_MOD_STRIP),1)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 49) strip-option := --strip-debug
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 50) else
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 51) strip-option := $(INSTALL_MOD_STRIP)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 52) endif
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 53)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 54) quiet_cmd_strip = STRIP $@
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 55) cmd_strip = $(STRIP) $(strip-option) $@
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 56)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 57) else
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 58)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 59) quiet_cmd_strip =
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 60) cmd_strip = :
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 61)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 62) endif
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 63)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 64) #
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 65) # Signing
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 66) # Don't stop modules_install even if we can't sign external modules.
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 67) #
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 68) ifeq ($(CONFIG_MODULE_SIG_ALL),y)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 69) quiet_cmd_sign = SIGN $@
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 70) $(eval $(call config_filename,MODULE_SIG_KEY))
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 71) cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY) certs/signing_key.x509 $@ \
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 72) $(if $(KBUILD_EXTMOD),|| true)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 73) else
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 74) quiet_cmd_sign :=
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 75) cmd_sign := :
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 76) endif
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 77)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 78) ifeq ($(modules_sign_only),)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 79)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 80) $(dst)/%.ko: $(extmod_prefix)%.ko FORCE
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 81) $(call cmd,install)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 82) $(call cmd,strip)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 83) $(call cmd,sign)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 84)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 85) else
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 86)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 87) $(dst)/%.ko: FORCE
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 88) $(call cmd,sign)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 89)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 90) endif
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 91)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 92) #
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 93) # Compression
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 94) #
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 95) quiet_cmd_gzip = GZIP $@
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 96) cmd_gzip = $(KGZIP) -n -f $<
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 97) quiet_cmd_xz = XZ $@
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 98) cmd_xz = $(XZ) --lzma2=dict=2MiB -f $<
c3d7ef377eb25 (Piotr Gorski 2021-04-07 18:09:27 +0200 99) quiet_cmd_zstd = ZSTD $@
c3d7ef377eb25 (Piotr Gorski 2021-04-07 18:09:27 +0200 100) cmd_zstd = $(ZSTD) -T0 --rm -f -q $<
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 101)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 102) $(dst)/%.ko.gz: $(dst)/%.ko FORCE
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 103) $(call cmd,gzip)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 104)
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 105) $(dst)/%.ko.xz: $(dst)/%.ko FORCE
65ce9c38326e2 (Masahiro Yamada 2021-03-31 22:38:08 +0900 106) $(call cmd,xz)
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 107)
c3d7ef377eb25 (Piotr Gorski 2021-04-07 18:09:27 +0200 108) $(dst)/%.ko.zst: $(dst)/%.ko FORCE
c3d7ef377eb25 (Piotr Gorski 2021-04-07 18:09:27 +0200 109) $(call cmd,zstd)
c3d7ef377eb25 (Piotr Gorski 2021-04-07 18:09:27 +0200 110)
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 111) PHONY += FORCE
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 112) FORCE:
4f1933620f571 (Paul Smith 2006-03-05 17:14:10 -0500 113)
4f1933620f571 (Paul Smith 2006-03-05 17:14:10 -0500 114) .PHONY: $(PHONY)