Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 1 | ## |
| 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 Georgi | 4ebd3d9 | 2014-05-17 14:02:08 +0200 | [diff] [blame] | 20 | ARCH_SUPPORTED := armv7 x86_32 |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 21 | |
| 22 | COREBOOT_STANDARD_STAGES := bootblock romstage ramstage |
| 23 | |
| 24 | ARCHDIR-i386 := x86 |
| 25 | ARCHDIR-x86_32 := x86 |
| 26 | ARCHDIR-armv7 := armv7 |
| 27 | |
Patrick Georgi | b145b83 | 2014-05-17 15:08:47 +0200 | [diff] [blame] | 28 | CFLAGS_armv7 += \ |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 29 | -ffixed-r8\ |
| 30 | -march=armv7-a\ |
| 31 | -marm\ |
| 32 | -mno-unaligned-access\ |
| 33 | -mthumb\ |
| 34 | -mthumb-interwork |
| 35 | |
| 36 | toolchain_to_dir = \ |
| 37 | $(foreach arch,$(ARCH_SUPPORTED),\ |
Patrick Georgi | b145b83 | 2014-05-17 15:08:47 +0200 | [diff] [blame] | 38 | $(eval CPPFLAGS_$(arch) += \ |
Patrick Georgi | 4ebd3d9 | 2014-05-17 14:02:08 +0200 | [diff] [blame] | 39 | -Isrc/arch/$(ARCHDIR-$(arch))/include)) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 40 | |
| 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 |
| 48 | set_stage_toolchain= \ |
Patrick Georgi | 4ebd3d9 | 2014-05-17 14:02:08 +0200 | [diff] [blame] | 49 | $(foreach arch,$(ARCH_SUPPORTED),$(eval ARCH-$(1)-$($(shell echo CONFIG_ARCH_$(1)_$(arch) | tr '[:lower:]' '[:upper:]')) := $(arch))) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 50 | |
| 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 |
| 56 | define create_class_compiler |
| 57 | CC_$(1) := $(CC_$(2)) |
| 58 | LD_$(1) := $(LD_$(2)) |
| 59 | NM_$(1) := $(NM_$(2)) |
| 60 | OBJCOPY_$(1) := $(OBJCOPY_$(2)) |
| 61 | OBJDUMP_$(1) := $(OBJDUMP_$(2)) |
| 62 | STRIP_$(1) := $(STRIP_$(2)) |
| 63 | READELF_$(1) := $(READELF_$(2)) |
Patrick Georgi | 58f73a6 | 2014-05-17 14:00:12 +0200 | [diff] [blame] | 64 | CFLAGS_$(1) = $$(CFLAGS_common) $$(CFLAGS_$(2)) |
| 65 | CPPFLAGS_$(1) = $$(CPPFLAGS_common) $$(CPPFLAGS_$(2)) |
Patrick Georgi | 6bc4455 | 2014-05-17 14:52:28 +0200 | [diff] [blame] | 66 | LIBGCC_FILE_NAME_$(1) = $(wildcard $(shell $(CC_$(2)) -print-libgcc-file-name)) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 67 | endef |
| 68 | |
| 69 | # initialize standard toolchain (CC,AS and others) for give stage |
| 70 | # @1 : stage for which the toolchain is to be initialized |
| 71 | init_standard_toolchain = \ |
Patrick Georgi | 4ebd3d9 | 2014-05-17 14:02:08 +0200 | [diff] [blame] | 72 | $(eval $(call set_stage_toolchain,$(1))) \ |
Patrick Georgi | 262f31c | 2014-05-17 15:13:40 +0200 | [diff] [blame] | 73 | $(eval $(call create_class_compiler,$(1),$(ARCH-$(1)-y))) |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 74 | |
| 75 | init_stages = \ |
| 76 | $(foreach stage,$(COREBOOT_STANDARD_STAGES),$(eval $(call init_standard_toolchain,$(stage)))) |
| 77 | |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 78 | $(eval $(call toolchain_to_dir)) |
| 79 | |
| 80 | $(call init_stages) |