Makefile 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. TARGET = target_lo
  2. ######################################
  3. # building variables
  4. ######################################
  5. # debug build?
  6. DEBUG = 1
  7. # optimization
  8. OPT = -Og
  9. #######################################
  10. # paths
  11. #######################################
  12. # Build path
  13. BUILD_DIR = build
  14. ######################################
  15. # source
  16. ######################################
  17. C_SOURCES =
  18. CPP_SOURCES =
  19. C_DEFS =
  20. # Target
  21. C_SOURCES += Src/main.c
  22. C_SOURCES += Src/flipper_hal.c
  23. C_SOURCES += Src/lo_os.c
  24. C_SOURCES += Src/lo_hal.c
  25. C_DEFS += -DFURI_DEBUG
  26. # Core
  27. CPP_SOURCES += ../core/app.cpp
  28. C_SOURCES += ../core/debug.c
  29. C_SOURCES += ../core/furi.c
  30. C_SOURCES += ../core/furi_ac.c
  31. # System applications
  32. ifeq ($(TEST), 1)
  33. C_SOURCES += ../applications/tests/furiac_test.c
  34. C_SOURCES += ../applications/tests/furi_record_test.c
  35. C_SOURCES += ../applications/tests/test_index.c
  36. C_DEFS += -DTEST
  37. endif
  38. # Examples
  39. ifeq ($(EXAMPLE_BLINK), 1)
  40. C_SOURCES += ../applications/examples/blink.c
  41. C_DEFS += -DEXAMPLE_BLINK
  42. endif
  43. # User application
  44. # Add C_SOURCES +=, C_DEFS += or CPP_SOURCES += here
  45. #######################################
  46. # binaries
  47. #######################################
  48. CC = gcc
  49. CPP = g++
  50. AS =
  51. CP = objcopy
  52. SZ = size
  53. HEX = $(CP) -O ihex
  54. BIN = $(CP) -O binary -S
  55. #######################################
  56. # CFLAGS
  57. #######################################
  58. # C includes
  59. C_INCLUDES = \
  60. -IInc \
  61. -I../applications \
  62. -I../core
  63. # compile gcc flags
  64. CFLAGS = $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -pthread
  65. ifeq ($(DEBUG), 1)
  66. CFLAGS += -g -gdwarf-2
  67. endif
  68. # Generate dependency information
  69. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  70. CPPFLAGS = -fno-threadsafe-statics
  71. #######################################
  72. # LDFLAGS
  73. #######################################
  74. # libraries
  75. LIBS = -lc -lm
  76. LIBDIR =
  77. LDFLAGS = $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections -pthread
  78. # default action: build all
  79. all: $(BUILD_DIR)/$(TARGET)
  80. example_blink:
  81. EXAMPLE_BLINK=1 make
  82. $(BUILD_DIR)/$(TARGET)
  83. test:
  84. TEST=1 make
  85. $(BUILD_DIR)/$(TARGET)
  86. #######################################
  87. # build the application
  88. #######################################
  89. # list of objects
  90. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  91. vpath %.c $(sort $(dir $(C_SOURCES)))
  92. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o)))
  93. vpath %.cpp $(sort $(dir $(CPP_SOURCES)))
  94. $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
  95. $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  96. $(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR)
  97. $(CPP) -c $(CFLAGS) $(CPPFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  98. $(BUILD_DIR)/$(TARGET): $(OBJECTS) Makefile
  99. $(CPP) $(OBJECTS) $(LDFLAGS) -o $@
  100. $(SZ) $@
  101. $(BUILD_DIR):
  102. mkdir $@
  103. #######################################
  104. # clean up
  105. #######################################
  106. clean:
  107. -rm -fR $(BUILD_DIR)
  108. #######################################
  109. # dependencies
  110. #######################################
  111. -include $(wildcard $(BUILD_DIR)/*.d)
  112. # *** EOF ***