David Brazdil | f5d3276 | 2021-08-23 08:40:18 +0000 | [diff] [blame] | 1 | # Copyright 2021 The Android KVM Authors |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | # Find the toolchain path for the current OS. |
| 16 | UNNAME_S := $(shell uname -s | tr '[:upper:]' '[:lower:]') |
| 17 | TOOLCHAIN_arm64_clang := $(ROOT_DIR)/toolchains/$(UNNAME_S)-x86/clang/clang-r416183b |
| 18 | TOOLCHAIN_arm64_gcc-5.1 := $(ROOT_DIR)/toolchains/$(UNNAME_S)-x86/gcc/aarch64-linux-gnu-5.1 |
| 19 | TOOLCHAIN_arm64_gcc-9.2 := $(ROOT_DIR)/toolchains/$(UNNAME_S)-x86/gcc/aarch64-linux-gnu-9.2 |
| 20 | |
| 21 | # Set the toolchain build binary paths and prefixes. |
| 22 | TARGET_arm64_clang := aarch64-linux-gnu |
| 23 | TARGET_arm64_gcc-5.1 := aarch64-linux-gnu |
| 24 | TARGET_arm64_gcc-9.2 := aarch64-none-linux-gnu |
| 25 | |
| 26 | # |
| 27 | # $(1): toolchain name |
| 28 | # $(2): toolchain variables' prefix |
| 29 | # |
| 30 | define define_toolchain |
| 31 | $(2)TOOLCHAIN_IS_LEGACY := 0 |
| 32 | $(2)TOOLCHAIN_IS_LLVM := 0 |
| 33 | |
| 34 | ifeq ($(1), gcc-5.1) |
| 35 | $(2)TOOLCHAIN_IS_LEGACY := 1 |
| 36 | else ifeq ($(1), gcc-9.2) |
| 37 | else ifeq ($(1), clang) |
| 38 | $(2)TOOLCHAIN_IS_LLVM := 1 |
| 39 | else |
| 40 | $$(error Unrecognized toolchain: $(1)) |
| 41 | endif |
| 42 | |
| 43 | $(2)TOOLCHAIN_BIN := $(TOOLCHAIN_$(ARCH)_$(1))/bin |
| 44 | $(2)TARGET := $(TARGET_$(ARCH)_$(1)) |
| 45 | |
| 46 | ifeq ($$($(2)TOOLCHAIN_IS_LLVM),1) |
| 47 | $(2)CC := $$($(2)TOOLCHAIN_BIN)/clang |
| 48 | $(2)LD := $$($(2)TOOLCHAIN_BIN)/ld.lld |
| 49 | $(2)OBJCOPY := $$($(2)TOOLCHAIN_BIN)/llvm-objcopy |
| 50 | $(2)OBJDUMP := $$($(2)TOOLCHAIN_BIN)/llvm-objdump |
| 51 | else |
| 52 | $(2)CC := $$($(2)TOOLCHAIN_BIN)/$$($(2)TARGET)-gcc |
| 53 | $(2)LD := $$($(2)TOOLCHAIN_BIN)/$$($(2)TARGET)-ld |
| 54 | $(2)OBJCOPY := $$($(2)TOOLCHAIN_BIN)/$$($(2)TARGET)-objcopy |
| 55 | $(2)OBJDUMP := $$($(2)TOOLCHAIN_BIN)/$$($(2)TARGET)-objdump |
| 56 | endif |
| 57 | endef |