mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 06:31:49 +00:00
faabed295c
To build host programs, you need to add the program names to 'hostprogs' to use the necessary build rule, but it is not enough to build them because there is no dependency. There are two types of host programs: built as the prerequisite of another (e.g. gen_crc32table in lib/Makefile), or always built when Kbuild visits the Makefile (e.g. genksyms in scripts/genksyms/Makefile). The latter is typical in Makefiles under scripts/, which contains host programs globally used during the kernel build. To build them, you need to add them to both 'hostprogs' and 'always-y'. This commit adds hostprogs-always-y as a shorthand. The same applies to user programs. net/bpfilter/Makefile builds bpfilter_umh on demand, hence always-y is unneeded. In contrast, programs under samples/ are added to both 'userprogs' and 'always-y' so they are always built when Kbuild visits the Makefiles. userprogs-always-y works as a shorthand. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Acked-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
74 lines
2.3 KiB
Makefile
74 lines
2.3 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
# ==========================================================================
|
|
# Cleaning up
|
|
# ==========================================================================
|
|
|
|
src := $(obj)
|
|
|
|
PHONY := __clean
|
|
__clean:
|
|
|
|
include scripts/Kbuild.include
|
|
|
|
# The filename Kbuild has precedence over Makefile
|
|
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
|
|
include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
|
|
|
|
# Figure out what we need to build from the various variables
|
|
# ==========================================================================
|
|
|
|
subdir-ymn := $(sort $(subdir-y) $(subdir-m) $(subdir-) \
|
|
$(patsubst %/,%, $(filter %/, $(obj-y) $(obj-m) $(obj-))))
|
|
|
|
# Add subdir path
|
|
|
|
subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
|
|
|
|
# build a list of files to remove, usually relative to the current
|
|
# directory
|
|
|
|
__clean-files := \
|
|
$(clean-files) $(targets) $(hostprogs) $(userprogs) \
|
|
$(extra-y) $(extra-m) $(extra-) \
|
|
$(always-y) $(always-m) $(always-) \
|
|
$(hostprogs-always-y) $(hostprogs-always-m) $(hostprogs-always-) \
|
|
$(userprogs-always-y) $(userprogs-always-m) $(userprogs-always-)
|
|
|
|
# deprecated
|
|
__clean-files += $(always) $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
|
|
|
|
__clean-files := $(filter-out $(no-clean-files), $(__clean-files))
|
|
|
|
# clean-files is given relative to the current directory, unless it
|
|
# starts with $(objtree)/ (which means "./", so do not add "./" unless
|
|
# you want to delete a file from the toplevel object directory).
|
|
|
|
__clean-files := $(wildcard \
|
|
$(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \
|
|
$(filter $(objtree)/%, $(__clean-files)))
|
|
|
|
# ==========================================================================
|
|
|
|
quiet_cmd_clean = CLEAN $(obj)
|
|
cmd_clean = rm -rf $(__clean-files)
|
|
|
|
__clean: $(subdir-ymn)
|
|
ifneq ($(strip $(__clean-files)),)
|
|
$(call cmd,clean)
|
|
endif
|
|
@:
|
|
|
|
|
|
# ===========================================================================
|
|
# Generic stuff
|
|
# ===========================================================================
|
|
|
|
# Descending
|
|
# ---------------------------------------------------------------------------
|
|
|
|
PHONY += $(subdir-ymn)
|
|
$(subdir-ymn):
|
|
$(Q)$(MAKE) $(clean)=$@
|
|
|
|
.PHONY: $(PHONY)
|