make.mk 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #
  2. # Common make definition for all examples
  3. #
  4. # Compiler
  5. ifeq ($(BOARD), msp_exp430f5529lp)
  6. CROSS_COMPILE = msp430-elf-
  7. else ifeq ($(BOARD), fomu)
  8. CROSS_COMPILE = riscv-none-embed-
  9. else
  10. CROSS_COMPILE = arm-none-eabi-
  11. endif
  12. CC = $(CROSS_COMPILE)gcc
  13. CXX = $(CROSS_COMPILE)g++
  14. OBJCOPY = $(CROSS_COMPILE)objcopy
  15. SIZE = $(CROSS_COMPILE)size
  16. MKDIR = mkdir
  17. SED = sed
  18. CP = cp
  19. RM = rm
  20. PYTHON ?= python
  21. check_defined = \
  22. $(strip $(foreach 1,$1, \
  23. $(call __check_defined,$1,$(strip $(value 2)))))
  24. __check_defined = \
  25. $(if $(value $1),, \
  26. $(error Undefined make flag: $1$(if $2, ($2))))
  27. define newline
  28. endef
  29. # Select the board to build for.
  30. ifeq ($(BOARD),)
  31. $(info You must provide a BOARD parameter with 'BOARD=')
  32. $(info Supported boards are:)
  33. $(info $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/, $(newline)-,$(wildcard $(TOP)/hw/bsp/*/.)))))
  34. $(error BOARD not defined)
  35. else
  36. ifeq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/.),)
  37. $(error Invalid BOARD specified)
  38. endif
  39. endif
  40. # Build directory
  41. BUILD = _build/build-$(BOARD)
  42. # Board specific
  43. include $(TOP)/hw/bsp/$(BOARD)/board.mk
  44. # Include all source C in board folder
  45. SRC_C += hw/bsp/board.c
  46. SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c))
  47. # Compiler Flags
  48. CFLAGS += \
  49. -fsingle-precision-constant \
  50. -fno-strict-aliasing \
  51. -Wdouble-promotion \
  52. -Wno-endif-labels \
  53. -Wstrict-prototypes \
  54. -Wall \
  55. -Wextra \
  56. -Werror \
  57. -Werror-implicit-function-declaration \
  58. -Wfatal-errors \
  59. -Wfloat-equal \
  60. -Wundef \
  61. -Wshadow \
  62. -Wwrite-strings \
  63. -Wsign-compare \
  64. -Wmissing-format-attribute \
  65. -Wno-deprecated-declarations \
  66. -Wunreachable-code \
  67. -ffunction-sections \
  68. -fdata-sections
  69. # This causes lots of warning with nrf5x build due to nrfx code
  70. # CFLAGS += -Wcast-align
  71. # Debugging/Optimization
  72. ifeq ($(DEBUG), 1)
  73. CFLAGS += -Og -ggdb
  74. else
  75. CFLAGS += -Os
  76. endif
  77. # TUSB Logging option
  78. ifneq ($(LOG),)
  79. CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
  80. endif