Commit 121c2a13 authored by Masahiro Yamada's avatar Masahiro Yamada

kbuild: error out if targets prefixed with '__' are directly run

Some targets are internal-use only.

It is tedious to care about "what if __build_one_by_one is contained
in $(MAKECMDGOALS)?" etc.

Prefix internal targets with double underscores. Stop parsing Makefile
if they are directly run.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 93fdddfe
......@@ -11,9 +11,12 @@ NAME = Kleptomaniac Octopus
# Comments in this file are targeted only to the developer, do not
# expect to learn how to build the kernel reading this file.
$(if $(filter __%, $(MAKECMDGOALS)), \
$(error targets prefixed with '__' are only for internal use))
# That's our default target when none is given on the command line
PHONY := _all
_all:
PHONY := __all
__all:
# We are using a recursive build, so we need to do a little thinking
# to get the ordering right.
......@@ -172,13 +175,13 @@ export sub_make_done := 1
ifeq ($(need-sub-make),1)
PHONY += $(MAKECMDGOALS) sub-make
PHONY += $(MAKECMDGOALS) __sub-make
$(filter-out _all sub-make $(this-makefile), $(MAKECMDGOALS)) _all: sub-make
$(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
@:
# Invoke a second make in the output directory, passing relevant variables
sub-make:
__sub-make:
$(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
endif # need-sub-make
......@@ -323,7 +326,7 @@ ifdef mixed-build
PHONY += $(MAKECMDGOALS) __build_one_by_one
$(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one
$(MAKECMDGOALS): __build_one_by_one
@:
__build_one_by_one:
......@@ -598,12 +601,12 @@ else #!config-build
# targets and others. In general all targets except *config targets.
# If building an external module we do not care about the all: rule
# but instead _all depend on modules
# but instead __all depend on modules
PHONY += all
ifeq ($(KBUILD_EXTMOD),)
_all: all
__all: all
else
_all: modules
__all: modules
endif
# Decide whether to build built-in, modular, or both.
......@@ -625,7 +628,7 @@ endif
# in addition to whatever we do anyway.
# Just "make" or "make all" shall build modules as well
ifneq ($(filter all _all modules nsdeps,$(MAKECMDGOALS)),)
ifneq ($(filter all modules nsdeps,$(MAKECMDGOALS)),)
KBUILD_MODULES := 1
endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment