summaryrefslogtreecommitdiff
path: root/examples/make.mk
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-05-01 14:27:17 +0700
committerhathach <[email protected]>2019-05-01 14:27:17 +0700
commit0f3da42db8e4edeccb5825a3329bd5ee3d3eec1d (patch)
tree87ef8174e44ab9369d8b79d4bd055a6e4f0ea0c2 /examples/make.mk
parent4d29decafcdd0dac2e71c6adf3be5a34200706d8 (diff)
add make.mk and rules.mk to help new makefile example
Diffstat (limited to 'examples/make.mk')
-rw-r--r--examples/make.mk65
1 files changed, 65 insertions, 0 deletions
diff --git a/examples/make.mk b/examples/make.mk
new file mode 100644
index 000000000..d76f611fb
--- /dev/null
+++ b/examples/make.mk
@@ -0,0 +1,65 @@
+#
+# Common make definition for all examples
+#
+
+# Compiler
+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
+
+# Select the board to build for.
+ifeq ($(BOARD),)
+ $(info You must provide a BOARD parameter with 'BOARD=')
+ $(info Possible values are:)
+ $(info $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(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-$(BOARD)
+
+# Board specific
+include $(TOP)/hw/bsp/$(BOARD)/board.mk
+
+# Compiler Flags
+CFLAGS += \
+ -fsingle-precision-constant \
+ -fno-strict-aliasing \
+ -Wdouble-promotion \
+ -Wno-endif-labels \
+ -Wstrict-prototypes \
+ -Wall \
+ -Werror \
+ -Werror-implicit-function-declaration \
+ -Wfloat-equal \
+ -Wundef \
+ -Wshadow \
+ -Wwrite-strings \
+ -Wsign-compare \
+ -Wmissing-format-attribute \
+ -Wno-deprecated-declarations \
+ -Wnested-externs \
+ -Wunreachable-code \
+ -Wno-error=lto-type-mismatch \
+ -ffunction-sections \
+ -fdata-sections
+
+# This causes lots of warning with nrf5x build due to nrfx code
+# CFLAGS += -Wcast-align
+
+# Debugging/Optimization
+ifeq ($(DEBUG), 1)
+ CFLAGS += -O0 -ggdb
+else
+ CFLAGS += -flto -Os
+endif