| # Copyright 2021 The Android KVM Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| # Find the toolchain path for the current OS. |
| UNNAME_S := $(shell uname -s | tr '[:upper:]' '[:lower:]') |
| TOOLCHAIN_arm64_clang := $(ROOT_DIR)/toolchains/$(UNNAME_S)-x86/clang/clang-r416183b |
| TOOLCHAIN_arm64_gcc-5.1 := $(ROOT_DIR)/toolchains/$(UNNAME_S)-x86/gcc/aarch64-linux-gnu-5.1 |
| TOOLCHAIN_arm64_gcc-9.2 := $(ROOT_DIR)/toolchains/$(UNNAME_S)-x86/gcc/aarch64-linux-gnu-9.2 |
| |
| # Set the toolchain build binary paths and prefixes. |
| TARGET_arm64_clang := aarch64-linux-gnu |
| TARGET_arm64_gcc-5.1 := aarch64-linux-gnu |
| TARGET_arm64_gcc-9.2 := aarch64-none-linux-gnu |
| |
| # |
| # $(1): toolchain name |
| # $(2): toolchain variables' prefix |
| # |
| define define_toolchain |
| $(2)TOOLCHAIN_IS_LEGACY := 0 |
| $(2)TOOLCHAIN_IS_LLVM := 0 |
| |
| ifeq ($(1), gcc-5.1) |
| $(2)TOOLCHAIN_IS_LEGACY := 1 |
| else ifeq ($(1), gcc-9.2) |
| else ifeq ($(1), clang) |
| $(2)TOOLCHAIN_IS_LLVM := 1 |
| else |
| $$(error Unrecognized toolchain: $(1)) |
| endif |
| |
| $(2)TOOLCHAIN_BIN := $(TOOLCHAIN_$(ARCH)_$(1))/bin |
| $(2)TARGET := $(TARGET_$(ARCH)_$(1)) |
| |
| ifeq ($$($(2)TOOLCHAIN_IS_LLVM),1) |
| $(2)CC := $$($(2)TOOLCHAIN_BIN)/clang |
| $(2)LD := $$($(2)TOOLCHAIN_BIN)/ld.lld |
| $(2)OBJCOPY := $$($(2)TOOLCHAIN_BIN)/llvm-objcopy |
| $(2)OBJDUMP := $$($(2)TOOLCHAIN_BIN)/llvm-objdump |
| else |
| $(2)CC := $$($(2)TOOLCHAIN_BIN)/$$($(2)TARGET)-gcc |
| $(2)LD := $$($(2)TOOLCHAIN_BIN)/$$($(2)TARGET)-ld |
| $(2)OBJCOPY := $$($(2)TOOLCHAIN_BIN)/$$($(2)TARGET)-objcopy |
| $(2)OBJDUMP := $$($(2)TOOLCHAIN_BIN)/$$($(2)TARGET)-objdump |
| endif |
| endef |