summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2020-03-29 00:40:36 +0700
committerGitHub <[email protected]>2020-03-29 00:40:36 +0700
commita582674b910ac0cbb53f84a7cb1f0548be849daa (patch)
tree9849e95a4835d4a2819749cb0e69c1b954a412dc /examples
parent8179c831ae886ad708b45ee4be752a497a03e2b7 (diff)
parentad2824df8bb947c420b0bd4722378eed46981934 (diff)
Merge pull request #312 from hathach/develop
house keeping work
Diffstat (limited to 'examples')
-rw-r--r--examples/make.mk75
1 files changed, 31 insertions, 44 deletions
diff --git a/examples/make.mk b/examples/make.mk
index 25b618896..f2a8b979e 100644
--- a/examples/make.mk
+++ b/examples/make.mk
@@ -1,82 +1,69 @@
-#
+# ---------------------------------------
# Common make definition for all examples
-#
+# ---------------------------------------
-# Compiler
-ifeq ($(BOARD), msp_exp430f5529lp)
- CROSS_COMPILE = msp430-elf-
-else ifeq ($(BOARD), fomu)
- CROSS_COMPILE = riscv-none-embed-
-else
- CROSS_COMPILE = arm-none-eabi-
+#-------------- Select the board to build for. ------------
+BOARD_LIST = $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.))))
+
+ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
+ $(info You must provide a BOARD parameter with 'BOARD=', supported boards are:)
+ $(foreach b,$(BOARD_LIST),$(info - $(b)))
+ $(error Invalid BOARD specified)
endif
-CC = $(CROSS_COMPILE)gcc
-CXX = $(CROSS_COMPILE)g++
-OBJCOPY = $(CROSS_COMPILE)objcopy
-SIZE = $(CROSS_COMPILE)size
-MKDIR = mkdir
-SED = sed
-CP = cp
-RM = rm
-PYTHON ?= python
+# Handy check parameter function
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined make flag: $1$(if $2, ($2))))
-
-
-define newline
-
-
-endef
-
-# Select the board to build for.
-ifeq ($(BOARD),)
- $(info You must provide a BOARD parameter with 'BOARD=')
- $(info Supported boards are:)
- $(info $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/, $(newline)-,$(wildcard $(TOP)/hw/bsp/*/.)))))
- $(error BOARD not defined)
-else
- ifeq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/.),)
- $(error Invalid BOARD specified)
- endif
-endif
-
+
# Build directory
BUILD = _build/build-$(BOARD)
-# Board specific
+# Board specific define
include $(TOP)/hw/bsp/$(BOARD)/board.mk
+#-------------- Cross Compiler ------------
+# Can be set by board, default to ARM GCC
+CROSS_COMPILE ?= arm-none-eabi-
+
+CC = $(CROSS_COMPILE)gcc
+CXX = $(CROSS_COMPILE)g++
+OBJCOPY = $(CROSS_COMPILE)objcopy
+SIZE = $(CROSS_COMPILE)size
+MKDIR = mkdir
+SED = sed
+CP = cp
+RM = rm
+
+#-------------- Source files and compiler flags --------------
+
# Include all source C in board folder
SRC_C += hw/bsp/board.c
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c))
# Compiler Flags
CFLAGS += \
+ -fdata-sections \
+ -ffunction-sections \
-fsingle-precision-constant \
-fno-strict-aliasing \
-Wdouble-promotion \
- -Wno-endif-labels \
-Wstrict-prototypes \
-Wall \
-Wextra \
-Werror \
- -Werror-implicit-function-declaration \
-Wfatal-errors \
+ -Werror-implicit-function-declaration \
-Wfloat-equal \
-Wundef \
-Wshadow \
-Wwrite-strings \
-Wsign-compare \
-Wmissing-format-attribute \
- -Wno-deprecated-declarations \
- -Wunreachable-code \
- -ffunction-sections \
- -fdata-sections
+ -Wunreachable-code
# This causes lots of warning with nrf5x build due to nrfx code
# CFLAGS += -Wcast-align