2019-05-01 14:27:17 +07:00
|
|
|
#
|
|
|
|
# Common make definition for all examples
|
|
|
|
#
|
|
|
|
|
2019-11-13 09:26:00 -08:00
|
|
|
# Compiler
|
|
|
|
ifeq ($(BOARD), fomu)
|
|
|
|
CROSS_COMPILE = riscv-none-embed-
|
|
|
|
else
|
2019-05-01 14:27:17 +07:00
|
|
|
CROSS_COMPILE = arm-none-eabi-
|
2019-11-13 09:26:00 -08:00
|
|
|
endif
|
2019-05-01 14:27:17 +07:00
|
|
|
CC = $(CROSS_COMPILE)gcc
|
|
|
|
CXX = $(CROSS_COMPILE)g++
|
|
|
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
|
|
|
SIZE = $(CROSS_COMPILE)size
|
|
|
|
MKDIR = mkdir
|
|
|
|
SED = sed
|
|
|
|
CP = cp
|
|
|
|
RM = rm
|
2019-05-20 12:35:33 +07:00
|
|
|
PYTHON ?= python
|
2019-05-01 14:27:17 +07:00
|
|
|
|
2019-05-29 16:56:26 +07:00
|
|
|
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))))
|
|
|
|
|
2019-09-03 13:25:36 +07:00
|
|
|
|
|
|
|
define newline
|
|
|
|
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
2019-05-01 14:27:17 +07:00
|
|
|
# Select the board to build for.
|
|
|
|
ifeq ($(BOARD),)
|
|
|
|
$(info You must provide a BOARD parameter with 'BOARD=')
|
2019-09-03 13:25:36 +07:00
|
|
|
$(info Supported boards are:)
|
|
|
|
$(info $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/, $(newline)-,$(wildcard $(TOP)/hw/bsp/*/.)))))
|
2019-05-01 14:27:17 +07:00
|
|
|
$(error BOARD not defined)
|
|
|
|
else
|
|
|
|
ifeq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/.),)
|
|
|
|
$(error Invalid BOARD specified)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Build directory
|
2019-05-24 12:04:47 +07:00
|
|
|
BUILD = _build/build-$(BOARD)
|
2019-05-01 14:27:17 +07:00
|
|
|
|
|
|
|
# Board specific
|
|
|
|
include $(TOP)/hw/bsp/$(BOARD)/board.mk
|
|
|
|
|
2019-05-14 13:59:45 +07:00
|
|
|
# Include all source C in board folder
|
2019-10-12 00:00:08 +07:00
|
|
|
SRC_C += hw/bsp/board.c
|
2019-05-14 13:59:45 +07:00
|
|
|
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c))
|
|
|
|
|
2019-05-01 14:27:17 +07:00
|
|
|
# Compiler Flags
|
|
|
|
CFLAGS += \
|
|
|
|
-fsingle-precision-constant \
|
|
|
|
-fno-strict-aliasing \
|
|
|
|
-Wdouble-promotion \
|
|
|
|
-Wno-endif-labels \
|
|
|
|
-Wstrict-prototypes \
|
|
|
|
-Wall \
|
2019-09-27 00:15:43 +07:00
|
|
|
-Wextra \
|
2019-05-01 14:27:17 +07:00
|
|
|
-Werror \
|
|
|
|
-Werror-implicit-function-declaration \
|
2019-09-20 13:49:33 +07:00
|
|
|
-Wfatal-errors \
|
2019-05-01 14:27:17 +07:00
|
|
|
-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)
|
2019-11-03 13:18:02 +07:00
|
|
|
CFLAGS += -Og -ggdb
|
2019-05-01 14:27:17 +07:00
|
|
|
else
|
2019-11-20 16:06:40 +07:00
|
|
|
CFLAGS += -Os
|
2019-10-03 14:22:43 +02:00
|
|
|
endif
|
2019-11-03 13:18:02 +07:00
|
|
|
|
|
|
|
# TUSB Logging option
|
|
|
|
ifneq ($(LOG),)
|
|
|
|
CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
|
2019-05-01 14:27:17 +07:00
|
|
|
endif
|