make.mk 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # ---------------------------------------
  2. # Common make definition for all examples
  3. # ---------------------------------------
  4. #-------------- Select the board to build for. ------------
  5. BOARD_LIST = $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.))))
  6. ifeq ($(filter $(BOARD),$(BOARD_LIST)),)
  7. $(info You must provide a BOARD parameter with 'BOARD=', supported boards are:)
  8. $(foreach b,$(BOARD_LIST),$(info - $(b)))
  9. $(error Invalid BOARD specified)
  10. endif
  11. # Handy check parameter function
  12. check_defined = \
  13. $(strip $(foreach 1,$1, \
  14. $(call __check_defined,$1,$(strip $(value 2)))))
  15. __check_defined = \
  16. $(if $(value $1),, \
  17. $(error Undefined make flag: $1$(if $2, ($2))))
  18. # Build directory
  19. BUILD = _build/build-$(BOARD)
  20. # Board specific define
  21. include $(TOP)/hw/bsp/$(BOARD)/board.mk
  22. #-------------- Cross Compiler ------------
  23. # Can be set by board, default to ARM GCC
  24. CROSS_COMPILE ?= arm-none-eabi-
  25. CC = $(CROSS_COMPILE)gcc
  26. CXX = $(CROSS_COMPILE)g++
  27. OBJCOPY = $(CROSS_COMPILE)objcopy
  28. SIZE = $(CROSS_COMPILE)size
  29. MKDIR = mkdir
  30. SED = sed
  31. CP = cp
  32. RM = rm
  33. #-------------- Source files and compiler flags --------------
  34. # Include all source C in board folder
  35. SRC_C += hw/bsp/board.c
  36. SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c))
  37. # Compiler Flags
  38. CFLAGS += \
  39. -ggdb \
  40. -fdata-sections \
  41. -ffunction-sections \
  42. -fsingle-precision-constant \
  43. -fno-strict-aliasing \
  44. -Wdouble-promotion \
  45. -Wstrict-prototypes \
  46. -Wall \
  47. -Wextra \
  48. -Werror \
  49. -Wfatal-errors \
  50. -Werror-implicit-function-declaration \
  51. -Wfloat-equal \
  52. -Wundef \
  53. -Wshadow \
  54. -Wwrite-strings \
  55. -Wsign-compare \
  56. -Wmissing-format-attribute \
  57. -Wunreachable-code \
  58. -Wcast-align
  59. # Debugging/Optimization
  60. ifeq ($(DEBUG), 1)
  61. CFLAGS += -Og
  62. else
  63. CFLAGS += -Os
  64. endif
  65. # Log level is mapped to TUSB DEBUG option
  66. ifneq ($(LOG),)
  67. CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
  68. endif
  69. # Logger: default is uart, can be set to rtt or swo
  70. ifeq ($(LOGGER),rtt)
  71. RTT_SRC = lib/SEGGER_RTT
  72. CFLAGS += -DLOGGER_RTT -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
  73. INC += $(TOP)/$(RTT_SRC)/RTT
  74. SRC_C += $(RTT_SRC)/RTT/SEGGER_RTT.c
  75. else ifeq ($(LOGGER),swo)
  76. CFLAGS += -DLOGGER_SWO
  77. endif