make.mk 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #
  2. # Common make definition for all examples
  3. #
  4. # Compiler
  5. ifeq ($(BOARD), fomu)
  6. CROSS_COMPILE = riscv-none-embed-
  7. else
  8. CROSS_COMPILE = arm-none-eabi-
  9. endif
  10. CC = $(CROSS_COMPILE)gcc
  11. CXX = $(CROSS_COMPILE)g++
  12. OBJCOPY = $(CROSS_COMPILE)objcopy
  13. SIZE = $(CROSS_COMPILE)size
  14. MKDIR = mkdir
  15. SED = sed
  16. CP = cp
  17. RM = rm
  18. PYTHON ?= python
  19. check_defined = \
  20. $(strip $(foreach 1,$1, \
  21. $(call __check_defined,$1,$(strip $(value 2)))))
  22. __check_defined = \
  23. $(if $(value $1),, \
  24. $(error Undefined make flag: $1$(if $2, ($2))))
  25. define newline
  26. endef
  27. # Select the board to build for.
  28. ifeq ($(BOARD),)
  29. $(info You must provide a BOARD parameter with 'BOARD=')
  30. $(info Supported boards are:)
  31. $(info $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/, $(newline)-,$(wildcard $(TOP)/hw/bsp/*/.)))))
  32. $(error BOARD not defined)
  33. else
  34. ifeq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/.),)
  35. $(error Invalid BOARD specified)
  36. endif
  37. endif
  38. # Build directory
  39. BUILD = _build/build-$(BOARD)
  40. # Board specific
  41. include $(TOP)/hw/bsp/$(BOARD)/board.mk
  42. # Include all source C in board folder
  43. SRC_C += hw/bsp/board.c
  44. SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c))
  45. # Compiler Flags
  46. CFLAGS += \
  47. -fsingle-precision-constant \
  48. -fno-strict-aliasing \
  49. -Wdouble-promotion \
  50. -Wno-endif-labels \
  51. -Wstrict-prototypes \
  52. -Wall \
  53. -Wextra \
  54. -Werror \
  55. -Werror-implicit-function-declaration \
  56. -Wfatal-errors \
  57. -Wfloat-equal \
  58. -Wundef \
  59. -Wshadow \
  60. -Wwrite-strings \
  61. -Wsign-compare \
  62. -Wmissing-format-attribute \
  63. -Wno-deprecated-declarations \
  64. -Wnested-externs \
  65. -Wunreachable-code \
  66. -Wno-error=lto-type-mismatch \
  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