make.mk 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. ifeq ($(CMDEXE),1)
  31. CP = copy
  32. RM = del
  33. else
  34. SED = sed
  35. CP = cp
  36. RM = rm
  37. endif
  38. #-------------- Source files and compiler flags --------------
  39. # Include all source C in board folder
  40. SRC_C += hw/bsp/board.c
  41. SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c))
  42. # Compiler Flags
  43. CFLAGS += \
  44. -ggdb \
  45. -fdata-sections \
  46. -ffunction-sections \
  47. -fsingle-precision-constant \
  48. -fno-strict-aliasing \
  49. -Wdouble-promotion \
  50. -Wstrict-prototypes \
  51. -Wall \
  52. -Wextra \
  53. -Werror \
  54. -Wfatal-errors \
  55. -Werror-implicit-function-declaration \
  56. -Wfloat-equal \
  57. -Wundef \
  58. -Wshadow \
  59. -Wwrite-strings \
  60. -Wsign-compare \
  61. -Wmissing-format-attribute \
  62. -Wunreachable-code \
  63. -Wcast-align
  64. # Debugging/Optimization
  65. ifeq ($(DEBUG), 1)
  66. CFLAGS += -Og
  67. else
  68. CFLAGS += -Os
  69. endif
  70. # Log level is mapped to TUSB DEBUG option
  71. ifneq ($(LOG),)
  72. CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
  73. endif
  74. # Logger: default is uart, can be set to rtt or swo
  75. ifeq ($(LOGGER),rtt)
  76. RTT_SRC = lib/SEGGER_RTT
  77. CFLAGS += -DLOGGER_RTT -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
  78. INC += $(TOP)/$(RTT_SRC)/RTT
  79. SRC_C += $(RTT_SRC)/RTT/SEGGER_RTT.c
  80. else ifeq ($(LOGGER),swo)
  81. CFLAGS += -DLOGGER_SWO
  82. endif