kbuild: refactor scripts/Makefile.modinst
[linux-block.git] / scripts / Makefile.modinst
CommitLineData
b2441318 1# SPDX-License-Identifier: GPL-2.0
1da177e4
LT
2# ==========================================================================
3# Installing modules
4# ==========================================================================
5
4f193362 6PHONY := __modinst
1da177e4
LT
7__modinst:
8
3204a7fb 9include $(srctree)/scripts/Kbuild.include
1da177e4 10
ccae4cfa
MY
11modules := $(sort $(shell cat $(MODORDER)))
12
13ifeq ($(KBUILD_EXTMOD),)
14dst := $(MODLIB)/kernel
15else
16INSTALL_MOD_DIR ?= extra
17dst := $(MODLIB)/$(INSTALL_MOD_DIR)
18endif
19
20modules := $(patsubst $(extmod_prefix)%, $(dst)/%, $(modules))
1da177e4 21
1da177e4
LT
22__modinst: $(modules)
23 @:
24
f6a79af8 25# Don't stop modules_install if we can't sign external modules.
ccae4cfa
MY
26quiet_cmd_install = INSTALL $@
27 cmd_install = \
28 mkdir -p $(dir $@); cp $< $@; \
29 $(mod_strip_cmd) $@; \
30 $(mod_sign_cmd) $@ $(patsubst %,|| true,$(KBUILD_EXTMOD)) ; \
31 $(mod_compress_cmd) $@
32
33$(modules): $(dst)/%: $(extmod_prefix)% FORCE
34 $(call cmd,install)
35
36PHONY += FORCE
37FORCE:
4f193362 38
4f193362 39.PHONY: $(PHONY)