History

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.

Masahiro Yamada committed 3 years ago

Commit 151aeca1 parent 02e84872 files · +18 −18Browse files

Unified · Split

2 files
  1. Makefile +16 −16
  2. scripts/Makefile.modinst +2 −2
Makefile+16−16
@@ -1461,20 +1461,6 @@ modules: modules_prepare · 1460 unmodified lines
1461modules_prepare: prepare1461modules_prepare: prepare
1462 $(Q)$(MAKE) $(build)=scripts scripts/module.lds1462 $(Q)$(MAKE) $(build)=scripts scripts/module.lds
1463 1463
1464export modules_sign_only :=
1465
1466ifeq ($(CONFIG_MODULE_SIG),y)
1467PHONY += modules_sign
1468modules_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'.
1473ifeq ($(filter modules_install,$(MAKECMDGOALS)),)
1474modules_sign_only := y
1475endif
1476endif
1477
1478endif # CONFIG_MODULES1464endif # CONFIG_MODULES
1479 1465
1480###1466###
@@ -1833,10 +1819,24 @@ endif # KBUILD_EXTMOD · 352 unmodified lines
1833# ---------------------------------------------------------------------------1819# ---------------------------------------------------------------------------
1834# Modules1820# Modules
1835 1821
1836PHONY += modules modules_install modules_prepare1822PHONY += modules modules_install modules_sign modules_prepare
1837 1823
1838modules_install:1824modules_install:
1839 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst1825 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst \
1826 sign-only=$(if $(filter modules_install,$(MAKECMDGOALS)),,y)
1827
1828ifeq ($(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'.
1831modules_sign: modules_install
1832 @:
1833else
1834modules_sign:
1835 @echo >&2 '***'
1836 @echo >&2 '*** CONFIG_MODULE_SIG is disabled. You cannot sign modules.'
1837 @echo >&2 '***'
1838 @false
1839endif
1840 1840
1841ifdef CONFIG_MODULES1841ifdef CONFIG_MODULES
1842 1842
scripts/Makefile.modinst+2−2
@@ -11,7 +11,7 @@ include $(srctree)/scripts/Kbuild.include · 10 unmodified lines
11 11
12install-y :=12install-y :=
13 13
14ifeq ($(KBUILD_EXTMOD)$(modules_sign_only),)14ifeq ($(KBUILD_EXTMOD)$(sign-only),)
15 15
16# remove the old directory and symlink16# remove the old directory and symlink
17$(shell rm -fr $(MODLIB)/kernel $(MODLIB)/build)17$(shell rm -fr $(MODLIB)/kernel $(MODLIB)/build)
@@ -104,7 +104,7 @@ quiet_cmd_sign = SIGN $@ · 86 unmodified lines
104 cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \104 cmd_sign = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) "$(sig-key)" certs/signing_key.x509 $@ \
105 $(if $(KBUILD_EXTMOD),|| true)105 $(if $(KBUILD_EXTMOD),|| true)
106 106
107ifeq ($(modules_sign_only),)107ifeq ($(sign-only),)
108 108
109# During modules_install, modules are signed only when CONFIG_MODULE_SIG_ALL=y.109# During modules_install, modules are signed only when CONFIG_MODULE_SIG_ALL=y.
110ifndef CONFIG_MODULE_SIG_ALL110ifndef CONFIG_MODULE_SIG_ALL