make.mk 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. -fsingle-precision-constant \
  40. -fno-strict-aliasing \
  41. -Wdouble-promotion \
  42. -Wno-endif-labels \
  43. -Wstrict-prototypes \
  44. -Wall \
  45. -Wextra \
  46. -Werror \
  47. -Werror-implicit-function-declaration \
  48. -Wfatal-errors \
  49. -Wfloat-equal \
  50. -Wundef \
  51. -Wshadow \
  52. -Wwrite-strings \
  53. -Wsign-compare \
  54. -Wmissing-format-attribute \
  55. -Wno-deprecated-declarations \
  56. -Wunreachable-code \
  57. -ffunction-sections \
  58. -fdata-sections
  59. # This causes lots of warning with nrf5x build due to nrfx code
  60. # CFLAGS += -Wcast-align
  61. # Debugging/Optimization
  62. ifeq ($(DEBUG), 1)
  63. CFLAGS += -Og -ggdb
  64. else
  65. CFLAGS += -Os
  66. endif
  67. # TUSB Logging option
  68. ifneq ($(LOG),)
  69. CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
  70. endif