diff --git a/Makefile.include b/Makefile.include index c1439114a56821f6aa415fb2bc369f9395da00e5..4decf6ed66282922a639b3027c56fc8fa5d457aa 100644 --- a/Makefile.include +++ b/Makefile.include @@ -136,6 +136,32 @@ ifneq (0,$(shell test -d $(RIOTBOARD)/$(BOARD); echo $$?)) $(error The specified board $(BOARD) does not exist.) endif +# Use TOOLCHAIN environment variable to select the toolchain to use. +# Default: gnu +TOOLCHAIN ?= gnu + +# TOOLCHAIN = clang is an alias for TOOLCHAIN = llvm +ifeq (clang,$(TOOLCHAIN)) +# use override so that we can redefine a variable set on the command line (as +# opposed to one set in the environment) +override TOOLCHAIN := llvm +endif +# TOOLCHAIN = gcc is an alias for TOOLCHAIN = gnu +ifeq (gcc,$(TOOLCHAIN)) +# use override so that we can redefine a variable set on the command line (as +# opposed to one set in the environment) +override TOOLCHAIN := gnu +endif + +ifeq (,$(TOOLCHAIN)) +override TOOLCHAIN := gnu +endif + +export TOOLCHAIN + +# Import all toolchain settings +include $(RIOTCPU)/Makefile.include.$(TOOLCHAIN) + # mandatory includes! include $(RIOTBASE)/Makefile.modules include $(RIOTBOARD)/$(BOARD)/Makefile.include diff --git a/cpu/Makefile.include.cortexm_common b/cpu/Makefile.include.cortexm_common index 726d82c0b3689488827c87680ec59c3c25cadebb..2c3f941c50433ee074b2c3611e72c67d68e4d88f 100644 --- a/cpu/Makefile.include.cortexm_common +++ b/cpu/Makefile.include.cortexm_common @@ -1,29 +1,6 @@ # Target triple for the build. Use arm-none-eabi if you are unsure. export TARGET_TRIPLE ?= arm-none-eabi -# Use TOOLCHAIN environment variable to select the toolchain to use. -# Default: gnu -TOOLCHAIN ?= gnu - -# TOOLCHAIN = clang is an alias for TOOLCHAIN = llvm -ifeq (clang,$(TOOLCHAIN)) -# use override so that we can redefine a variable set on the command line (as -# opposed to one set in the environment) -override TOOLCHAIN := llvm -endif -# TOOLCHAIN = gcc is an alias for TOOLCHAIN = gnu -ifeq (gcc,$(TOOLCHAIN)) -# use override so that we can redefine a variable set on the command line (as -# opposed to one set in the environment) -override TOOLCHAIN := gnu -endif - -ifeq (,$(TOOLCHAIN)) -override TOOLCHAIN := gnu -endif - -export TOOLCHAIN - # default toolchain prefix, defaults to target triple followed by a dash, you # will most likely not need to touch this. export PREFIX ?= $(if $(TARGET_TRIPLE),$(TARGET_TRIPLE)-) @@ -116,9 +93,6 @@ endif # CPU depends on the cortex-m common module, so include it: include $(RIOTCPU)/cortexm_common/Makefile.include -# Import all toolchain settings -include $(RIOTCPU)/Makefile.include.$(TOOLCHAIN) - # use the nano-specs of Newlib when available ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) export LINKFLAGS += -specs=nano.specs -lc -lnosys