mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
100 lines
2.5 KiB
Makefile
100 lines
2.5 KiB
Makefile
# ---------------------------------------
|
|
# Common make definition for all examples
|
|
# ---------------------------------------
|
|
|
|
# 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))))
|
|
|
|
#-------------- 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
|
|
|
|
BOARD_PATH = $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/*/boards/$(BOARD)))
|
|
ifeq ($(BOARD_PATH),)
|
|
$(error Invalid BOARD specified)
|
|
endif
|
|
|
|
FAMILY = $(word 3, $(subst /, ,$(BOARD_PATH)))
|
|
FAMILY_PATH = hw/bsp/$(FAMILY)
|
|
|
|
# Build directory
|
|
BUILD = _build/build-$(BOARD)
|
|
|
|
# Include Family and Board specific defs
|
|
include $(TOP)/$(FAMILY_PATH)/family.mk
|
|
-include $(TOP)/$(BOARD_PATH)/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 family & board folder
|
|
SRC_C += hw/bsp/board.c
|
|
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c))
|
|
SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(BOARD_PATH)/*.c))
|
|
|
|
# Compiler Flags
|
|
CFLAGS += \
|
|
-ggdb \
|
|
-fdata-sections \
|
|
-ffunction-sections \
|
|
-fsingle-precision-constant \
|
|
-fno-strict-aliasing \
|
|
-Wdouble-promotion \
|
|
-Wstrict-prototypes \
|
|
-Wall \
|
|
-Wextra \
|
|
-Werror \
|
|
-Wfatal-errors \
|
|
-Werror-implicit-function-declaration \
|
|
-Wfloat-equal \
|
|
-Wundef \
|
|
-Wshadow \
|
|
-Wwrite-strings \
|
|
-Wsign-compare \
|
|
-Wmissing-format-attribute \
|
|
-Wunreachable-code \
|
|
-Wcast-align
|
|
|
|
# Debugging/Optimization
|
|
ifeq ($(DEBUG), 1)
|
|
CFLAGS += -Og
|
|
else
|
|
CFLAGS += -Os
|
|
endif
|
|
|
|
# Log level is mapped to TUSB DEBUG option
|
|
ifneq ($(LOG),)
|
|
CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
|
|
endif
|
|
|
|
# Logger: default is uart, can be set to rtt or swo
|
|
ifeq ($(LOGGER),rtt)
|
|
RTT_SRC = lib/SEGGER_RTT
|
|
CFLAGS += -DLOGGER_RTT -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
|
INC += $(TOP)/$(RTT_SRC)/RTT
|
|
SRC_C += $(RTT_SRC)/RTT/SEGGER_RTT.c
|
|
else ifeq ($(LOGGER),swo)
|
|
CFLAGS += -DLOGGER_SWO
|
|
endif
|