summaryrefslogtreecommitdiff
path: root/examples/build_system/make/make.mk
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-04-24 19:21:26 +0700
committerhathach <[email protected]>2024-04-24 19:21:26 +0700
commita7bf0e3e7f7799c28e370826710810033c117744 (patch)
tree1ac7cb708010473050ceeab0f6ff6c7750eaa6d1 /examples/build_system/make/make.mk
parent366f1cf1863bad626af10347f8ff3d0ef7f6ea2b (diff)
clang make work for samd21
Diffstat (limited to 'examples/build_system/make/make.mk')
-rw-r--r--examples/build_system/make/make.mk28
1 files changed, 21 insertions, 7 deletions
diff --git a/examples/build_system/make/make.mk b/examples/build_system/make/make.mk
index 2437b8766..1ec42cb50 100644
--- a/examples/build_system/make/make.mk
+++ b/examples/build_system/make/make.mk
@@ -2,6 +2,26 @@
# Common make definition for all examples
# ---------------------------------------
+#-------------------------------------------------------------
+# Toolchain
+# Can be changed via TOOLCHAIN=gcc|iar or CC=arm-none-eabi-gcc|iccarm|clang
+#-------------------------------------------------------------
+
+ifneq (,$(findstring clang,$(CC)))
+ TOOLCHAIN = clang
+else ifneq (,$(findstring iccarm,$(CC)))
+ TOOLCHAIN = iar
+else ifneq (,$(findstring gcc,$(CC)))
+ TOOLCHAIN = gcc
+endif
+
+# Default to GCC
+ifndef TOOLCHAIN
+ TOOLCHAIN = gcc
+endif
+
+$(info TOOLCHAIN: $(TOOLCHAIN))
+
#-------------- TOP and CURRENT_PATH ------------
# Set TOP to be the path to get from the current directory (where make was invoked) to the top of the tree.
@@ -75,12 +95,6 @@ else
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c))
endif
-#-------------------------------------------------------------
-# Toolchain
-# Can be changed via TOOLCHAIN=gcc|iar or CC=arm-none-eabi-gcc|iccarm|clang
-#-------------------------------------------------------------
-TOOLCHAIN ?= gcc
-
#-------------- Source files and compiler flags --------------
# tinyusb makefile
include $(TOP)/src/tinyusb.mk
@@ -112,7 +126,7 @@ endif
# Logger: default is uart, can be set to rtt or swo
ifneq ($(LOGGER),)
- CMAKE_DEFSYM += -DLOGGER=$(LOGGER)
+ CMAKE_DEFSYM += -DLOGGER=$(LOGGER)
endif
ifeq ($(LOGGER),rtt)