From 8beba5645bbb6d216c21b769fe4eb8b1ef206ccd Mon Sep 17 00:00:00 2001
From: Kaspar Schleiser <kaspar@schleiser.de>
Date: Wed, 22 Apr 2015 15:41:37 +0200
Subject: [PATCH] make: board: initial commit of generic board Makefiles

---
 boards/Makefile.include.cortex_common | 38 +++++++++++++++++++++++++++
 boards/Makefile.include.gnu           |  8 ++++++
 boards/Makefile.include.openocd       |  4 +++
 boards/Makefile.include.serial        | 17 ++++++++++++
 4 files changed, 67 insertions(+)
 create mode 100644 boards/Makefile.include.cortex_common
 create mode 100644 boards/Makefile.include.gnu
 create mode 100644 boards/Makefile.include.openocd
 create mode 100644 boards/Makefile.include.serial

diff --git a/boards/Makefile.include.cortex_common b/boards/Makefile.include.cortex_common
new file mode 100644
index 0000000000..93965c98e8
--- /dev/null
+++ b/boards/Makefile.include.cortex_common
@@ -0,0 +1,38 @@
+# we build all cortex boards with the GNU toolchain
+export PREFIX = arm-none-eabi-
+include $(RIOTBOARD)/Makefile.include.gnu
+
+# use cortex name of CPU folder, but enable board Makefile to override
+export MCPU ?= $(CORTEX)
+
+#
+# CPU model specifics
+ifeq ($(CORTEX),cortex-m4)
+CFLAGS_FPU += -mfloat-abi=hard -mfpu=fpv4-sp-d16
+endif
+
+# define build specific options
+export CFLAGS_CPU   = -mcpu=$(MCPU) -mlittle-endian -mthumb -mno-thumb-interwork $(CFLAGS_FPU)
+export CFLAGS_STYLE = -std=gnu99 -Wall -Wstrict-prototypes
+export CFLAGS_LINK  = -ffunction-sections -fdata-sections -fno-builtin
+export CFLAGS_DBG   = -ggdb -g3
+export CFLAGS_OPT   ?= -Os
+export CFLAGS += $(CFLAGS_CPU) $(CFLAGS_STYLE) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
+
+export ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DEBUG)
+export LINKFLAGS += -L$(RIOTCPU)/$(CPU)
+export LINKFLAGS += $(CFLAGS_DEBUG) $(CFLAGS_CPU) $(CFLAGS_STYLE) -static -lgcc -nostartfiles -T$(LINKERSCRIPT)
+
+export OFLAGS ?= -O ihex
+export FFLAGS ?= flash
+export DEBUGGER_FLAGS ?= debug
+export DEBUGSERVER_FLAGS ?= debug-server
+export RESET_FLAGS ?= reset
+
+# use the nano-specs of the 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
+endif
+
+# export board specific includes to the global includes-listing
+export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include
diff --git a/boards/Makefile.include.gnu b/boards/Makefile.include.gnu
new file mode 100644
index 0000000000..f514bf1d70
--- /dev/null
+++ b/boards/Makefile.include.gnu
@@ -0,0 +1,8 @@
+export CC = $(PREFIX)gcc
+export CXX = $(PREFIX)g++
+export AR = $(PREFIX)ar
+export AS = $(PREFIX)as
+export LINK = $(PREFIX)gcc
+export SIZE = $(PREFIX)size
+export OBJCOPY = $(PREFIX)objcopy
+export DBG = $(PREFIX)gdb
diff --git a/boards/Makefile.include.openocd b/boards/Makefile.include.openocd
new file mode 100644
index 0000000000..390f3462b0
--- /dev/null
+++ b/boards/Makefile.include.openocd
@@ -0,0 +1,4 @@
+export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
+export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
+export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
+export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
diff --git a/boards/Makefile.include.serial b/boards/Makefile.include.serial
new file mode 100644
index 0000000000..236872e9ab
--- /dev/null
+++ b/boards/Makefile.include.serial
@@ -0,0 +1,17 @@
+# set default port depending on operating system
+OS := $(shell uname)
+ifeq ($(OS),Linux)
+  PORT ?= $(PORT_LINUX)
+else ifeq ($(OS),Darwin)
+  PORT ?= $(PORT_DARWIN)
+endif
+
+ifeq ($(PORT),)
+    $(info Warning: no PORT set!)
+endif
+
+export BAUD ?= 115200
+export TERMFLAGS += -p "$(PORT)" -b "$(BAUD)"
+export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
+
+export PORT
-- 
GitLab