mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 20:51:44 +00:00
e30f34053e
Add quiet_cmd_test so that: $(Q)$(call echo-cmd,test) will print: TEST <path> This is useful for executing compile-time tests similar to what happens for fortify tests in the kernel's lib directory. Reviewed-by: Kajol Jain <kjain@linux.ibm.com> Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Caleb Biggers <caleb.biggers@intel.com> Cc: Florian Fischer <florian.fischer@muhq.space> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jing Zhang <renyu.zj@linux.alibaba.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Kang Minchul <tegongkang@gmail.com> Cc: Kim Phillips <kim.phillips@amd.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Perry Taylor <perry.taylor@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Rob Herring <robh@kernel.org> Cc: Sandipan Das <sandipan.das@amd.com> Cc: Stephane Eranian <eranian@google.com> Cc: Will Deacon <will@kernel.org> Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linuxppc-dev@lists.ozlabs.org Link: https://lore.kernel.org/r/20230126233645.200509-15-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
164 lines
3.9 KiB
Makefile
164 lines
3.9 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
###
|
|
# Main build makefile.
|
|
#
|
|
# Lots of this code have been borrowed or heavily inspired from parts
|
|
# of kbuild code, which is not credited, but mostly developed by:
|
|
#
|
|
# Copyright (C) Sam Ravnborg <sam@mars.ravnborg.org>, 2015
|
|
# Copyright (C) Linus Torvalds <torvalds@linux-foundation.org>, 2015
|
|
#
|
|
|
|
PHONY := __build
|
|
__build:
|
|
|
|
ifeq ($(V),1)
|
|
quiet =
|
|
Q =
|
|
else
|
|
quiet=quiet_
|
|
Q=@
|
|
endif
|
|
|
|
ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
|
|
quiet=silent_
|
|
endif
|
|
|
|
build-dir := $(srctree)/tools/build
|
|
|
|
# Define $(fixdep) for dep-cmd function
|
|
ifeq ($(OUTPUT),)
|
|
fixdep := $(build-dir)/fixdep
|
|
else
|
|
fixdep := $(OUTPUT)/fixdep
|
|
endif
|
|
|
|
# Generic definitions
|
|
include $(build-dir)/Build.include
|
|
|
|
# do not force detected configuration
|
|
-include $(OUTPUT).config-detected
|
|
|
|
# Init all relevant variables used in build files so
|
|
# 1) they have correct type
|
|
# 2) they do not inherit any value from the environment
|
|
subdir-y :=
|
|
obj-y :=
|
|
subdir-y :=
|
|
subdir-obj-y :=
|
|
|
|
# Build definitions
|
|
build-file := $(dir)/Build
|
|
-include $(build-file)
|
|
|
|
quiet_cmd_flex = FLEX $@
|
|
quiet_cmd_bison = BISON $@
|
|
quiet_cmd_test = TEST $@
|
|
|
|
# Create directory unless it exists
|
|
quiet_cmd_mkdir = MKDIR $(dir $@)
|
|
cmd_mkdir = mkdir -p $(dir $@)
|
|
rule_mkdir = $(if $(wildcard $(dir $@)),,@$(call echo-cmd,mkdir) $(cmd_mkdir))
|
|
|
|
# Compile command
|
|
quiet_cmd_cc_o_c = CC $@
|
|
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
|
|
|
|
quiet_cmd_host_cc_o_c = HOSTCC $@
|
|
cmd_host_cc_o_c = $(HOSTCC) $(host_c_flags) -c -o $@ $<
|
|
|
|
quiet_cmd_cxx_o_c = CXX $@
|
|
cmd_cxx_o_c = $(CXX) $(cxx_flags) -c -o $@ $<
|
|
|
|
quiet_cmd_cpp_i_c = CPP $@
|
|
cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $<
|
|
|
|
quiet_cmd_cc_s_c = AS $@
|
|
cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $<
|
|
|
|
quiet_cmd_gen = GEN $@
|
|
|
|
# Link agregate command
|
|
# If there's nothing to link, create empty $@ object.
|
|
quiet_cmd_ld_multi = LD $@
|
|
cmd_ld_multi = $(if $(strip $(obj-y)),\
|
|
$(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@)
|
|
|
|
quiet_cmd_host_ld_multi = HOSTLD $@
|
|
cmd_host_ld_multi = $(if $(strip $(obj-y)),\
|
|
$(HOSTLD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(HOSTAR) rcs $@)
|
|
|
|
ifneq ($(filter $(obj),$(hostprogs)),)
|
|
host = host_
|
|
endif
|
|
|
|
# Build rules
|
|
$(OUTPUT)%.o: %.c FORCE
|
|
$(call rule_mkdir)
|
|
$(call if_changed_dep,$(host)cc_o_c)
|
|
|
|
$(OUTPUT)%.o: %.cpp FORCE
|
|
$(call rule_mkdir)
|
|
$(call if_changed_dep,cxx_o_c)
|
|
|
|
$(OUTPUT)%.o: %.S FORCE
|
|
$(call rule_mkdir)
|
|
$(call if_changed_dep,$(host)cc_o_c)
|
|
|
|
$(OUTPUT)%.i: %.c FORCE
|
|
$(call rule_mkdir)
|
|
$(call if_changed_dep,cpp_i_c)
|
|
|
|
$(OUTPUT)%.s: %.S FORCE
|
|
$(call rule_mkdir)
|
|
$(call if_changed_dep,cpp_i_c)
|
|
|
|
$(OUTPUT)%.s: %.c FORCE
|
|
$(call rule_mkdir)
|
|
$(call if_changed_dep,cc_s_c)
|
|
|
|
# Gather build data:
|
|
# obj-y - list of build objects
|
|
# subdir-y - list of directories to nest
|
|
# subdir-obj-y - list of directories objects 'dir/$(obj)-in.o'
|
|
obj-y := $($(obj)-y)
|
|
subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
|
|
obj-y := $(patsubst %/, %/$(obj)-in.o, $(obj-y))
|
|
subdir-obj-y := $(filter %/$(obj)-in.o, $(obj-y))
|
|
|
|
# '$(OUTPUT)/dir' prefix to all objects
|
|
objprefix := $(subst ./,,$(OUTPUT)$(dir)/)
|
|
obj-y := $(addprefix $(objprefix),$(obj-y))
|
|
subdir-obj-y := $(addprefix $(objprefix),$(subdir-obj-y))
|
|
|
|
# Final '$(obj)-in.o' object
|
|
in-target := $(objprefix)$(obj)-in.o
|
|
|
|
PHONY += $(subdir-y)
|
|
|
|
$(subdir-y):
|
|
$(Q)$(MAKE) -f $(build-dir)/Makefile.build dir=$(dir)/$@ obj=$(obj)
|
|
|
|
$(sort $(subdir-obj-y)): $(subdir-y) ;
|
|
|
|
$(in-target): $(obj-y) FORCE
|
|
$(call rule_mkdir)
|
|
$(call if_changed,$(host)ld_multi)
|
|
|
|
__build: $(in-target)
|
|
@:
|
|
|
|
PHONY += FORCE
|
|
FORCE:
|
|
|
|
# Include all cmd files to get all the dependency rules
|
|
# for all objects included
|
|
targets := $(wildcard $(sort $(obj-y) $(in-target) $(MAKECMDGOALS)))
|
|
cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
|
|
|
|
ifneq ($(cmd_files),)
|
|
include $(cmd_files)
|
|
endif
|
|
|
|
.PHONY: $(PHONY)
|