blob: bb65755d750e91090cb4fb6a5eec0e330e685d1a [file] [log] [blame]
Joakim Bech427dd632015-05-04 15:52:33 +02001################################################################################
2# Toolchains
3################################################################################
Yunli Liu904f1482021-01-22 11:08:08 +08004SHELL = /bin/bash
Joakim Bechc9606632017-01-27 11:50:49 +01005ROOT ?= $(CURDIR)/..
Joakim Bech427dd632015-05-04 15:52:33 +02006TOOLCHAIN_ROOT ?= $(ROOT)/toolchains
7
8AARCH32_PATH ?= $(TOOLCHAIN_ROOT)/aarch32
9AARCH32_CROSS_COMPILE ?= $(AARCH32_PATH)/bin/arm-linux-gnueabihf-
Jerome Forissier38cc5a82020-09-21 17:42:09 +020010AARCH32_GCC_VERSION ?= gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf
11SRC_AARCH32_GCC ?= https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/$(AARCH32_GCC_VERSION).tar.xz
Joakim Bech427dd632015-05-04 15:52:33 +020012
13AARCH64_PATH ?= $(TOOLCHAIN_ROOT)/aarch64
14AARCH64_CROSS_COMPILE ?= $(AARCH64_PATH)/bin/aarch64-linux-gnu-
Jerome Forissier38cc5a82020-09-21 17:42:09 +020015AARCH64_GCC_VERSION ?= gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu
16SRC_AARCH64_GCC ?= https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/$(AARCH64_GCC_VERSION).tar.xz
Joakim Bech427dd632015-05-04 15:52:33 +020017
Joakim Bechc9606632017-01-27 11:50:49 +010018# Download toolchain macro for saving some repetition
19# $(1) is $AARCH.._PATH : i.e., path to the destination
20# $(2) is $SRC_AARCH.._GCC : is the downloaded tar.gz file
21# $(3) is $.._GCC_VERSION : the name of the file to download
22define dltc
23 @if [ ! -d "$(1)" ]; then \
24 mkdir -p $(1); \
25 echo "Downloading $(3) ..."; \
26 curl -s -L $(2) -o $(TOOLCHAIN_ROOT)/$(3).tar.xz; \
27 tar xf $(TOOLCHAIN_ROOT)/$(3).tar.xz -C $(1) --strip-components=1; \
Jerome Forissier38cc5a82020-09-21 17:42:09 +020028 (cd $(1)/bin && for f in *-none-linux*; do ln -s $$f $${f//-none} ; done;) \
Joakim Bechc9606632017-01-27 11:50:49 +010029 fi
30endef
31
32.PHONY: toolchains
Joakim Bech6a0fc2b2018-05-23 08:38:47 +020033toolchains: aarch32 aarch64
Joakim Bech427dd632015-05-04 15:52:33 +020034
Joakim Bechc9606632017-01-27 11:50:49 +010035.PHONY: aarch32
Joakim Bech42807a72017-01-27 10:43:28 +010036aarch32:
Joakim Bechc9606632017-01-27 11:50:49 +010037 $(call dltc,$(AARCH32_PATH),$(SRC_AARCH32_GCC),$(AARCH32_GCC_VERSION))
Joakim Bech427dd632015-05-04 15:52:33 +020038
Joakim Bechc9606632017-01-27 11:50:49 +010039.PHONY: aarch64
Joakim Bech42807a72017-01-27 10:43:28 +010040aarch64:
Joakim Bechc9606632017-01-27 11:50:49 +010041 $(call dltc,$(AARCH64_PATH),$(SRC_AARCH64_GCC),$(AARCH64_GCC_VERSION))
Jerome Forissierc3cd9f52020-05-25 18:47:00 +020042
Jerome Forissierc09d34c2021-04-15 17:09:44 +020043CLANG_VER ?= 12.0.0
Jerome Forissier0ae3f0a2021-04-15 17:09:44 +020044CLANG_PATH ?= $(ROOT)/clang-$(CLANG_VER)
Jerome Forissierc3cd9f52020-05-25 18:47:00 +020045
46# Download the Clang compiler with LLVM tools and compiler-rt libraries
47define dl-clang
Jerome Forissier0ae3f0a2021-04-15 17:09:44 +020048 @if [ ! -d "$(2)" ]; then \
49 ./get_clang.sh $(1) $(2); \
Jerome Forissierc3cd9f52020-05-25 18:47:00 +020050 else \
Jerome Forissier0ae3f0a2021-04-15 17:09:44 +020051 echo "$(2) already exists"; \
Jerome Forissierc3cd9f52020-05-25 18:47:00 +020052 fi
53endef
54
55.PHONY: clang-toolchains
56clang-toolchains:
Jerome Forissier0ae3f0a2021-04-15 17:09:44 +020057 $(call dl-clang,$(CLANG_VER),$(CLANG_PATH))