Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 151aeca

Browse files
committed
kbuild: support modules_sign for external modules as well
The modules_sign target is currently only available for in-tree modules, but it actually works for external modules as well. Move the modules_sign rule to the common part. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
1 parent 02e8487 commit 151aeca

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

Makefile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,20 +1461,6 @@ modules: modules_prepare
14611461
modules_prepare: prepare
14621462
$(Q)$(MAKE) $(build)=scripts scripts/module.lds
14631463

1464-
export modules_sign_only :=
1465-
1466-
ifeq ($(CONFIG_MODULE_SIG),y)
1467-
PHONY += modules_sign
1468-
modules_sign: modules_install
1469-
@:
1470-
1471-
# modules_sign is a subset of modules_install.
1472-
# 'make modules_install modules_sign' is equivalent to 'make modules_install'.
1473-
ifeq ($(filter modules_install,$(MAKECMDGOALS)),)
1474-
modules_sign_only := y
1475-
endif
1476-
endif
1477-
14781464
endif # CONFIG_MODULES
14791465

14801466
###
@@ -1833,10 +1819,24 @@ endif # KBUILD_EXTMOD
18331819
# ---------------------------------------------------------------------------
18341820
# Modules
18351821

1836-
PHONY += modules modules_install modules_prepare
1822+
PHONY += modules modules_install modules_sign modules_prepare
18371823

18381824
modules_install:
1839-
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
1825+
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst \
1826+
sign-only=$(if $(filter modules_install,$(MAKECMDGOALS)),,y)
1827+
1828+
ifeq ($(CONFIG_MODULE_SIG),y)
1829+
# modules_sign is a subset of modules_install.
1830+
# 'make modules_install modules_sign' is equivalent to 'make modules_install'.
1831+
modules_sign: modules_install
1832+
@:
1833+
else
1834+
modules_sign:
1835+
@echo >&2 '***'
1836+
@echo >&2 '*** CONFIG_MODULE_SIG is disabled. You cannot sign modules.'
1837+
@echo >&2 '***'
1838+
@false
1839+
endif
18401840

18411841
ifdef CONFIG_MODULES
18421842

scripts/Makefile.modinst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ include $(srctree)/scripts/Kbuild.include
1111

1212
install-y :=
1313

14-
ifeq ($(KBUILD_EXTMOD)$(modules_sign_only),)
14+
ifeq ($(KBUILD_EXTMOD)$(sign-only),)
1515

1616
# remove the old directory and symlink
1717
$(shell rm -fr $(MODLIB)/kernel $(MODLIB)/build)
@@ -104,7 +104,7 @@ quiet_cmd_sign = SIGN $@
104104
cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \
105105
$(if $(KBUILD_EXTMOD),|| true)
106106

107-
ifeq ($(modules_sign_only),)
107+
ifeq ($(sign-only),)
108108

109109
# During modules_install, modules are signed only when CONFIG_MODULE_SIG_ALL=y.
110110
ifndef CONFIG_MODULE_SIG_ALL

0 commit comments

Comments
 (0)