make.mk 1.7 KB

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