]> mj.ucw.cz Git - home-hw.git/blob - Makefile
First bits of my own high-level USB stack
[home-hw.git] / Makefile
1 ##########################################################################################################################
2 # File automatically-generated by tool: [projectgenerator] version: [2.27.0] date: [Sat Jun 23 19:52:50 CEST 2018] 
3 ##########################################################################################################################
4
5 # ------------------------------------------------
6 # Generic Makefile (based on gcc)
7 #
8 # ChangeLog :
9 #       2017-02-10 - Several enhancements + project update mode
10 #   2015-07-22 - first version
11 # ------------------------------------------------
12
13 ######################################
14 # target
15 ######################################
16 TARGET = testusb
17
18
19 ######################################
20 # building variables
21 ######################################
22 # debug build?
23 DEBUG = 1
24 # optimization
25 OPT = -Og
26
27
28 #######################################
29 # paths
30 #######################################
31 # source path
32 SOURCES_DIR =  \
33 Drivers \
34 Application/User/Src/main.c \
35 Application/User/Src \
36 Application/User/Src/stm32f1xx_hal_msp.c \
37 Drivers/STM32F1xx_HAL_Driver \
38 Application/User/Src/stm32f1xx_it.c \
39 Application/User \
40 Drivers/CMSIS \
41 Application
42
43 # firmware library path
44 PERIFLIB_PATH = 
45
46 # Build path
47 BUILD_DIR = build
48
49 ######################################
50 # source
51 ######################################
52 # C sources
53 C_SOURCES =  \
54 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_exti.c \
55 Src/main.c \
56 Src/usb.c \
57 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_rcc.c \
58 /Src/system_stm32f1xx.c \
59 Src/stm32f1xx_it.c \
60 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_utils.c \
61 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_gpio.c \
62 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \
63 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \
64 Src/stm32f1xx_hal_msp.c \
65 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \
66 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \
67 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c \
68 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \
69 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \
70 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \
71 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \
72 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \
73 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \
74 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \
75 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c \
76 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \
77 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd.c \
78 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usb.c \
79 /aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_i2c.c
80
81 # ASM sources
82 ASM_SOURCES =  \
83 startup_stm32f103xb.s
84
85
86 ######################################
87 # firmware library
88 ######################################
89 PERIFLIB_SOURCES = 
90
91
92 #######################################
93 # binaries
94 #######################################
95 BINPATH = /usr/bin
96 PREFIX = arm-none-eabi-
97 CC = $(BINPATH)/$(PREFIX)gcc
98 AS = $(BINPATH)/$(PREFIX)gcc -x assembler-with-cpp
99 CP = $(BINPATH)/$(PREFIX)objcopy
100 AR = $(BINPATH)/$(PREFIX)ar
101 SZ = $(BINPATH)/$(PREFIX)size
102 HEX = $(CP) -O ihex
103 BIN = $(CP) -O binary -S
104  
105 #######################################
106 # CFLAGS
107 #######################################
108 # cpu
109 CPU = -mcpu=cortex-m3
110
111 # fpu
112 # NONE for Cortex-M0/M0+/M3
113
114 # float-abi
115
116
117 # mcu
118 MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
119
120 # macros for gcc
121 # AS defines
122 AS_DEFS = 
123
124 # C defines
125 C_DEFS =  \
126 -DUSE_FULL_LL_DRIVER \
127 -DSTM32F103xB \
128 -DUSE_HAL_DRIVER
129
130
131 # AS includes
132 AS_INCLUDES = 
133
134 # C includes
135 C_INCLUDES =  \
136 -IInc \
137 -I/aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Inc \
138 -I/aux/misc/stm/F1-package/Drivers/STM32F1xx_HAL_Driver/Inc/Legacy \
139 -I/aux/misc/stm/F1-package/Drivers/CMSIS/Include \
140 -I/aux/misc/stm/F1-package/Drivers/CMSIS/Device/ST/STM32F1xx/Include
141
142
143 # compile gcc flags
144 ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
145
146 CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
147
148 ifeq ($(DEBUG), 1)
149 CFLAGS += -g -gdwarf-2
150 endif
151
152
153 # Generate dependency information
154 CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"
155
156
157 #######################################
158 # LDFLAGS
159 #######################################
160 # link script
161 LDSCRIPT = STM32F103C8Tx_FLASH.ld
162
163 # libraries
164 LIBS = -lc -lm -lnosys 
165 LIBDIR = 
166 LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
167
168 # default action: build all
169 all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
170
171 flash: all
172         LD_LIBRARY_PATH=../stlink ../stlink/st-flash write $(BUILD_DIR)/$(TARGET).bin 0x8000000
173
174 #######################################
175 # build the application
176 #######################################
177 # list of objects
178 OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
179 vpath %.c $(sort $(dir $(C_SOURCES)))
180 # list of ASM program objects
181 OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
182 vpath %.s $(sort $(dir $(ASM_SOURCES)))
183
184 $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 
185         $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
186
187 $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
188         $(AS) -c $(CFLAGS) $< -o $@
189
190 $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
191         $(CC) $(OBJECTS) $(LDFLAGS) -o $@
192         $(SZ) $@
193
194 $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
195         $(HEX) $< $@
196         
197 $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
198         $(BIN) $< $@    
199         
200 $(BUILD_DIR):
201         mkdir $@                
202
203 #######################################
204 # clean up
205 #######################################
206 clean:
207         -rm -fR .dep $(BUILD_DIR)
208   
209 #######################################
210 # dependencies
211 #######################################
212 -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
213
214 # *** EOF ***