diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2023-07-22 13:47:55 +0900 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2023-07-25 00:59:32 +0900 |
commit | 76a48b8ffbad5cb24ce3fab517a24f555b3c9616 (patch) | |
tree | e537cc7991bca5f2f772b9f2f82b0b05f22f3ba1 /Makefile | |
parent | 93ed5605c6185edf3b47c433b257c00854f0a4e1 (diff) | |
download | linux-76a48b8ffbad5cb24ce3fab517a24f555b3c9616.tar.gz linux-76a48b8ffbad5cb24ce3fab517a24f555b3c9616.tar.bz2 linux-76a48b8ffbad5cb24ce3fab517a24f555b3c9616.zip |
kbuild: add a phony target to run a command with Kbuild env vars
There are some cases where we want to run a command with the same
environment variables as Kbuild uses. For example, 'make coccicheck'
invokes scripts/coccicheck from the top Makefile so that the script can
reference to ${LINUXINCLUDE}, ${KBUILD_EXTMOD}, etc. The top Makefile
defines several phony targets that run a script.
We do it also for an internally used script, which results in a somewhat
complex call graph.
One example:
debian/rules binary-arch
-> make intdeb-pkg
-> scripts/package/builddeb
It is also tedious to add a dedicated target like 'intdeb-pkg' for each
use case.
Add a generic target 'run-command' to run an arbitrary command in an
environment with all Kbuild variables set.
The usage is:
$ make run-command KBUILD_RUN_COMMAND=<command>
The concept is similar to:
$ dpkg-architecture -c <command>
This executes <command> in an environment which has all DEB_* variables
defined.
Convert the existing 'make intdeb-pkg'.
Another possible usage is to interrogate a Make variable.
$ make run-command KBUILD_RUN_COMMAND='echo $(KBUILD_CFLAGS)'
might be useful to see KBUILD_CFLAGS set by the top Makefile.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -2148,6 +2148,10 @@ kernelversion: image_name: @echo $(KBUILD_IMAGE) +PHONY += run-command +run-command: + $(Q)$(KBUILD_RUN_COMMAND) + quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) cmd_rmfiles = rm -rf $(rm-files) |