Skip to content

Commit eb38f37

Browse files
bulwahntorvalds
authored andcommitted
kbuild: doc: describe proper script invocation
During an investigation to fix up the execute bits of scripts in the kernel repository, Andrew Morton and Kees Cook pointed out that the execute bit should not matter, and that build scripts cannot rely on that. Kees could not point to any documentation, though. Masahiro Yamada explained the convention of setting execute bits to make it easier for manual script invocation. Provide some basic documentation how the build shall invoke scripts, such that the execute bits do not matter, and acknowledge that execute bits are useful nonetheless. This serves as reference for further clean-up patches in the future. Suggested-by: Andrew Morton <akpm@linux-foundation.org> Suggested-by: Kees Cook <keescook@chromium.org> Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Masahiro Yamada <masahiroy@kernel.org> Cc: Michal Marek <michal.lkml@markovi.net> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Ujjwal Kumar <ujjwalkumar0501@gmail.com> Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> Link: https://lore.kernel.org/lkml/20200830174409.c24c3f67addcce0cea9a9d4c@linux-foundation.org/ Link: https://lore.kernel.org/lkml/202008271102.FEB906C88@keescook/ Link: https://lore.kernel.org/linux-kbuild/CAK7LNAQdrvMkDA6ApDJCGr+5db8SiPo=G+p8EiOvnnGvEN80gA@mail.gmail.com/ Link: https://lkml.kernel.org/r/20201001075723.24246-1-lukas.bulwahn@gmail.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4d6fb34 commit eb38f37

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎Documentation/kbuild/makefiles.rst‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This document describes the Linux kernel Makefiles.
2121
--- 3.10 Special Rules
2222
--- 3.11 $(CC) support functions
2323
--- 3.12 $(LD) support functions
24+
--- 3.13 Script Invocation
2425
2526
=== 4 Host Program support
2627
--- 4.1 Simple Host Program
@@ -605,6 +606,25 @@ more details, with real examples.
605606
#Makefile
606607
LDFLAGS_vmlinux += $(call ld-option, -X)
607608

609+
3.13 Script invocation
610+
----------------------
611+
612+
Make rules may invoke scripts to build the kernel. The rules shall
613+
always provide the appropriate interpreter to execute the script. They
614+
shall not rely on the execute bits being set, and shall not invoke the
615+
script directly. For the convenience of manual script invocation, such
616+
as invoking ./scripts/checkpatch.pl, it is recommended to set execute
617+
bits on the scripts nonetheless.
618+
619+
Kbuild provides variables $(CONFIG_SHELL), $(AWK), $(PERL),
620+
$(PYTHON) and $(PYTHON3) to refer to interpreters for the respective
621+
scripts.
622+
623+
Example::
624+
625+
#Makefile
626+
cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
627+
$(KERNELRELEASE)
608628

609629
4 Host Program support
610630
======================

0 commit comments

Comments
 (0)