make.mk 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #
  2. # Common make definition for all examples
  3. #
  4. # Compiler
  5. ifeq ($(BOARD), msp_exp430f5529lp)
  6. CROSS_COMPILE = msp430-elf-
  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 += $(subst $(TOP)/,,$(wildcard $(TOP)/hw/bsp/$(BOARD)/*.c))
  44. # Compiler Flags
  45. CFLAGS += \
  46. -fsingle-precision-constant \
  47. -fno-strict-aliasing \
  48. -Wdouble-promotion \
  49. -Wno-endif-labels \
  50. -Wstrict-prototypes \
  51. -Wall \
  52. -Werror \
  53. -Werror-implicit-function-declaration \
  54. -Wfloat-equal \
  55. -Wundef \
  56. -Wshadow \
  57. -Wwrite-strings \
  58. -Wsign-compare \
  59. -Wmissing-format-attribute \
  60. -Wno-deprecated-declarations \
  61. -Wnested-externs \
  62. -Wunreachable-code \
  63. -ffunction-sections \
  64. -fdata-sections
  65. ifneq ($(BOARD), msp_exp430f5529lp)
  66. CFLAGS += -Wno-error=lto-type-mismatch
  67. endif
  68. # This causes lots of warning with nrf5x build due to nrfx code
  69. # CFLAGS += -Wcast-align
  70. # Debugging/Optimization
  71. ifeq ($(DEBUG), 1)
  72. CFLAGS += -O0 -ggdb -DCFG_TUSB_DEBUG=1
  73. else
  74. CFLAGS += -flto -Os
  75. endif