make.mk 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. # Select the board to build for.
  22. ifeq ($(BOARD),)
  23. $(info You must provide a BOARD parameter with 'BOARD=')
  24. $(info Possible values are:)
  25. $(info $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.)))))
  26. $(error BOARD not defined)
  27. else
  28. ifeq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/.),)
  29. $(error Invalid BOARD specified)
  30. endif
  31. endif
  32. # Build directory
  33. BUILD = _build/build-$(BOARD)
  34. # Board specific
  35. include $(TOP)/hw/bsp/$(BOARD)/board.mk
  36. # Include all source C in board folder
  37. SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c))
  38. # Compiler Flags
  39. CFLAGS += \
  40. -fsingle-precision-constant \
  41. -fno-strict-aliasing \
  42. -Wdouble-promotion \
  43. -Wno-endif-labels \
  44. -Wstrict-prototypes \
  45. -Wall \
  46. -Werror \
  47. -Werror-implicit-function-declaration \
  48. -Wfloat-equal \
  49. -Wundef \
  50. -Wshadow \
  51. -Wwrite-strings \
  52. -Wsign-compare \
  53. -Wmissing-format-attribute \
  54. -Wno-deprecated-declarations \
  55. -Wnested-externs \
  56. -Wunreachable-code \
  57. -Wno-error=lto-type-mismatch \
  58. -ffunction-sections \
  59. -fdata-sections
  60. # This causes lots of warning with nrf5x build due to nrfx code
  61. # CFLAGS += -Wcast-align
  62. # Debugging/Optimization
  63. ifeq ($(DEBUG), 1)
  64. CFLAGS += -O0 -ggdb -DCFG_TUSB_DEBUG=1
  65. else
  66. CFLAGS += -flto -Os
  67. endif