Skip to content

Commit ccae4cf

Browse files
committed
kbuild: refactor scripts/Makefile.modinst
scripts/Makefile.modinst is ugly and weird in multiple ways; it specifies real files $(modules) as phony, makes directory manipulation needlessly too complicated. Clean up the Makefile code, and show the full path of installed modules in the log. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 7f69180 commit ccae4cf

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ endif # CONFIG_BPF
11411141

11421142
PHONY += prepare0
11431143

1144-
extmod_prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
1144+
export extmod_prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
11451145
export MODORDER := $(extmod_prefix)modules.order
11461146
export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps
11471147

scripts/Makefile.modinst

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,32 @@ __modinst:
88

99
include $(srctree)/scripts/Kbuild.include
1010

11-
modules := $(sort $(shell cat $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order))
11+
modules := $(sort $(shell cat $(MODORDER)))
12+
13+
ifeq ($(KBUILD_EXTMOD),)
14+
dst := $(MODLIB)/kernel
15+
else
16+
INSTALL_MOD_DIR ?= extra
17+
dst := $(MODLIB)/$(INSTALL_MOD_DIR)
18+
endif
19+
20+
modules := $(patsubst $(extmod_prefix)%, $(dst)/%, $(modules))
1221

13-
PHONY += $(modules)
1422
__modinst: $(modules)
1523
@:
1624

1725
# Don't stop modules_install if we can't sign external modules.
18-
quiet_cmd_modules_install = INSTALL $@
19-
cmd_modules_install = \
20-
mkdir -p $(2) ; \
21-
cp $@ $(2) ; \
22-
$(mod_strip_cmd) $(2)/$(notdir $@) ; \
23-
$(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) ; \
24-
$(mod_compress_cmd) $(2)/$(notdir $@)
25-
26-
# Modules built outside the kernel source tree go into extra by default
27-
INSTALL_MOD_DIR ?= extra
28-
ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D))
29-
30-
modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
31-
32-
$(modules):
33-
$(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
26+
quiet_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+
36+
PHONY += FORCE
37+
FORCE:
3438

3539
.PHONY: $(PHONY)

0 commit comments

Comments
 (0)