Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kbuild: add cmd_and_savecmd macro

Separate out the command execution part of if_changed, as we did
for if_changed_dep.

This allows us to reuse it in if_changed_rule.

define rule_foo
$(call cmd_and_savecmd,foo)
$(call cmd,bar)
endef

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)

+4 -2
+4 -2
scripts/Kbuild.include
··· 142 142 if-changed-cond = $(newer-prereqs)$(cmd-check)$(check-FORCE) 143 143 144 144 # Execute command if command has changed or prerequisite(s) are updated. 145 - if_changed = $(if $(if-changed-cond), \ 145 + if_changed = $(if $(if-changed-cond),$(cmd_and_savecmd),@:) 146 + 147 + cmd_and_savecmd = \ 146 148 $(cmd); \ 147 - printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) 149 + printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd 148 150 149 151 # Execute the command and also postprocess generated .d dependencies file. 150 152 if_changed_dep = $(if $(if-changed-cond),$(cmd_and_fixdep),@:)