xref: /aosp_15_r20/external/coreboot/toolchain.mk (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1*b9411a12SAndroid Build Coastguard Worker# SPDX-License-Identifier: GPL-2.0-only
2*b9411a12SAndroid Build Coastguard Worker
3*b9411a12SAndroid Build Coastguard Worker# ccache integration
4*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_CCACHE),y)
5*b9411a12SAndroid Build Coastguard Worker
6*b9411a12SAndroid Build Coastguard WorkerCCACHE:=$(word 1,$(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH)))))
7*b9411a12SAndroid Build Coastguard Workerifeq ($(CCACHE),)
8*b9411a12SAndroid Build Coastguard Worker$(error ccache selected, but not found in PATH)
9*b9411a12SAndroid Build Coastguard Workerendif
10*b9411a12SAndroid Build Coastguard Worker
11*b9411a12SAndroid Build Coastguard Workerexport CCACHE_COMPILERCHECK=mtime
12*b9411a12SAndroid Build Coastguard Workerexport CCACHE_BASEDIR=$(top)
13*b9411a12SAndroid Build Coastguard Workerexport CCACHE_STATSLOG=$(obj)/ccache.stats
14*b9411a12SAndroid Build Coastguard Worker
15*b9411a12SAndroid Build Coastguard Worker$(foreach arch,$(ARCH_SUPPORTED), \
16*b9411a12SAndroid Build Coastguard Worker	$(eval CC_$(arch):=$(CCACHE) $(CC_$(arch))))
17*b9411a12SAndroid Build Coastguard Worker
18*b9411a12SAndroid Build Coastguard WorkerHOSTCC:=$(CCACHE) $(HOSTCC)
19*b9411a12SAndroid Build Coastguard WorkerHOSTCXX:=$(CCACHE) $(HOSTCXX)
20*b9411a12SAndroid Build Coastguard Workerendif
21*b9411a12SAndroid Build Coastguard Worker
22*b9411a12SAndroid Build Coastguard Worker# scan-build integration
23*b9411a12SAndroid Build Coastguard Workerifneq ($(CCC_ANALYZER_OUTPUT_FORMAT),)
24*b9411a12SAndroid Build Coastguard Worker
25*b9411a12SAndroid Build Coastguard Workerifeq ($(CCC_ANALYZER_ANALYSIS),)
26*b9411a12SAndroid Build Coastguard Workerexport CCC_ANALYZER_ANALYSIS := -analyzer-opt-analyze-headers
27*b9411a12SAndroid Build Coastguard Workerendif
28*b9411a12SAndroid Build Coastguard Worker
29*b9411a12SAndroid Build Coastguard Worker$(foreach arch,$(ARCH_SUPPORTED), \
30*b9411a12SAndroid Build Coastguard Worker	$(eval CC_$(arch):=CCC_CC="$(CC_$(arch))" $(CC) ))
31*b9411a12SAndroid Build Coastguard Worker
32*b9411a12SAndroid Build Coastguard WorkerHOSTCC:=CCC_CC="$(HOSTCC)" $(CC)
33*b9411a12SAndroid Build Coastguard WorkerHOSTCXX:=CCC_CXX="$(HOSTCXX)" $(CXX)
34*b9411a12SAndroid Build Coastguard Workerendif
35*b9411a12SAndroid Build Coastguard Worker
36*b9411a12SAndroid Build Coastguard Worker# include-what-you-use integration
37*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_IWYU),y)
38*b9411a12SAndroid Build Coastguard Worker
39*b9411a12SAndroid Build Coastguard WorkerIWYU:=$(word 1,$(wildcard $(addsuffix /iwyu,$(subst :, ,$(PATH)))))
40*b9411a12SAndroid Build Coastguard Workerifeq ($(IWYU),)
41*b9411a12SAndroid Build Coastguard Worker$(error include-what-you-use selected, but not found in PATH)
42*b9411a12SAndroid Build Coastguard Workerendif
43*b9411a12SAndroid Build Coastguard Worker
44*b9411a12SAndroid Build Coastguard Worker$(foreach arch,$(ARCH_SUPPORTED), \
45*b9411a12SAndroid Build Coastguard Worker	$(eval CC_$(arch):=$(IWYU) ))
46*b9411a12SAndroid Build Coastguard Worker
47*b9411a12SAndroid Build Coastguard WorkerCFLAGS_common := -Xiwyu --prefix_header_includes=remove  -Xiwyu --no_comments  -Xiwyu --no_fwd_decls $(CFLAGS_common)
48*b9411a12SAndroid Build Coastguard WorkerNOCOMPILE := 1
49*b9411a12SAndroid Build Coastguard Workerendif
50*b9411a12SAndroid Build Coastguard Worker
51*b9411a12SAndroid Build Coastguard WorkerCOREBOOT_STANDARD_STAGES := decompressor bootblock verstage romstage ramstage
52*b9411a12SAndroid Build Coastguard WorkerMAP-decompressor := bootblock
53*b9411a12SAndroid Build Coastguard Worker
54*b9411a12SAndroid Build Coastguard WorkerARCHDIR-i386	:= x86
55*b9411a12SAndroid Build Coastguard WorkerARCHDIR-x86_32	:= x86
56*b9411a12SAndroid Build Coastguard WorkerARCHDIR-x86_64	:= x86
57*b9411a12SAndroid Build Coastguard WorkerARCHDIR-arm	:= arm
58*b9411a12SAndroid Build Coastguard WorkerARCHDIR-arm64	:= arm64
59*b9411a12SAndroid Build Coastguard WorkerARCHDIR-riscv	:= riscv
60*b9411a12SAndroid Build Coastguard WorkerARCHDIR-ppc64	:= ppc64
61*b9411a12SAndroid Build Coastguard Worker
62*b9411a12SAndroid Build Coastguard WorkerCFLAGS_arm	+=
63*b9411a12SAndroid Build Coastguard WorkerCFLAGS_arm64	+= -mgeneral-regs-only
64*b9411a12SAndroid Build Coastguard WorkerCFLAGS_riscv	+=
65*b9411a12SAndroid Build Coastguard WorkerCFLAGS_x86_32	+=
66*b9411a12SAndroid Build Coastguard WorkerCFLAGS_x86_64	+= -mcmodel=large -mno-red-zone
67*b9411a12SAndroid Build Coastguard WorkerCFLAGS_ppc64	+=
68*b9411a12SAndroid Build Coastguard Worker
69*b9411a12SAndroid Build Coastguard WorkerGCC_ADAFLAGS_arm	+=
70*b9411a12SAndroid Build Coastguard WorkerGCC_ADAFLAGS_arm64	+= -mgeneral-regs-only
71*b9411a12SAndroid Build Coastguard WorkerGCC_ADAFLAGS_riscv	+=
72*b9411a12SAndroid Build Coastguard WorkerGCC_ADAFLAGS_x86_32	+=
73*b9411a12SAndroid Build Coastguard WorkerGCC_ADAFLAGS_x86_64	+= -mcmodel=large -mno-red-zone
74*b9411a12SAndroid Build Coastguard WorkerGCC_ADAFLAGS_ppc64	+=
75*b9411a12SAndroid Build Coastguard Worker
76*b9411a12SAndroid Build Coastguard Worker# Some boards only provide 2K stacks, so storing lots of data there leads to
77*b9411a12SAndroid Build Coastguard Worker# problems. Since C rules don't allow us to statically determine the maximum
78*b9411a12SAndroid Build Coastguard Worker# stack use, we use 1.5K as heuristic, assuming that we typically have lots
79*b9411a12SAndroid Build Coastguard Worker# of tiny stack frames and the odd large one.
80*b9411a12SAndroid Build Coastguard Worker#
81*b9411a12SAndroid Build Coastguard Worker# Store larger buffers in BSS, use static to share data in cache-as-ram
82*b9411a12SAndroid Build Coastguard Worker# on x86.
83*b9411a12SAndroid Build Coastguard Worker# Since GCCs detection of dynamic array bounds unfortunately seems to be
84*b9411a12SAndroid Build Coastguard Worker# very basic, you'll sometimes have to use a static upper bound for the
85*b9411a12SAndroid Build Coastguard Worker# size and an assert() to make sure it's honored (see gpio_base3_value()
86*b9411a12SAndroid Build Coastguard Worker# for an example).
87*b9411a12SAndroid Build Coastguard Worker# (If you absolutely need a larger stack frame and are 100% sure it cannot
88*b9411a12SAndroid Build Coastguard Worker# cause problems, you can whitelist it with #pragma diagnostic.)
89*b9411a12SAndroid Build Coastguard Workerifeq ($(CONFIG_COMPILER_GCC),y)
90*b9411a12SAndroid Build Coastguard WorkerCFLAGS_arm	+= -Wstack-usage=1536
91*b9411a12SAndroid Build Coastguard WorkerCFLAGS_arm64	+= -Wstack-usage=1536
92*b9411a12SAndroid Build Coastguard WorkerCFLAGS_riscv	+= -Wstack-usage=1536
93*b9411a12SAndroid Build Coastguard WorkerCFLAGS_ppc64	+= -Wstack-usage=1536
94*b9411a12SAndroid Build Coastguard Workerendif
95*b9411a12SAndroid Build Coastguard Worker
96*b9411a12SAndroid Build Coastguard Workertoolchain_to_dir = \
97*b9411a12SAndroid Build Coastguard Worker	$(foreach arch,$(ARCH_SUPPORTED),\
98*b9411a12SAndroid Build Coastguard Worker	$(eval CPPFLAGS_$(arch) += \
99*b9411a12SAndroid Build Coastguard Worker	-Isrc/arch/$(ARCHDIR-$(arch))/include))
100*b9411a12SAndroid Build Coastguard Worker
101*b9411a12SAndroid Build Coastguard Worker# set_stage_toolchain: Decides the toolchain to be used by every stage
102*b9411a12SAndroid Build Coastguard Worker# E.g.: If bootblock is x86_32, it sets ARCH-BOOTBLOCK-y = x86_32, whereas
103*b9411a12SAndroid Build Coastguard Worker# ARCH-BOOTBLOCK-n = armv7. Then, ARCH-BOOTBLOCK-y can be used anywhere to
104*b9411a12SAndroid Build Coastguard Worker# decide the compiler toolchain for bootblock stage
105*b9411a12SAndroid Build Coastguard Worker# This step is essential for initializing the toolchain for coreboot standard
106*b9411a12SAndroid Build Coastguard Worker# stages i.e. bootblock, romstage and ramstage, since it acts as the second
107*b9411a12SAndroid Build Coastguard Worker# parameter to create_class_compiler below in init_standard_toolchain
108*b9411a12SAndroid Build Coastguard Workermap_stage = $(strip $(if $(MAP-$(1)),$(MAP-$(1)),$(1)))
109*b9411a12SAndroid Build Coastguard Workerset_stage_toolchain= \
110*b9411a12SAndroid Build Coastguard Worker	$(foreach arch,$(ARCH_SUPPORTED), \
111*b9411a12SAndroid Build Coastguard Worker	$(eval ARCH-$(1)-$($(shell \
112*b9411a12SAndroid Build Coastguard Worker		echo CONFIG_ARCH_$(call map_stage,$(1))_$(arch) | \
113*b9411a12SAndroid Build Coastguard Worker		tr '[:lower:]' '[:upper:]')) := $(arch)))
114*b9411a12SAndroid Build Coastguard Worker
115*b9411a12SAndroid Build Coastguard Worker# standard-archs: Tell which architectures are used by the standard stages.
116*b9411a12SAndroid Build Coastguard Workerstandard-archs = $(sort $(foreach stagearch, \
117*b9411a12SAndroid Build Coastguard Worker			  $(patsubst %,ARCH-%-y,$(COREBOOT_STANDARD_STAGES)), \
118*b9411a12SAndroid Build Coastguard Worker			  $($(stagearch))))
119*b9411a12SAndroid Build Coastguard Worker
120*b9411a12SAndroid Build Coastguard Worker# create_class_compiler: Used to create compiler tool set for
121*b9411a12SAndroid Build Coastguard Worker# special classes
122*b9411a12SAndroid Build Coastguard Worker# @1: special class
123*b9411a12SAndroid Build Coastguard Worker# @2: compiler set to be used
124*b9411a12SAndroid Build Coastguard Worker# e.g.: smm special class uses i386 as compiler set
125*b9411a12SAndroid Build Coastguard Workerdefine create_class_compiler
126*b9411a12SAndroid Build Coastguard Worker$(if $(2),,$(warning *** The toolchain architecture for $(1) is unknown.) \
127*b9411a12SAndroid Build Coastguard Worker	$(warning CONFIG_ARCH_$(1)_* settings in $(DOTCONFIG):) \
128*b9411a12SAndroid Build Coastguard Worker	$(error $(shell grep CONFIG_ARCH_$(1)_ $(DOTCONFIG))))
129*b9411a12SAndroid Build Coastguard WorkerCC_$(1) := $(CC_$(2))
130*b9411a12SAndroid Build Coastguard WorkerGCC_$(1) := $(GCC_CC_$(2))
131*b9411a12SAndroid Build Coastguard WorkerLD_$(1) := $(LD_$(2))
132*b9411a12SAndroid Build Coastguard WorkerNM_$(1) := $(NM_$(2))
133*b9411a12SAndroid Build Coastguard WorkerAR_$(1) := $(AR_$(2))
134*b9411a12SAndroid Build Coastguard WorkerGNATBIND_$(1) := $(GNATBIND_$(2))
135*b9411a12SAndroid Build Coastguard WorkerOBJCOPY_$(1) := $(OBJCOPY_$(2))
136*b9411a12SAndroid Build Coastguard WorkerOBJDUMP_$(1) := $(OBJDUMP_$(2))
137*b9411a12SAndroid Build Coastguard WorkerSTRIP_$(1) := $(STRIP_$(2))
138*b9411a12SAndroid Build Coastguard WorkerREADELF_$(1) := $(READELF_$(2))
139*b9411a12SAndroid Build Coastguard WorkerCFLAGS_$(1) = $$(CFLAGS_common) $$(CFLAGS_$(2))
140*b9411a12SAndroid Build Coastguard WorkerADAFLAGS_$(1) = --RTS=$$(obj)/libgnat-$(2)/ $$(ADAFLAGS_common) $$(GCC_ADAFLAGS_$(2))
141*b9411a12SAndroid Build Coastguard WorkerCPPFLAGS_$(1) = $$(CPPFLAGS_common) $$(CPPFLAGS_$(2)) -D__ARCH_$(2)__
142*b9411a12SAndroid Build Coastguard WorkerCOMPILER_RT_$(1) := $$(COMPILER_RT_$(2))
143*b9411a12SAndroid Build Coastguard WorkerCOMPILER_RT_FLAGS_$(1) := $$(COMPILER_RT_FLAGS_$(2))
144*b9411a12SAndroid Build Coastguard WorkerLDFLAGS_$(1) = $$(LDFLAGS_common) $$(LDFLAGS_$(2))
145*b9411a12SAndroid Build Coastguard Workerendef
146*b9411a12SAndroid Build Coastguard Worker
147*b9411a12SAndroid Build Coastguard Worker# define_class: Allows defining any program as dynamic class and compiler tool
148*b9411a12SAndroid Build Coastguard Worker# set for the same based on the architecture for which the program is to be
149*b9411a12SAndroid Build Coastguard Worker# compiled
150*b9411a12SAndroid Build Coastguard Worker# @1: program (class name)
151*b9411a12SAndroid Build Coastguard Worker# @2: architecture for which the program needs to be compiled
152*b9411a12SAndroid Build Coastguard Worker# IMP: Ensure that define_class is called before any .c or .S files are added to
153*b9411a12SAndroid Build Coastguard Worker# the class of the program. Check subdirs-y for order of subdirectory inclusions
154*b9411a12SAndroid Build Coastguard Workerdefine define_class
155*b9411a12SAndroid Build Coastguard Workerclasses-y += $(1)
156*b9411a12SAndroid Build Coastguard Worker$(eval $(call create_class_compiler,$(1),$(2)))
157*b9411a12SAndroid Build Coastguard Workerendef
158*b9411a12SAndroid Build Coastguard Worker
159*b9411a12SAndroid Build Coastguard Worker# initialize standard toolchain (CC,AS and others) for give stage
160*b9411a12SAndroid Build Coastguard Worker# @1 : stage for which the toolchain is to be initialized
161*b9411a12SAndroid Build Coastguard Workerinit_standard_toolchain = \
162*b9411a12SAndroid Build Coastguard Worker	$(eval $(call set_stage_toolchain,$(1))) \
163*b9411a12SAndroid Build Coastguard Worker	$(eval $(call create_class_compiler,$(1),$(ARCH-$(1)-y)))
164*b9411a12SAndroid Build Coastguard Worker
165*b9411a12SAndroid Build Coastguard Workerinit_stages = \
166*b9411a12SAndroid Build Coastguard Worker	$(foreach stage,$(COREBOOT_STANDARD_STAGES), \
167*b9411a12SAndroid Build Coastguard Worker	$(eval $(call init_standard_toolchain,$(stage))))
168*b9411a12SAndroid Build Coastguard Worker
169*b9411a12SAndroid Build Coastguard Worker$(eval $(call toolchain_to_dir))
170*b9411a12SAndroid Build Coastguard Worker
171*b9411a12SAndroid Build Coastguard Worker$(call init_stages)
172*b9411a12SAndroid Build Coastguard Worker
173*b9411a12SAndroid Build Coastguard Worker# Test for coreboot toolchain (except when explicitly not requested)
174*b9411a12SAndroid Build Coastguard Workerifneq ($(NOCOMPILE),1)
175*b9411a12SAndroid Build Coastguard Worker# Only run if we're doing a build (not for tests, kconfig, ...)
176*b9411a12SAndroid Build Coastguard Worker# rationale: gcc versions by Linux distributions tend to be quite messed up
177*b9411a12SAndroid Build Coastguard Worker# llvm/clang also needs patches supplied by the coreboot build
178*b9411a12SAndroid Build Coastguard WorkerCOMPILERFAIL:=0
179*b9411a12SAndroid Build Coastguard WorkerIASLFAIL:=0
180*b9411a12SAndroid Build Coastguard Worker
181*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_ANY_TOOLCHAIN),y)
182*b9411a12SAndroid Build Coastguard Worker# Verify that the coreboot toolchain is being used.
183*b9411a12SAndroid Build Coastguard Worker$(foreach arch,$(sort $(foreach stage,\
184*b9411a12SAndroid Build Coastguard Worker	$(COREBOOT_STANDARD_STAGES),$(ARCH-$(stage)-y))), \
185*b9411a12SAndroid Build Coastguard Worker	$(if $(shell if [ -n "$(CC_$(arch))" ]; then \
186*b9411a12SAndroid Build Coastguard Worker		$(CC_$(arch)) -v 2>&1 | grep -q "coreboot toolchain" || \
187*b9411a12SAndroid Build Coastguard Worker		echo not-coreboot; else echo not-coreboot; fi), \
188*b9411a12SAndroid Build Coastguard Worker		$(eval COMPILERFAIL:=1)\
189*b9411a12SAndroid Build Coastguard Worker		$(warning The coreboot toolchain for '$(arch)'\
190*b9411a12SAndroid Build Coastguard Worker			architecture was not found.)))
191*b9411a12SAndroid Build Coastguard Worker# If iasl doesn't match the current coreboot version, fail the test
192*b9411a12SAndroid Build Coastguard Worker# TODO: Figure out if iasl is even needed for the build.
193*b9411a12SAndroid Build Coastguard Worker$(if $(shell if [ -n "$(IASL)" ]; then \
194*b9411a12SAndroid Build Coastguard Worker	$(IASL) -v 2>&1 | grep -q "coreboot toolchain" || \
195*b9411a12SAndroid Build Coastguard Worker	echo not-coreboot; else echo not-coreboot; fi), \
196*b9411a12SAndroid Build Coastguard Worker	$(eval COMPILERFAIL:=1)$(eval IASLFAIL:=1)\
197*b9411a12SAndroid Build Coastguard Worker	$(warning The coreboot toolchain version of iasl \
198*b9411a12SAndroid Build Coastguard Worker		'$(shell util/crossgcc/buildgcc -s iasl)' was not found))
199*b9411a12SAndroid Build Coastguard Workerelse #$(CONFIG_ANY_TOOLCHAIN)
200*b9411a12SAndroid Build Coastguard Worker# If the coreboot toolchain isn't being used, verify that there is A toolchain
201*b9411a12SAndroid Build Coastguard Worker$(foreach arch,$(sort \
202*b9411a12SAndroid Build Coastguard Worker	$(foreach stage,$(COREBOOT_STANDARD_STAGES),$(ARCH-$(stage)-y))), \
203*b9411a12SAndroid Build Coastguard Worker	$(if $(CC_$(arch)),, $(eval COMPILERFAIL:=1) \
204*b9411a12SAndroid Build Coastguard Worker	$(warning No compiler found for '$(arch)' architecture. \
205*b9411a12SAndroid Build Coastguard Worker		Install one or use the coreboot toolchain?)) )
206*b9411a12SAndroid Build Coastguard Worker# If iasl isn't present, fail
207*b9411a12SAndroid Build Coastguard Worker# TODO: Figure out if iasl is even needed for the build.
208*b9411a12SAndroid Build Coastguard Worker$(if $(IASL),, $(eval COMPILERFAIL:=1)$(eval IASLFAIL:=1) \
209*b9411a12SAndroid Build Coastguard Worker	$(warning iasl not found. \
210*b9411a12SAndroid Build Coastguard Worker		Please install it or use the coreboot toolchain.))
211*b9411a12SAndroid Build Coastguard Workerendif
212*b9411a12SAndroid Build Coastguard Worker
213*b9411a12SAndroid Build Coastguard Worker# If the compiler check failed, print out warnings
214*b9411a12SAndroid Build Coastguard Workerifeq ($(COMPILERFAIL),1)
215*b9411a12SAndroid Build Coastguard Workerifneq ($(XGCCPATH),)
216*b9411a12SAndroid Build Coastguard Worker$(warning )
217*b9411a12SAndroid Build Coastguard Worker$(warning Path to your toolchain is currently set to '$(XGCCPATH)')
218*b9411a12SAndroid Build Coastguard Workerendif
219*b9411a12SAndroid Build Coastguard Worker$(warning )
220*b9411a12SAndroid Build Coastguard Worker$(warning To build the entire coreboot toolchain: run 'make crossgcc')
221*b9411a12SAndroid Build Coastguard Workerifeq ($(IASLFAIL),1)
222*b9411a12SAndroid Build Coastguard Worker$(warning To build just IASL: run 'make iasl')
223*b9411a12SAndroid Build Coastguard Workerendif #($(IASLFAIL),1)
224*b9411a12SAndroid Build Coastguard Worker$(warning For more toolchain build targets: run 'make help_toolchain')
225*b9411a12SAndroid Build Coastguard Worker$(warning )
226*b9411a12SAndroid Build Coastguard Workerifneq ($(CONFIG_ANY_TOOLCHAIN),y)
227*b9411a12SAndroid Build Coastguard Worker$(warning To try to use any toolchain in your path, \
228*b9411a12SAndroid Build Coastguard Worker	run 'make menuconfig', then select)
229*b9411a12SAndroid Build Coastguard Worker$(warning the config option: 'General setup', \
230*b9411a12SAndroid Build Coastguard Worker	and 'Allow building with any toolchain')
231*b9411a12SAndroid Build Coastguard Worker$(warning Note that this is NOT supported.  \
232*b9411a12SAndroid Build Coastguard Worker	Using it means you're on your own.)
233*b9411a12SAndroid Build Coastguard Worker$(warning )
234*b9411a12SAndroid Build Coastguard Workerendif #($(CONFIG_ANY_TOOLCHAIN),y)
235*b9411a12SAndroid Build Coastguard Worker$(error Halting the build)
236*b9411a12SAndroid Build Coastguard Workerendif #($(COMPILERFAIL),1)
237*b9411a12SAndroid Build Coastguard Worker
238*b9411a12SAndroid Build Coastguard Workerendif #($(NOCOMPILE),1)
239*b9411a12SAndroid Build Coastguard Worker
240*b9411a12SAndroid Build Coastguard Worker# Run the toolchain version checks if the requested target is 'test-toolchain'
241*b9411a12SAndroid Build Coastguard Worker# Checks the versions of GCC, binutils, clang, and IASL
242*b9411a12SAndroid Build Coastguard Workerifneq ($(MAKECMDGOALS),)
243*b9411a12SAndroid Build Coastguard Workerifneq ($(filter test-toolchain,$(MAKECMDGOALS)),)
244*b9411a12SAndroid Build Coastguard Worker$(foreach arch, $(ARCH_SUPPORTED), \
245*b9411a12SAndroid Build Coastguard Worker	$(if $(shell if [ -n "$(GCC_CC_$(arch))" ]; then \
246*b9411a12SAndroid Build Coastguard Worker		$(GCC_CC_$(arch)) --version 2>&1 | head -n1 | rev | \
247*b9411a12SAndroid Build Coastguard Worker		cut -d ' ' -f 1 | rev | \
248*b9411a12SAndroid Build Coastguard Worker		grep -q "$$(util/crossgcc/buildgcc -s gcc)" || \
249*b9411a12SAndroid Build Coastguard Worker		echo not-current; fi), \
250*b9411a12SAndroid Build Coastguard Worker		$(eval COMPILER_OUT_OF_DATE:=1) \
251*b9411a12SAndroid Build Coastguard Worker		$(warning The coreboot toolchain version of gcc for '$(arch)' \
252*b9411a12SAndroid Build Coastguard Worker			architecture is not the current version.) \
253*b9411a12SAndroid Build Coastguard Worker		$(warning $(arch) gcc version from buildgcc: \
254*b9411a12SAndroid Build Coastguard Worker			$(shell util/crossgcc/buildgcc -s gcc)) \
255*b9411a12SAndroid Build Coastguard Worker		$(warning $(arch) version of gcc executable: \
256*b9411a12SAndroid Build Coastguard Worker			$(shell $(GCC_CC_$(arch)) --version | head -n1 | \
257*b9411a12SAndroid Build Coastguard Worker			rev | cut -d ' ' -f 1 | rev))) \
258*b9411a12SAndroid Build Coastguard Worker	$(if $(shell if [ -n "$(CLANG_CC_$(arch))" ]; then \
259*b9411a12SAndroid Build Coastguard Worker		$(CLANG_CC_$(arch)) --version  2>&1 | \
260*b9411a12SAndroid Build Coastguard Worker			sed 's/.*clang version/clang version/' | \
261*b9411a12SAndroid Build Coastguard Worker			head -n1 | cut -d ' ' -f 3 | \
262*b9411a12SAndroid Build Coastguard Worker		grep -q "$(shell util/crossgcc/buildgcc -s clang)" || \
263*b9411a12SAndroid Build Coastguard Worker		echo not-current; fi), \
264*b9411a12SAndroid Build Coastguard Worker		$(eval COMPILER_OUT_OF_DATE:=1) \
265*b9411a12SAndroid Build Coastguard Worker		$(warning The coreboot toolchain version of clang for \
266*b9411a12SAndroid Build Coastguard Worker			'$(arch)' architecture is not the current version.) \
267*b9411a12SAndroid Build Coastguard Worker		$(warning $(arch) clang version from buildgcc: \
268*b9411a12SAndroid Build Coastguard Worker			$(shell util/crossgcc/buildgcc -s clang)) \
269*b9411a12SAndroid Build Coastguard Worker		$(warning $(arch) version of clang executable: \
270*b9411a12SAndroid Build Coastguard Worker			$(shell $(CLANG_CC_$(arch)) --version 2>&1 | \
271*b9411a12SAndroid Build Coastguard Worker			sed 's/.*clang version/clang version/' | \
272*b9411a12SAndroid Build Coastguard Worker			head -n1 | cut -d ' ' -f 3))) \
273*b9411a12SAndroid Build Coastguard Worker	$(if $(shell if [ "$(OBJDUMP_$(arch))" != "invalidobjdump" ]; then \
274*b9411a12SAndroid Build Coastguard Worker		$(OBJDUMP_$(arch)) -v 2>&1 | \
275*b9411a12SAndroid Build Coastguard Worker		grep -q "$(shell util/crossgcc/buildgcc -s binutils)" || \
276*b9411a12SAndroid Build Coastguard Worker		echo not-current; fi), \
277*b9411a12SAndroid Build Coastguard Worker		$(eval COMPILER_OUT_OF_DATE:=1)\
278*b9411a12SAndroid Build Coastguard Worker		$(warning The coreboot toolchain version of binutils for \
279*b9411a12SAndroid Build Coastguard Worker			'$(arch)' architecture is not the current version.)) \
280*b9411a12SAndroid Build Coastguard Worker)
281*b9411a12SAndroid Build Coastguard Worker$(if $(shell if [ -n "$(IASL)" ]; then $(IASL) -v 2>&1 | \
282*b9411a12SAndroid Build Coastguard Worker	grep -q "$(shell util/crossgcc/buildgcc -s iasl)" || \
283*b9411a12SAndroid Build Coastguard Worker	echo not-coreboot; fi), \
284*b9411a12SAndroid Build Coastguard Worker	$(eval COMPILER_OUT_OF_DATE:=1)\
285*b9411a12SAndroid Build Coastguard Worker	$(warning The coreboot toolchain version of iasl \
286*b9411a12SAndroid Build Coastguard Worker		is not the current version) \
287*b9411a12SAndroid Build Coastguard Worker		$(warning $(arch) iasl version from buildgcc: \
288*b9411a12SAndroid Build Coastguard Worker			$(shell util/crossgcc/buildgcc -s iasl)) \
289*b9411a12SAndroid Build Coastguard Worker		$(warning $(arch) version of iasl executable: \
290*b9411a12SAndroid Build Coastguard Worker			$(shell $(IASL) -v 2>&1 | \
291*b9411a12SAndroid Build Coastguard Worker			grep ASL+ | rev | cut -f 1 -d ' ' | rev)))
292*b9411a12SAndroid Build Coastguard Worker$(eval UPDATED_SUBMODULES:=1)
293*b9411a12SAndroid Build Coastguard Workerendif #($(filter crossgcc_check%,$(MAKECMDGOALS)),)
294*b9411a12SAndroid Build Coastguard Workerendif #($(MAKECMDGOALS),)
295