espressif_tinyusb/examples/make.mk

82 lines
1.9 KiB
Makefile
Raw Normal View History

# ---------------------------------------
# Common make definition for all examples
# ---------------------------------------
#-------------- 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
# 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))))
# Build directory
2019-05-24 07:04:47 +02:00
BUILD = _build/build-$(BOARD)
# 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 --------------
2019-05-14 08:59:45 +02:00
# Include all source C in board folder
SRC_C += hw/bsp/board.c
2019-05-14 08:59:45 +02:00
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c))
# Compiler Flags
CFLAGS += \
2020-03-26 16:04:24 +01:00
-fdata-sections \
-ffunction-sections \
-fsingle-precision-constant \
-fno-strict-aliasing \
-Wdouble-promotion \
-Wstrict-prototypes \
-Wall \
-Wextra \
-Werror \
2019-09-20 08:49:33 +02:00
-Wfatal-errors \
2020-03-26 16:04:24 +01:00
-Werror-implicit-function-declaration \
-Wfloat-equal \
-Wundef \
-Wshadow \
-Wwrite-strings \
-Wsign-compare \
-Wmissing-format-attribute \
2020-03-26 16:04:24 +01:00
-Wunreachable-code
# This causes lots of warning with nrf5x build due to nrfx code
# CFLAGS += -Wcast-align
# Debugging/Optimization
ifeq ($(DEBUG), 1)
2019-11-03 07:18:02 +01:00
CFLAGS += -Og -ggdb
else
CFLAGS += -Os
2019-10-03 14:22:43 +02:00
endif
2019-11-03 07:18:02 +01:00
# TUSB Logging option
ifneq ($(LOG),)
CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
endif