make.mk 1.8 KB

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