blob: 9417a7323c1afe0a995b643fa6cd85a153a28a9c [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
Patrick Georgi4ebd3d92014-05-17 14:02:08 +020020ARCH_SUPPORTED := armv7 x86_32
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070021
22COREBOOT_STANDARD_STAGES := bootblock romstage ramstage
23
24ARCHDIR-i386 := x86
25ARCHDIR-x86_32 := x86
26ARCHDIR-armv7 := armv7
27
Patrick Georgib145b832014-05-17 15:08:47 +020028CFLAGS_armv7 += \
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070029 -ffixed-r8\
30 -march=armv7-a\
31 -marm\
32 -mno-unaligned-access\
33 -mthumb\
34 -mthumb-interwork
35
36toolchain_to_dir = \
37 $(foreach arch,$(ARCH_SUPPORTED),\
Patrick Georgib145b832014-05-17 15:08:47 +020038 $(eval CPPFLAGS_$(arch) += \
Patrick Georgi4ebd3d92014-05-17 14:02:08 +020039 -Isrc/arch/$(ARCHDIR-$(arch))/include))
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070040
41# set_stage_toolchain: Decides the toolchain to be used by every stage
42# E.g.: If bootblock is x86_32, it sets ARCH-BOOTBLOCK-y = x86_32, whereas
43# ARCH-BOOTBLOCK-n = armv7. Then, ARCH-BOOTBLOCK-y can be used anywhere to
44# decide the compiler toolchain for bootblock stage
45# This step is essential for initializing the toolchain for coreboot standard
46# stages i.e. bootblock, romstage and ramstage, since it acts as the second
47# parameter to create_class_compiler below in init_standard_toolchain
48set_stage_toolchain= \
Patrick Georgi4ebd3d92014-05-17 14:02:08 +020049 $(foreach arch,$(ARCH_SUPPORTED),$(eval ARCH-$(1)-$($(shell echo CONFIG_ARCH_$(1)_$(arch) | tr '[:lower:]' '[:upper:]')) := $(arch)))
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070050
51# create_class_compiler: Used to create compiler tool set for
52# special classes
53# @1: special class
54# @2: compiler set to be used
55# e.g.: smm special class uses i386 as compiler set
56define create_class_compiler
57CC_$(1) := $(CC_$(2))
58LD_$(1) := $(LD_$(2))
59NM_$(1) := $(NM_$(2))
60OBJCOPY_$(1) := $(OBJCOPY_$(2))
61OBJDUMP_$(1) := $(OBJDUMP_$(2))
62STRIP_$(1) := $(STRIP_$(2))
63READELF_$(1) := $(READELF_$(2))
Patrick Georgi58f73a62014-05-17 14:00:12 +020064CFLAGS_$(1) = $$(CFLAGS_common) $$(CFLAGS_$(2))
65CPPFLAGS_$(1) = $$(CPPFLAGS_common) $$(CPPFLAGS_$(2))
Patrick Georgi6bc44552014-05-17 14:52:28 +020066LIBGCC_FILE_NAME_$(1) = $(wildcard $(shell $(CC_$(2)) -print-libgcc-file-name))
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070067endef
68
69# initialize standard toolchain (CC,AS and others) for give stage
70# @1 : stage for which the toolchain is to be initialized
71init_standard_toolchain = \
Patrick Georgi4ebd3d92014-05-17 14:02:08 +020072 $(eval $(call set_stage_toolchain,$(1))) \
Patrick Georgi262f31c2014-05-17 15:13:40 +020073 $(eval $(call create_class_compiler,$(1),$(ARCH-$(1)-y)))
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070074
75init_stages = \
76 $(foreach stage,$(COREBOOT_STANDARD_STAGES),$(eval $(call init_standard_toolchain,$(stage))))
77
Furquan Shaikh99ac98f2014-04-23 10:18:48 -070078$(eval $(call toolchain_to_dir))
79
80$(call init_stages)