blob: 5a4579e76485c111daef39b7731fff1ff24529e6 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002# ==========================================================================
3# Installing modules
4# ==========================================================================
5
Paul Smith4f193362006-03-05 17:14:10 -05006PHONY := __modinst
Linus Torvalds1da177e2005-04-16 15:20:36 -07007__modinst:
8
Sam Ravnborg8ec4b4f2005-07-25 20:10:36 +00009include scripts/Kbuild.include
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
Masahiro Yamadad56aec12019-07-17 15:17:53 +090011modules := $(sort $(shell cat $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order))
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Paul Smith4f193362006-03-05 17:14:10 -050013PHONY += $(modules)
Linus Torvalds1da177e2005-04-16 15:20:36 -070014__modinst: $(modules)
15 @:
16
Rusty Russellf6a79af2012-11-06 11:46:59 +103017# Don't stop modules_install if we can't sign external modules.
Linus Torvalds1da177e2005-04-16 15:20:36 -070018quiet_cmd_modules_install = INSTALL $@
Bertrand Jacquin40e42f62014-08-27 20:30:56 +093019 cmd_modules_install = \
20 mkdir -p $(2) ; \
21 cp $@ $(2) ; \
22 $(mod_strip_cmd) $(2)/$(notdir $@) ; \
Douglas Andersonf84dde102019-03-15 09:25:03 -070023 $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) ; \
Bertrand Jacquinbeb50df2014-08-27 20:31:56 +093024 $(mod_compress_cmd) $(2)/$(notdir $@)
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26# Modules built outside the kernel source tree go into extra by default
27INSTALL_MOD_DIR ?= extra
Sam Ravnborg9b213112008-01-01 13:40:28 +010028ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D))
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
31
32$(modules):
33 $(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
Paul Smith4f193362006-03-05 17:14:10 -050034
Paul Smith4f193362006-03-05 17:14:10 -050035.PHONY: $(PHONY)