make.mk 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. #-------------- Source files and compiler flags --------------
  32. INC += $(TOP)/test
  33. # Compiler Flags
  34. CFLAGS += \
  35. -ggdb \
  36. -fsanitize=fuzzer \
  37. -fsanitize=address \
  38. -fsanitize=undefined \
  39. -fdata-sections \
  40. -ffunction-sections \
  41. -fno-strict-aliasing \
  42. -Wall \
  43. -Wextra \
  44. -Werror \
  45. -Wfatal-errors \
  46. -Wdouble-promotion \
  47. -Wstrict-prototypes \
  48. -Wstrict-overflow \
  49. -Werror-implicit-function-declaration \
  50. -Wfloat-equal \
  51. -Wundef \
  52. -Wshadow \
  53. -Wwrite-strings \
  54. -Wsign-compare \
  55. -Wmissing-format-attribute \
  56. -Wunreachable-code \
  57. -Wcast-align \
  58. -Wcast-qual \
  59. -Wnull-dereference \
  60. -Wuninitialized \
  61. -Wunused \
  62. -Wredundant-decls \
  63. -O1
  64. CFLAGS += \
  65. -Wno-error=unreachable-code \
  66. -DOPT_MCU_FUZZ=1 \
  67. -DCFG_TUSB_MCU=OPT_MCU_FUZZ
  68. CXXFLAGS += \
  69. -xc++ \
  70. -Wno-c++11-narrowing \
  71. -fno-implicit-templates
  72. # conversion is too strict for most mcu driver, may be disable sign/int/arith-conversion
  73. # -Wconversion
  74. # Debugging/Optimization
  75. ifeq ($(DEBUG), 1)
  76. CFLAGS += -Og
  77. else
  78. CFLAGS += $(CFLAGS_OPTIMIZED)
  79. endif
  80. # Log level is mapped to TUSB DEBUG option
  81. ifneq ($(LOG),)
  82. CMAKE_DEFSYM += -DLOG=$(LOG)
  83. CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
  84. endif
  85. # Logger: default is uart, can be set to rtt or swo
  86. ifneq ($(LOGGER),)
  87. CMAKE_DEFSYM += -DLOGGER=$(LOGGER)
  88. endif