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 | |
| 20 | ARCH_SUPPORTED := ARMV7 X86_32 |
| 21 | |
| 22 | ARCH_TO_TOOLCHAIN_X86_32 := x86_32 |
| 23 | ARCH_TO_TOOLCHAIN_ARMV7 := armv7 |
| 24 | |
| 25 | COREBOOT_STANDARD_STAGES := bootblock romstage ramstage |
| 26 | |
| 27 | ARCHDIR-i386 := x86 |
| 28 | ARCHDIR-x86_32 := x86 |
| 29 | ARCHDIR-armv7 := armv7 |
| 30 | |
| 31 | CFLAGS_armv7 = \ |
| 32 | -ffixed-r8\ |
| 33 | -march=armv7-a\ |
| 34 | -marm\ |
| 35 | -mno-unaligned-access\ |
| 36 | -mthumb\ |
| 37 | -mthumb-interwork |
| 38 | |
| 39 | toolchain_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 |
| 51 | set_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 |
| 59 | define create_class_compiler |
| 60 | CC_$(1) := $(CC_$(2)) |
| 61 | LD_$(1) := $(LD_$(2)) |
| 62 | NM_$(1) := $(NM_$(2)) |
| 63 | OBJCOPY_$(1) := $(OBJCOPY_$(2)) |
| 64 | OBJDUMP_$(1) := $(OBJDUMP_$(2)) |
| 65 | STRIP_$(1) := $(STRIP_$(2)) |
| 66 | READELF_$(1) := $(READELF_$(2)) |
| 67 | INCLUDES_$(1) = -Isrc/arch/$(ARCHDIR-$(2))/include |
| 68 | CFLAGS_$(1) = $$(CFLAGS_common) $$(INCLUDES_$(1)) $(CFLAGS_$(2)) |
Aaron Durbin | c087a9e | 2014-05-08 11:14:41 -0500 | [diff] [blame] | 69 | LIBGCC_FILE_NAME_$(1) = $(shell [ -r `$(CC_$(2)) -print-libgcc-file-name` ] && \ |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 70 | $(CC_$(2)) -print-libgcc-file-name) |
| 71 | endef |
| 72 | |
| 73 | # initialize standard toolchain (CC,AS and others) for give stage |
| 74 | # @1 : stage for which the toolchain is to be initialized |
| 75 | init_standard_toolchain = \ |
Aaron Durbin | c087a9e | 2014-05-08 11:14:41 -0500 | [diff] [blame] | 76 | $(eval stage_caps := $(shell printf "%s" $(1) | tr '[:lower:]' '[:upper:]' )) \ |
Furquan Shaikh | 99ac98f | 2014-04-23 10:18:48 -0700 | [diff] [blame] | 77 | $(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 | |
| 81 | init_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) |