make.mk 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. -fdata-sections \
  40. -ffunction-sections \
  41. -fsingle-precision-constant \
  42. -fno-strict-aliasing \
  43. -Wdouble-promotion \
  44. -Wstrict-prototypes \
  45. -Wall \
  46. -Wextra \
  47. -Werror \
  48. -Wfatal-errors \
  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. # This causes lots of warning with nrf5x build due to nrfx code
  58. # CFLAGS += -Wcast-align
  59. # Debugging/Optimization
  60. ifeq ($(DEBUG), 1)
  61. CFLAGS += -Og -ggdb
  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
  70. ifeq ($(LOGGER),rtt)
  71. RTT_SRC = lib/SEGGER_RTT
  72. CFLAGS += -DLOGGER_RTT
  73. INC += $(TOP)/$(RTT_SRC)/RTT
  74. SRC_C += $(RTT_SRC)/RTT/SEGGER_RTT_printf.c
  75. SRC_C += $(RTT_SRC)/RTT/SEGGER_RTT.c
  76. endif