blob: 576e7447ca3d70f1bc532d08a62c5a6f561ceb37 [file] [log] [blame]
Furquan Shaikh99ac98f2014-04-23 10:18:48 -07001##
2## This file is part of the coreboot project.
3##
4## Copyright (C) 2014 Google Inc
5##
6## This program is free software; you can redistribute it and/or modify
7## it under the terms of the GNU General Public License as published by
8## the Free Software Foundation; version 2 of the License.
9##
10## This program is distributed in the hope that it will be useful,
11## but WITHOUT ANY WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13## GNU General Public License for more details.
14##
15## You should have received a copy of the GNU General Public License
16## along with this program; if not, write to the Free Software
17## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18##
19
20ARCH_SUPPORTED := ARMV7 X86_32
21
22ARCH_TO_TOOLCHAIN_X86_32 := x86_32
23ARCH_TO_TOOLCHAIN_ARMV7 := armv7
24
25COREBOOT_STANDARD_STAGES := bootblock romstage ramstage
26
27ARCHDIR-i386 := x86
28ARCHDIR-x86_32 := x86
29ARCHDIR-armv7 := armv7
30
31CFLAGS_armv7 = \
32 -ffixed-r8\
33 -march=armv7-a\
34 -marm\
35 -mno-unaligned-access\
36 -mthumb\
37 -mthumb-interwork
38
39toolchain_to_dir = \
40 $(foreach arch,$(ARCH_SUPPORTED),\
41 $(eval INCLUDES_$(ARCH_TO_TOOLCHAIN_$(arch)) = \
42 -Isrc/arch/$(ARCHDIR-$(ARCH_TO_TOOLCHAIN_$(arch)))/include))
43
44# set_stage_toolchain: Decides the toolchain to be used by every stage
45# E.g.: If bootblock is x86_32, it sets ARCH-BOOTBLOCK-y = x86_32, whereas
46# ARCH-BOOTBLOCK-n = armv7. Then, ARCH-BOOTBLOCK-y can be used anywhere to
47# decide the compiler toolchain for bootblock stage
48# This step is essential for initializing the toolchain for coreboot standard
49# stages i.e. bootblock, romstage and ramstage, since it acts as the second
50# parameter to create_class_compiler below in init_standard_toolchain
51set_stage_toolchain= \
52 $(foreach arch,$(ARCH_SUPPORTED),$(eval ARCH-$(1)-$(CONFIG_ARCH_$(1)_$(arch)) := $(ARCH_TO_TOOLCHAIN_$(arch))))
53
54# create_class_compiler: Used to create compiler tool set for
55# special classes
56# @1: special class
57# @2: compiler set to be used
58# e.g.: smm special class uses i386 as compiler set
59define create_class_compiler
60CC_$(1) := $(CC_$(2))
61LD_$(1) := $(LD_$(2))
62NM_$(1) := $(NM_$(2))
63OBJCOPY_$(1) := $(OBJCOPY_$(2))
64OBJDUMP_$(1) := $(OBJDUMP_$(2))
65STRIP_$(1) := $(STRIP_$(2))
66READELF_$(1) := $(READELF_$(2))
67INCLUDES_$(1) = -Isrc/arch/$(ARCHDIR-$(2))/include
68CFLAGS_$(1) = $$(CFLAGS_common) $$(INCLUDES_$(1)) $(CFLAGS_$(2))
Aaron Durbinc087a9e2014-05-08 11:14:41 -050069LIBGCC_FILE_NAME_$(1) = $(shell [ -r `$(CC_$(2)) -print-libgcc-file-name` ] && \
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070070 $(CC_$(2)) -print-libgcc-file-name)
71endef
72
73# initialize standard toolchain (CC,AS and others) for give stage
74# @1 : stage for which the toolchain is to be initialized
75init_standard_toolchain = \
Aaron Durbinc087a9e2014-05-08 11:14:41 -050076 $(eval stage_caps := $(shell printf "%s" $(1) | tr '[:lower:]' '[:upper:]' )) \
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070077 $(eval $(call set_stage_toolchain,$(stage_caps))) \
78 $(eval $(call create_class_compiler,$(1),$(ARCH-$(stage_caps)-y))) \
79 $(eval $(call set_stage_libgcc,$(1)))
80
81init_stages = \
82 $(foreach stage,$(COREBOOT_STANDARD_STAGES),$(eval $(call init_standard_toolchain,$(stage))))
83
84# This mapping is created to have consistency with xcompile naming
85$(eval $(call create_class_compiler,x86_32,i386))
86
87$(eval $(call toolchain_to_dir))
88
89$(call init_stages)