Skip to content

Commit

Permalink
kbuild: use 'output' variable to create the output directory
Browse files Browse the repository at this point in the history
$(KBUILD_OUTPUT) specifies the output directory of kernel builds.

Use a more generic name, 'output', to better reflect this code hunk in
the context of external module builds.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
  • Loading branch information
Masahiro Yamada committed Nov 27, 2024
1 parent 5ea1721 commit d171136
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,20 @@ export KBUILD_EXTRA_WARN
# The O= assignment takes precedence over the KBUILD_OUTPUT environment
# variable.

# Do we want to change the working directory?
ifeq ("$(origin O)", "command line")
KBUILD_OUTPUT := $(O)
endif

ifneq ($(KBUILD_OUTPUT),)
output := $(KBUILD_OUTPUT)

# Do we want to change the working directory?
ifneq ($(output),)
# $(realpath ...) gets empty if the path does not exist. Run 'mkdir -p' first.
$(shell mkdir -p "$(KBUILD_OUTPUT)")
$(shell mkdir -p "$(output)")
# $(realpath ...) resolves symlinks
abs_output := $(realpath $(KBUILD_OUTPUT))
$(if $(abs_output),,$(error failed to create output directory "$(KBUILD_OUTPUT)"))
endif # ifneq ($(KBUILD_OUTPUT),)
abs_output := $(realpath $(output))
$(if $(abs_output),,$(error failed to create output directory "$(output)"))
endif

ifneq ($(words $(subst :, ,$(abs_srctree))), 1)
$(error source directory cannot contain spaces or colons)
Expand Down

0 comments on commit d171136

Please sign in to comment.