2022-10-28 00:56:31 +02:00
|
|
|
# ---------------------------------------
|
|
|
|
# Common make definition for all examples
|
|
|
|
# ---------------------------------------
|
|
|
|
|
|
|
|
# Build directory
|
|
|
|
BUILD := _build
|
|
|
|
PROJECT := $(notdir $(CURDIR))
|
|
|
|
|
|
|
|
# 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))))
|
|
|
|
|
|
|
|
#-------------- Fuzz harness compiler ------------
|
|
|
|
|
2022-12-28 21:37:12 +01:00
|
|
|
CC ?= clang
|
|
|
|
CXX ?= clang++
|
|
|
|
GDB ?= gdb
|
2022-10-28 00:56:31 +02:00
|
|
|
OBJCOPY = objcopy
|
|
|
|
SIZE = size
|
|
|
|
MKDIR = mkdir
|
|
|
|
|
|
|
|
ifeq ($(CMDEXE),1)
|
|
|
|
CP = copy
|
|
|
|
RM = del
|
|
|
|
PYTHON = python
|
|
|
|
else
|
|
|
|
SED = sed
|
|
|
|
CP = cp
|
|
|
|
RM = rm
|
|
|
|
PYTHON = python3
|
|
|
|
endif
|
|
|
|
|
2022-12-28 21:37:12 +01:00
|
|
|
#-------------- Fuzz harness flags ------------
|
|
|
|
COVERAGE_FLAGS ?= -fsanitize-coverage=trace-pc-guard
|
|
|
|
SANITIZER_FLAGS ?= -fsanitize=fuzzer \
|
|
|
|
-fsanitize=address
|
|
|
|
|
|
|
|
CFLAGS += $(COVERAGE_FLAGS) $(SANITIZER_FLAGS)
|
|
|
|
|
2022-10-28 00:56:31 +02:00
|
|
|
#-------------- Source files and compiler flags --------------
|
|
|
|
|
|
|
|
|
2022-12-08 04:39:54 +01:00
|
|
|
INC += $(TOP)/test
|
2022-10-28 00:56:31 +02:00
|
|
|
|
|
|
|
# Compiler Flags
|
|
|
|
CFLAGS += \
|
|
|
|
-ggdb \
|
|
|
|
-fdata-sections \
|
|
|
|
-ffunction-sections \
|
|
|
|
-fno-strict-aliasing \
|
|
|
|
-Wall \
|
|
|
|
-Wextra \
|
|
|
|
-Werror \
|
|
|
|
-Wfatal-errors \
|
|
|
|
-Wdouble-promotion \
|
|
|
|
-Wstrict-prototypes \
|
|
|
|
-Wstrict-overflow \
|
|
|
|
-Werror-implicit-function-declaration \
|
|
|
|
-Wfloat-equal \
|
|
|
|
-Wundef \
|
|
|
|
-Wshadow \
|
|
|
|
-Wwrite-strings \
|
|
|
|
-Wsign-compare \
|
|
|
|
-Wmissing-format-attribute \
|
|
|
|
-Wunreachable-code \
|
|
|
|
-Wcast-align \
|
|
|
|
-Wcast-qual \
|
|
|
|
-Wnull-dereference \
|
|
|
|
-Wuninitialized \
|
|
|
|
-Wunused \
|
2022-11-16 03:24:59 +01:00
|
|
|
-Wredundant-decls \
|
|
|
|
-O1
|
2022-10-28 00:56:31 +02:00
|
|
|
|
|
|
|
CFLAGS += \
|
2022-12-08 04:30:22 +01:00
|
|
|
-Wno-error=unreachable-code \
|
2022-10-28 00:56:31 +02:00
|
|
|
-DOPT_MCU_FUZZ=1 \
|
2023-01-21 00:40:32 +01:00
|
|
|
-DCFG_TUSB_MCU=OPT_MCU_FUZZ \
|
2023-02-22 05:47:09 +01:00
|
|
|
-D_FUZZ
|
2022-10-28 00:56:31 +02:00
|
|
|
|
|
|
|
CXXFLAGS += \
|
|
|
|
-xc++ \
|
|
|
|
-Wno-c++11-narrowing \
|
|
|
|
-fno-implicit-templates
|
|
|
|
|
|
|
|
# conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion
|
|
|
|
# -Wconversion
|
|
|
|
|
|
|
|
# Debugging/Optimization
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CFLAGS += -Og
|
|
|
|
else
|
|
|
|
CFLAGS += $(CFLAGS_OPTIMIZED)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Log level is mapped to TUSB DEBUG option
|
|
|
|
ifneq ($(LOG),)
|
|
|
|
CMAKE_DEFSYM += -DLOG=$(LOG)
|
|
|
|
CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Logger: default is uart, can be set to rtt or swo
|
|
|
|
ifneq ($(LOGGER),)
|
|
|
|
CMAKE_DEFSYM += -DLOGGER=$(LOGGER)
|
|
|
|
endif
|
|
|
|
|