toolchain: avoid duplicating Clang version number

To make upgrades easier, refactor the get_clang.sh script slightly.

Signed-off-by: Jerome Forissier <jerome@forissier.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/get_clang.sh b/get_clang.sh
index bce30ba..06329da 100755
--- a/get_clang.sh
+++ b/get_clang.sh
@@ -8,12 +8,11 @@
 # architectures by default (see <clang path>/bin/llc --version) which is great,
 # but compiler-rt is included only for the host architecture. Therefore we need
 # to combine several packages into one, which is the purpose of this script.
-#
-# Usage: get_clang.sh [path]
 
-DEST=${1:-./clang-9.0.1}
+[ "$1" ] || { echo "Usage: get_clang.sh version [path]"; exit 1; }
 
-VER=9.0.1
+VER=${1}
+DEST=${2:-./clang-${VER}}
 X86_64=clang+llvm-${VER}-x86_64-linux-gnu-ubuntu-16.04
 AARCH64=clang+llvm-${VER}-aarch64-linux-gnu
 ARMV7A=clang+llvm-${VER}-armv7a-linux-gnueabihf
diff --git a/toolchain.mk b/toolchain.mk
index b9383bf..15df870 100644
--- a/toolchain.mk
+++ b/toolchain.mk
@@ -40,17 +40,18 @@
 aarch64:
 	$(call dltc,$(AARCH64_PATH),$(SRC_AARCH64_GCC),$(AARCH64_GCC_VERSION))
 
-CLANG_PATH			?= $(ROOT)/clang-9.0.1
+CLANG_VER			?= 9.0.1
+CLANG_PATH			?= $(ROOT)/clang-$(CLANG_VER)
 
 # Download the Clang compiler with LLVM tools and compiler-rt libraries
 define dl-clang
-	@if [ ! -d "$(1)" ]; then \
-		./get_clang.sh $(1); \
+	@if [ ! -d "$(2)" ]; then \
+		./get_clang.sh $(1) $(2); \
 	else \
-		echo "$(1) already exists"; \
+		echo "$(2) already exists"; \
 	fi
 endef
 
 .PHONY: clang-toolchains
 clang-toolchains:
-	$(call dl-clang,$(CLANG_PATH))
+	$(call dl-clang,$(CLANG_VER),$(CLANG_PATH))