make.mk 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. -Wnested-externs \
  67. -Wunreachable-code \
  68. -Wno-error=lto-type-mismatch \
  69. -ffunction-sections \
  70. -fdata-sections
  71. # This causes lots of warning with nrf5x build due to nrfx code
  72. # CFLAGS += -Wcast-align
  73. # Debugging/Optimization
  74. ifeq ($(DEBUG), 1)
  75. CFLAGS += -Og -ggdb
  76. else
  77. CFLAGS += -Os
  78. endif
  79. # TUSB Logging option
  80. ifneq ($(LOG),)
  81. CFLAGS += -DCFG_TUSB_DEBUG=$(LOG)
  82. endif