make.mk 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # ---------------------------------------
  2. # Common make definition for all examples
  3. # ---------------------------------------
  4. # Build directory
  5. BUILD := _build
  6. PROJECT := $(notdir $(CURDIR))
  7. # Handy check parameter function
  8. check_defined = \
  9. $(strip $(foreach 1,$1, \
  10. $(call __check_defined,$1,$(strip $(value 2)))))
  11. __check_defined = \
  12. $(if $(value $1),, \
  13. $(error Undefined make flag: $1$(if $2, ($2))))
  14. #-------------- Fuzz harness compiler ------------
  15. CC ?= clang
  16. CXX ?= clang++
  17. GDB ?= gdb
  18. OBJCOPY = objcopy
  19. SIZE = size
  20. MKDIR = mkdir
  21. ifeq ($(CMDEXE),1)
  22. CP = copy
  23. RM = del
  24. PYTHON = python
  25. else
  26. SED = sed
  27. CP = cp
  28. RM = rm
  29. PYTHON = python3
  30. endif
  31. #-------------- Fuzz harness flags ------------
  32. COVERAGE_FLAGS ?= -fsanitize-coverage=trace-pc-guard
  33. SANITIZER_FLAGS ?= -fsanitize=fuzzer \
  34. -fsanitize=address
  35. CFLAGS += $(COVERAGE_FLAGS) $(SANITIZER_FLAGS)
  36. #-------------- Source files and compiler flags --------------
  37. INC += $(TOP)/test
  38. # Compiler Flags
  39. CFLAGS += \
  40. -ggdb \
  41. -fdata-sections \
  42. -ffunction-sections \
  43. -fno-strict-aliasing \
  44. -Wall \
  45. -Wextra \
  46. -Werror \
  47. -Wfatal-errors \
  48. -Wdouble-promotion \
  49. -Wstrict-prototypes \
  50. -Wstrict-overflow \
  51. -Werror-implicit-function-declaration \
  52. -Wfloat-equal \
  53. -Wundef \
  54. -Wshadow \
  55. -Wwrite-strings \
  56. -Wsign-compare \
  57. -Wmissing-format-attribute \
  58. -Wunreachable-code \
  59. -Wcast-align \
  60. -Wcast-qual \
  61. -Wnull-dereference \
  62. -Wuninitialized \
  63. -Wunused \
  64. -Wredundant-decls \
  65. -O1
  66. CFLAGS += \
  67. -Wno-error=unreachable-code \
  68. -DOPT_MCU_FUZZ=1 \
  69. -DCFG_TUSB_MCU=OPT_MCU_FUZZ
  70. CXXFLAGS += \
  71. -xc++ \
  72. -Wno-c++11-narrowing \
  73. -fno-implicit-templates
  74. # conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion
  75. # -Wconversion
  76. # Debugging/Optimization
  77. ifeq ($(DEBUG), 1)
  78. CFLAGS += -Og
  79. else
  80. CFLAGS += $(CFLAGS_OPTIMIZED)
  81. endif
  82. # Log level is mapped to TUSB DEBUG option
  83. ifneq ($(LOG),)
  84. CMAKE_DEFSYM += -DLOG=$(LOG)
  85. CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
  86. endif
  87. # Logger: default is uart, can be set to rtt or swo
  88. ifneq ($(LOGGER),)
  89. CMAKE_DEFSYM += -DLOGGER=$(LOGGER)
  90. endif