Makefile 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #########################
  2. # IAR Makefile for STM8 #
  3. #########################
  4. # Âçÿë èç ïðîåêòà atomthreads è ïåðåèíà÷èë.
  5. PROJECT=VAPC
  6. # Location of build tools and atomthreads sources
  7. EWSTM8_DIR=C:\IAR\Embedded Workbench 7.3\stm8
  8. EWSTM8_BIN=C:/IAR/Embedded\ Workbench\ 7.3/stm8/bin
  9. CC=$(EWSTM8_BIN)/iccstm8
  10. ASM=$(EWSTM8_BIN)/iasmstm8
  11. LINK=$(EWSTM8_BIN)/ilinkstm8
  12. HEX=$(EWSTM8_BIN)/ielftool
  13. FLASHTOOL=C:/STMicroelectronics/st_toolset/stvp/STVP_CmdLine.exe
  14. FLASHOPT=-Device=STM8L051x3
  15. APP_SRC = src
  16. LIB_SRC = lib
  17. # Sources pats
  18. vpath %.c $(APP_SRC)
  19. vpath %.c $(LIB_SRC)
  20. vpath %.c StdPerphDrv/src
  21. # Include paths
  22. INCLUDES = -I inc
  23. INCLUDES += -I lib
  24. INCLUDES += -I StdPerphDrv/inc
  25. # CPU part number
  26. PART = STM8L05X_LD_VL
  27. ICF = lnkstm8l051f3.icf
  28. LIB_MODEL = dlstm8ssn.h
  29. # Directory for built objects
  30. OUT_DIR = Out
  31. OBJ_DIR = $(OUT_DIR)/Obj
  32. LIST_DIR = $(OUT_DIR)/List
  33. # Models
  34. CODE_MODEL = small
  35. DATA_MODEL = medium
  36. # Application object files
  37. APP_OBJECTS = $(notdir $(patsubst %.c,%.o,$(wildcard $(APP_SRC)/*.c)))
  38. # Librarys object files
  39. LIB_OBJECTS = $(notdir $(patsubst %.c,%.o,$(wildcard $(LIB_SRC)/*.c)))
  40. # STM8S Peripheral driver object files
  41. PERIPH_OBJECTS = stm8l15x_adc.o
  42. #PERIPH_OBJECTS += stm8l15x_aes.o
  43. #PERIPH_OBJECTS += stm8l15x_beep.o
  44. PERIPH_OBJECTS += stm8l15x_clk.o
  45. #PERIPH_OBJECTS += stm8l15x_comp.o
  46. #PERIPH_OBJECTS += stm8l15x_dac.o
  47. PERIPH_OBJECTS += stm8l15x_dma.o
  48. PERIPH_OBJECTS += stm8l15x_exti.o
  49. #PERIPH_OBJECTS += stm8l15x_flash.o
  50. PERIPH_OBJECTS += stm8l15x_gpio.o
  51. #PERIPH_OBJECTS += stm8l15x_i2c.o
  52. #PERIPH_OBJECTS += stm8l15x_irtim.o
  53. PERIPH_OBJECTS += stm8l15x_itc.o
  54. #PERIPH_OBJECTS += stm8l15x_iwdg.o
  55. #PERIPH_OBJECTS += stm8l15x_lcd.o
  56. #PERIPH_OBJECTS += stm8l15x_pwr.o
  57. #PERIPH_OBJECTS += stm8l15x_rst.o
  58. PERIPH_OBJECTS += stm8l15x_rtc.o
  59. PERIPH_OBJECTS += stm8l15x_spi.o
  60. PERIPH_OBJECTS += stm8l15x_syscfg.o
  61. PERIPH_OBJECTS += stm8l15x_tim1.o
  62. PERIPH_OBJECTS += stm8l15x_tim2.o
  63. PERIPH_OBJECTS += stm8l15x_tim3.o
  64. PERIPH_OBJECTS += stm8l15x_tim4.o
  65. #PERIPH_OBJECTS += stm8l15x_tim5.o
  66. PERIPH_OBJECTS += stm8l15x_usart.o
  67. #PERIPH_OBJECTS += stm8l15x_wfe.o
  68. #PERIPH_OBJECTS += stm8l15x_wwdg.o
  69. # Collection of built objects (excluding test applications)
  70. ALL_OBJECTS = $(APP_OBJECTS) $(LIB_OBJECTS) $(PERIPH_OBJECTS)
  71. BUILT_OBJECTS = $(patsubst %,$(OUT_DIR)/%,$(ALL_OBJECTS))
  72. # Target application filenames (.elf) for each test object
  73. PROJ_ELF = $(PROJECT).elf
  74. PROJ_S19 = $(PROJECT).s19
  75. PROJ_HEX = $(PROJECT).hex
  76. # Search build/output directory for dependencies
  77. vpath %.o .\$(OBJ_DIR)
  78. vpath %.elf .\$(OUT_DIR)
  79. vpath %.hex .\$(OUT_DIR)
  80. # Compiler/Assembler flags
  81. CFLAGS = -e -Oh -D USE_STDPERIPH_DRIVER -D USE_RTOS
  82. CFLAGS += --code_model $(CODE_MODEL) --data_model $(DATA_MODEL)
  83. CFLAGS += --dlib_config "$(EWSTM8_DIR)\lib\$(LIB_MODEL)"
  84. CFLAGS += -D NDEBUG -D $(PART)
  85. CFLAGS += -lCN $(LIST_DIR) -lBN $(LIST_DIR)
  86. CFLAGS += --diag_suppress Pa050
  87. DBG_CFLAGS = -e -Ol --no_cse --no_unroll --no_inline --no_code_motion --no_tbaa
  88. DBG_CFLAGS += --no_cross_call --debug --code_model $(CODE_MODEL) --data_model $(DATA_MODEL)
  89. DBG_CFLAGS += --dlib_config "$(EWSTM8_DIR)\lib\$(LIB_MODEL)" -D $(PART)
  90. DBG_CFLAGS += -lC $(LIST_DIR) -lB $(LIST_DIR)
  91. DBG_CFLAGS += --diag_suppress Pa050
  92. ASMFLAGS = -M'<>' -ld $(OUT_DIR)\list --diag_suppress Pa050
  93. ASMFLAGS += --code_model small --data_model small
  94. DBG_ASMFLAGS = -M'<>' -r -ld $(OUT_DIR)\list --diag_suppress Pa050
  95. DBG_ASMFLAGS += --code_model $(CODE_MODEL) --data_model $(DATA_MODEL)
  96. LINKFLAGS = --redirect _Printf=_PrintfTinyNoMb
  97. LINKFLAGS += --redirect _Scanf=_ScanfSmallNoMb
  98. LINKFLAGS += --config "$(EWSTM8_DIR)\config\$(ICF)"
  99. LINKFLAGS += --config_def _CSTACK_SIZE=0x100
  100. LINKFLAGS += --config_def _HEAP_SIZE=0x000
  101. LINKFLAGS += --map $(OUT_DIR)
  102. LINKFLAGS += --entry __iar_program_start
  103. LINKFLAGS += --merge_duplicate_sections
  104. LINKFLAGS += --strip
  105. LINKFLAGS += -f "$(EWSTM8_DIR)\config\math_small.xcl"
  106. DBG_LINKFLAGS = --redirect _Printf=_PrintfTinyNoMb --redirect _Scanf=_ScanfSmallNoMb
  107. DBG_LINKFLAGS += --config "$(EWSTM8_DIR)\config\$(ICF)" --config_def
  108. DBG_LINKFLAGS += _CSTACK_SIZE=0x100 --config_def _HEAP_SIZE=0x000
  109. DBG_LINKFLAGS += --entry __iar_program_start
  110. #################
  111. # Build targets #
  112. #################
  113. # All
  114. all: $(OUT_DIR) $(PROJ_S19) $(PROJ_HEX)
  115. Release: all
  116. flash: all
  117. # Make build/output directory
  118. $(OUT_DIR):
  119. mkdir $(OUT_DIR)
  120. @mkdir $(OBJ_DIR)
  121. @mkdir $(LIST_DIR)
  122. # Test HEX files (one application build for each test)
  123. $(PROJ_S19): %.s19: $(PROJ_ELF)
  124. @echo
  125. @echo Building $@
  126. @$(HEX) $(OUT_DIR)/$(notdir $<) $(OUT_DIR)/$@ --srec --silent
  127. $(PROJ_HEX): %.hex: $(PROJ_ELF)
  128. @echo Building $@
  129. @$(HEX) $(OUT_DIR)/$(notdir $<) $(OUT_DIR)/$@ --ihex --silent
  130. # Test ELF files (one application build for each test)
  131. $(PROJ_ELF): %.elf: $(ALL_OBJECTS)
  132. @echo
  133. @echo Linking $@
  134. @$(LINK) $(OBJ_DIR)/*.o $(LINKFLAGS) -o $(OUT_DIR)/$@
  135. # All C objects builder
  136. $(ALL_OBJECTS): %.o: %.c
  137. @echo
  138. @echo Compiling $@
  139. @$(CC) $< $(CFLAGS) $(INCLUDES) -o $(OBJ_DIR)
  140. # Clean
  141. clean:
  142. rm -f *.o *.elf *.map *.hex *.bin *.lst *.stm8 *.s19 *.out *.s *.lst
  143. rm -rf $(LIST_DIR)
  144. rm -rf $(OBJ_DIR)
  145. rm -rf $(OUT_DIR)
  146. # Flash
  147. flash:
  148. @$(FLASHTOOL) $(FLASHOPT) -FileProg=$(OUT_DIR)\\$(PROJ_HEX)