-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
609 lines (530 loc) · 20.4 KB
/
Makefile
File metadata and controls
609 lines (530 loc) · 20.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
##########################################################################################################################
# File automatically-generated by STM32forVSCode
##########################################################################################################################
# ------------------------------------------------
# Generic Makefile (based on gcc)
#
# ChangeLog :
# 2024-04-27 - Added env file inclusion.
# Added way to overide: build directory, target name and optimisation.
# Added GCC_PATH by env file to not make the makefile machine dependent.
# Currently folder structure in build directory is preserved
# Switching of debug/release build output folder now happens based on debug flag
# 2017-02-10 - Several enhancements + project update mode
# 2015-07-22 - first version
# ------------------------------------------------
######################################
# Environment Variables
######################################
# Imports the environment file in which the compiler and other tooling is set
# for the build machine.
# This can also be used to overwrite some makefile variables
file_exists = $(or $(and $(wildcard $(1)),1),0)
ifeq ($(call file_exists,.stm32env),1)
include .stm32env
endif
######################################
# Target
######################################
# This is the name of the embedded target which will be build
# The final file name will also have debug or release appended to it.
TARGET ?= deltaprobe
#######################################
# Build directories
#######################################
# Build path can be overwritten when calling make or setting the environment variable
# in .stm32env
BUILD_DIRECTORY ?= build
######################################
# Optimization
######################################
# Optimization is switched based upon the DEBUG variable. If set to 1
# it will be build in debug mode with the Og optimization flag (optimized for debugging).
# If set to 0 (false) then by default the variable is used in the configuration yaml
# This can also be overwritten using the environment variable or by overwriting it
# by calling make with the OPTIMIZATION variable e.g.:
# make -f STM32Make.make -j 16 OPTIMIZATION=Os
# variable which determines if it is a debug build
DEBUG ?= 1
# debug flags when debug is defined
OPTIMIZATION ?= -Og
RELEASE_DIRECTORY = $(BUILD_DIRECTORY)/debug
ifeq ($(DEBUG),1)
# Sets debugging optimization -Og and the debug information output
OPTIMIZATION_FLAGS += -Og -g -gdwarf -ggdb
$(TARGET) := $(TARGET)-debug
RELEASE_DIRECTORY := $(BUILD_DIRECTORY)/debug
else
OPTIMIZATION_FLAGS += $(OPTIMIZATION)
$(TARGET) := $(TARGET)-release
RELEASE_DIRECTORY := $(BUILD_DIRECTORY)/release
endif
######################################
# source
######################################
# C sources
C_SOURCES = \
Core/Src/buttons.c \
Core/Src/display.c \
Core/Src/display_assets.c \
Core/Src/flash.c \
Core/Src/main.c \
Core/Src/measure.c \
Core/Src/sleep.c \
Core/Src/stm32f4xx_hal_msp.c \
Core/Src/stm32f4xx_it.c \
Core/Src/syscalls.c \
Core/Src/sysmem.c \
Core/Src/system_stm32f4xx.c \
Core/Src/u8g2_stm32f4.c \
Core/Src/usb.c \
Core/Src/usb_descriptors.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c \
Lib/tinyusb/src/class/audio/audio_device.c \
Lib/tinyusb/src/class/bth/bth_device.c \
Lib/tinyusb/src/class/cdc/cdc_device.c \
Lib/tinyusb/src/class/cdc/cdc_host.c \
Lib/tinyusb/src/class/cdc/cdc_rndis_host.c \
Lib/tinyusb/src/class/dfu/dfu_device.c \
Lib/tinyusb/src/class/dfu/dfu_rt_device.c \
Lib/tinyusb/src/class/hid/hid_device.c \
Lib/tinyusb/src/class/hid/hid_host.c \
Lib/tinyusb/src/class/midi/midi_device.c \
Lib/tinyusb/src/class/midi/midi_host.c \
Lib/tinyusb/src/class/msc/msc_device.c \
Lib/tinyusb/src/class/msc/msc_host.c \
Lib/tinyusb/src/class/mtp/mtp_device.c \
Lib/tinyusb/src/class/net/ecm_rndis_device.c \
Lib/tinyusb/src/class/net/ncm_device.c \
Lib/tinyusb/src/class/usbtmc/usbtmc_device.c \
Lib/tinyusb/src/class/vendor/vendor_device.c \
Lib/tinyusb/src/class/vendor/vendor_host.c \
Lib/tinyusb/src/class/video/video_device.c \
Lib/tinyusb/src/common/tusb_fifo.c \
Lib/tinyusb/src/device/usbd.c \
Lib/tinyusb/src/device/usbd_control.c \
Lib/tinyusb/src/host/hub.c \
Lib/tinyusb/src/host/usbh.c \
Lib/tinyusb/src/portable/analog/max3421/hcd_max3421.c \
Lib/tinyusb/src/portable/bridgetek/ft9xx/dcd_ft9xx.c \
Lib/tinyusb/src/portable/chipidea/ci_fs/dcd_ci_fs.c \
Lib/tinyusb/src/portable/chipidea/ci_hs/dcd_ci_hs.c \
Lib/tinyusb/src/portable/chipidea/ci_hs/hcd_ci_hs.c \
Lib/tinyusb/src/portable/dialog/da146xx/dcd_da146xx.c \
Lib/tinyusb/src/portable/ehci/ehci.c \
Lib/tinyusb/src/portable/mentor/musb/dcd_musb.c \
Lib/tinyusb/src/portable/mentor/musb/hcd_musb.c \
Lib/tinyusb/src/portable/microchip/pic/dcd_pic.c \
Lib/tinyusb/src/portable/microchip/pic32mz/dcd_pic32mz.c \
Lib/tinyusb/src/portable/microchip/samd/dcd_samd.c \
Lib/tinyusb/src/portable/microchip/samd/hcd_samd.c \
Lib/tinyusb/src/portable/microchip/samg/dcd_samg.c \
Lib/tinyusb/src/portable/microchip/samx7x/dcd_samx7x.c \
Lib/tinyusb/src/portable/mindmotion/mm32/dcd_mm32f327x_otg.c \
Lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c \
Lib/tinyusb/src/portable/nuvoton/nuc120/dcd_nuc120.c \
Lib/tinyusb/src/portable/nuvoton/nuc121/dcd_nuc121.c \
Lib/tinyusb/src/portable/nuvoton/nuc505/dcd_nuc505.c \
Lib/tinyusb/src/portable/nxp/khci/dcd_khci.c \
Lib/tinyusb/src/portable/nxp/khci/hcd_khci.c \
Lib/tinyusb/src/portable/nxp/lpc17_40/dcd_lpc17_40.c \
Lib/tinyusb/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c \
Lib/tinyusb/src/portable/ohci/ohci.c \
Lib/tinyusb/src/portable/raspberrypi/pio_usb/dcd_pio_usb.c \
Lib/tinyusb/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c \
Lib/tinyusb/src/portable/raspberrypi/rp2040/dcd_rp2040.c \
Lib/tinyusb/src/portable/raspberrypi/rp2040/hcd_rp2040.c \
Lib/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.c \
Lib/tinyusb/src/portable/renesas/rusb2/dcd_rusb2.c \
Lib/tinyusb/src/portable/renesas/rusb2/hcd_rusb2.c \
Lib/tinyusb/src/portable/renesas/rusb2/rusb2_common.c \
Lib/tinyusb/src/portable/sony/cxd56/dcd_cxd56.c \
Lib/tinyusb/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c \
Lib/tinyusb/src/portable/st/typec/typec_stm32.c \
Lib/tinyusb/src/portable/sunxi/dcd_sunxi_musb.c \
Lib/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c \
Lib/tinyusb/src/portable/synopsys/dwc2/dwc2_common.c \
Lib/tinyusb/src/portable/synopsys/dwc2/hcd_dwc2.c \
Lib/tinyusb/src/portable/template/dcd_template.c \
Lib/tinyusb/src/portable/template/hcd_template.c \
Lib/tinyusb/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c \
Lib/tinyusb/src/portable/valentyusb/eptri/dcd_eptri.c \
Lib/tinyusb/src/portable/wch/dcd_ch32_usbfs.c \
Lib/tinyusb/src/portable/wch/dcd_ch32_usbhs.c \
Lib/tinyusb/src/portable/wch/hcd_ch32_usbfs.c \
Lib/tinyusb/src/tusb.c \
Lib/tinyusb/src/typec/usbc.c \
Lib/u8g2/csrc/mui.c \
Lib/u8g2/csrc/mui_u8g2.c \
Lib/u8g2/csrc/u8g2_arc.c \
Lib/u8g2/csrc/u8g2_bitmap.c \
Lib/u8g2/csrc/u8g2_box.c \
Lib/u8g2/csrc/u8g2_buffer.c \
Lib/u8g2/csrc/u8g2_button.c \
Lib/u8g2/csrc/u8g2_circle.c \
Lib/u8g2/csrc/u8g2_cleardisplay.c \
Lib/u8g2/csrc/u8g2_d_memory.c \
Lib/u8g2/csrc/u8g2_d_setup.c \
Lib/u8g2/csrc/u8g2_font.c \
Lib/u8g2/csrc/u8g2_fonts.c \
Lib/u8g2/csrc/u8g2_hvline.c \
Lib/u8g2/csrc/u8g2_input_value.c \
Lib/u8g2/csrc/u8g2_intersection.c \
Lib/u8g2/csrc/u8g2_kerning.c \
Lib/u8g2/csrc/u8g2_line.c \
Lib/u8g2/csrc/u8g2_ll_hvline.c \
Lib/u8g2/csrc/u8g2_message.c \
Lib/u8g2/csrc/u8g2_polygon.c \
Lib/u8g2/csrc/u8g2_selection_list.c \
Lib/u8g2/csrc/u8g2_setup.c \
Lib/u8g2/csrc/u8log.c \
Lib/u8g2/csrc/u8log_u8g2.c \
Lib/u8g2/csrc/u8log_u8x8.c \
Lib/u8g2/csrc/u8x8_8x8.c \
Lib/u8g2/csrc/u8x8_byte.c \
Lib/u8g2/csrc/u8x8_cad.c \
Lib/u8g2/csrc/u8x8_capture.c \
Lib/u8g2/csrc/u8x8_d_a2printer.c \
Lib/u8g2/csrc/u8x8_d_ch1120.c \
Lib/u8g2/csrc/u8x8_d_gp1247ai.c \
Lib/u8g2/csrc/u8x8_d_gp1287ai.c \
Lib/u8g2/csrc/u8x8_d_gp1294ai.c \
Lib/u8g2/csrc/u8x8_d_gu800.c \
Lib/u8g2/csrc/u8x8_d_hd44102.c \
Lib/u8g2/csrc/u8x8_d_il3820_296x128.c \
Lib/u8g2/csrc/u8x8_d_ist3020.c \
Lib/u8g2/csrc/u8x8_d_ist3088.c \
Lib/u8g2/csrc/u8x8_d_ist7920.c \
Lib/u8g2/csrc/u8x8_d_ks0108.c \
Lib/u8g2/csrc/u8x8_d_lc7981.c \
Lib/u8g2/csrc/u8x8_d_ld7032_60x32.c \
Lib/u8g2/csrc/u8x8_d_ls013b7dh03.c \
Lib/u8g2/csrc/u8x8_d_max7219.c \
Lib/u8g2/csrc/u8x8_d_pcd8544_84x48.c \
Lib/u8g2/csrc/u8x8_d_pcf8812.c \
Lib/u8g2/csrc/u8x8_d_pcf8814_hx1230.c \
Lib/u8g2/csrc/u8x8_d_s1d15300.c \
Lib/u8g2/csrc/u8x8_d_s1d15721.c \
Lib/u8g2/csrc/u8x8_d_s1d15e06.c \
Lib/u8g2/csrc/u8x8_d_sbn1661.c \
Lib/u8g2/csrc/u8x8_d_sed1330.c \
Lib/u8g2/csrc/u8x8_d_sh1106_64x32.c \
Lib/u8g2/csrc/u8x8_d_sh1106_72x40.c \
Lib/u8g2/csrc/u8x8_d_sh1107.c \
Lib/u8g2/csrc/u8x8_d_sh1108.c \
Lib/u8g2/csrc/u8x8_d_sh1122.c \
Lib/u8g2/csrc/u8x8_d_ssd1305.c \
Lib/u8g2/csrc/u8x8_d_ssd1306_128x32.c \
Lib/u8g2/csrc/u8x8_d_ssd1306_128x64_noname.c \
Lib/u8g2/csrc/u8x8_d_ssd1306_2040x16.c \
Lib/u8g2/csrc/u8x8_d_ssd1306_48x64.c \
Lib/u8g2/csrc/u8x8_d_ssd1306_64x32.c \
Lib/u8g2/csrc/u8x8_d_ssd1306_64x48.c \
Lib/u8g2/csrc/u8x8_d_ssd1306_72x40.c \
Lib/u8g2/csrc/u8x8_d_ssd1306_96x16.c \
Lib/u8g2/csrc/u8x8_d_ssd1306_96x40.c \
Lib/u8g2/csrc/u8x8_d_ssd1309.c \
Lib/u8g2/csrc/u8x8_d_ssd1312.c \
Lib/u8g2/csrc/u8x8_d_ssd1315_128x64_noname.c \
Lib/u8g2/csrc/u8x8_d_ssd1316.c \
Lib/u8g2/csrc/u8x8_d_ssd1317.c \
Lib/u8g2/csrc/u8x8_d_ssd1318.c \
Lib/u8g2/csrc/u8x8_d_ssd1320.c \
Lib/u8g2/csrc/u8x8_d_ssd1322.c \
Lib/u8g2/csrc/u8x8_d_ssd1325.c \
Lib/u8g2/csrc/u8x8_d_ssd1326.c \
Lib/u8g2/csrc/u8x8_d_ssd1327.c \
Lib/u8g2/csrc/u8x8_d_ssd1329.c \
Lib/u8g2/csrc/u8x8_d_ssd1362.c \
Lib/u8g2/csrc/u8x8_d_ssd1363.c \
Lib/u8g2/csrc/u8x8_d_ssd1606_172x72.c \
Lib/u8g2/csrc/u8x8_d_ssd1607_200x200.c \
Lib/u8g2/csrc/u8x8_d_st7302.c \
Lib/u8g2/csrc/u8x8_d_st7305.c \
Lib/u8g2/csrc/u8x8_d_st7511.c \
Lib/u8g2/csrc/u8x8_d_st75160.c \
Lib/u8g2/csrc/u8x8_d_st75161.c \
Lib/u8g2/csrc/u8x8_d_st75256.c \
Lib/u8g2/csrc/u8x8_d_st7528.c \
Lib/u8g2/csrc/u8x8_d_st75320.c \
Lib/u8g2/csrc/u8x8_d_st7539.c \
Lib/u8g2/csrc/u8x8_d_st7565.c \
Lib/u8g2/csrc/u8x8_d_st7567.c \
Lib/u8g2/csrc/u8x8_d_st7571.c \
Lib/u8g2/csrc/u8x8_d_st7586s_erc240160.c \
Lib/u8g2/csrc/u8x8_d_st7586s_jlx320160.c \
Lib/u8g2/csrc/u8x8_d_st7586s_jlx384160.c \
Lib/u8g2/csrc/u8x8_d_st7586s_md240128.c \
Lib/u8g2/csrc/u8x8_d_st7586s_s028hn118a.c \
Lib/u8g2/csrc/u8x8_d_st7586s_ymc240160.c \
Lib/u8g2/csrc/u8x8_d_st7588.c \
Lib/u8g2/csrc/u8x8_d_st7920.c \
Lib/u8g2/csrc/u8x8_d_stdio.c \
Lib/u8g2/csrc/u8x8_d_t6963.c \
Lib/u8g2/csrc/u8x8_d_uc1601.c \
Lib/u8g2/csrc/u8x8_d_uc1604.c \
Lib/u8g2/csrc/u8x8_d_uc1608.c \
Lib/u8g2/csrc/u8x8_d_uc1609.c \
Lib/u8g2/csrc/u8x8_d_uc1610.c \
Lib/u8g2/csrc/u8x8_d_uc1611.c \
Lib/u8g2/csrc/u8x8_d_uc1617.c \
Lib/u8g2/csrc/u8x8_d_uc1628.c \
Lib/u8g2/csrc/u8x8_d_uc1638.c \
Lib/u8g2/csrc/u8x8_d_uc1698.c \
Lib/u8g2/csrc/u8x8_d_uc1701_dogs102.c \
Lib/u8g2/csrc/u8x8_d_uc1701_mini12864.c \
Lib/u8g2/csrc/u8x8_debounce.c \
Lib/u8g2/csrc/u8x8_display.c \
Lib/u8g2/csrc/u8x8_fonts.c \
Lib/u8g2/csrc/u8x8_gpio.c \
Lib/u8g2/csrc/u8x8_input_value.c \
Lib/u8g2/csrc/u8x8_message.c \
Lib/u8g2/csrc/u8x8_selection_list.c \
Lib/u8g2/csrc/u8x8_setup.c \
Lib/u8g2/csrc/u8x8_string.c \
Lib/u8g2/csrc/u8x8_u16toa.c \
Lib/u8g2/csrc/u8x8_u8toa.c
CXX_SOURCES = \
# ASM sources
ASM_SOURCES = \
startup_stm32f411xe.s
#######################################
# Tools
#######################################
ARM_PREFIX = arm-none-eabi-
POSTFIX = "
PREFIX = "
# The gcc compiler bin path can be defined in the make command via ARM_GCC_PATH variable (e.g.: make ARM_GCC_PATH=xxx)
# or it can be added to the PATH environment variable.
# By default the variable be used from the environment file: .stm32env.
# if it is not defined
ifdef ARM_GCC_PATH
CC = $(PREFIX)$(ARM_GCC_PATH)/$(ARM_PREFIX)gcc$(POSTFIX)
CXX = $(PREFIX)$(ARM_GCC_PATH)/$(ARM_PREFIX)g++$(POSTFIX)
AS = $(PREFIX)$(ARM_GCC_PATH)/$(ARM_PREFIX)gcc$(POSTFIX) -x assembler-with-cpp
CP = $(PREFIX)$(ARM_GCC_PATH)/$(ARM_PREFIX)objcopy$(POSTFIX)
SZ = $(PREFIX)$(ARM_GCC_PATH)/$(ARM_PREFIX)size$(POSTFIX)
DP = $(PREFIX)$(ARM_GCC_PATH)/$(ARM_PREFIX)objdump$(POSTFIX)
else
CC ?= $(ARM_PREFIX)gcc
CXX ?= $(ARM_PREFIX)g++$
AS ?= $(ARM_PREFIX)gcc -x assembler-with-cpp
CP ?= $(ARM_PREFIX)objcopy
SZ ?= $(ARM_PREFIX)size
DP ?= $(ARM_PREFIX)objdump
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
LSS = $(DP) -h -S
REMOVE_DIRECTORY_COMMAND = rm -fR
mkdir_function = mkdir -p $(1)
ifeq ($(OS),Windows_NT)
convert_to_windows_path = $(strip $(subst /,\,$(patsubst %/,%,$(1))))
REMOVE_DIRECTORY_COMMAND = cmd /c rd /s /q
mkdir_function = cmd /e:on /c if not exist $(call convert_to_windows_path,$(1)) md $(call convert_to_windows_path,$(1))
endif
# Flash and debug tools
# Default is openocd however will be gotten from the env file when existing
OPENOCD ?= openocd
#######################################
# CFLAGS
#######################################
# cpu
CPU = -mcpu=cortex-m4
# fpu
FPU = -mfpu=fpv4-sp-d16
# float-abi
FLOAT-ABI = -mfloat-abi=hard
# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
# macros for gcc
# AS defines
AS_DEFS =
# C defines
C_DEFS = \
-DSTM32F411xE \
-DUSE_HAL_DRIVER
# CXX defines
CXX_DEFS = \
-DSTM32F411xE \
-DUSE_HAL_DRIVER
# AS includes
AS_INCLUDES = \
# C includes
C_INCLUDES = \
-ICore/Inc \
-IDrivers/CMSIS/Device/ST/STM32F4xx/Include \
-IDrivers/CMSIS/Include \
-IDrivers/STM32F4xx_HAL_Driver/Inc \
-IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy \
-ILib/tinyusb/src \
-ILib/tinyusb/src/class/audio \
-ILib/tinyusb/src/class/bth \
-ILib/tinyusb/src/class/cdc \
-ILib/tinyusb/src/class/cdc/serial \
-ILib/tinyusb/src/class/dfu \
-ILib/tinyusb/src/class/hid \
-ILib/tinyusb/src/class/midi \
-ILib/tinyusb/src/class/msc \
-ILib/tinyusb/src/class/mtp \
-ILib/tinyusb/src/class/net \
-ILib/tinyusb/src/class/usbtmc \
-ILib/tinyusb/src/class/vendor \
-ILib/tinyusb/src/class/video \
-ILib/tinyusb/src/common \
-ILib/tinyusb/src/device \
-ILib/tinyusb/src/host \
-ILib/tinyusb/src/osal \
-ILib/tinyusb/src/portable/analog/max3421 \
-ILib/tinyusb/src/portable/chipidea/ci_fs \
-ILib/tinyusb/src/portable/chipidea/ci_hs \
-ILib/tinyusb/src/portable/ehci \
-ILib/tinyusb/src/portable/mentor/musb \
-ILib/tinyusb/src/portable/microchip/pic32mz \
-ILib/tinyusb/src/portable/microchip/samx7x \
-ILib/tinyusb/src/portable/nxp/lpc17_40 \
-ILib/tinyusb/src/portable/ohci \
-ILib/tinyusb/src/portable/raspberrypi/rp2040 \
-ILib/tinyusb/src/portable/renesas/rusb2 \
-ILib/tinyusb/src/portable/st/stm32_fsdev \
-ILib/tinyusb/src/portable/sunxi \
-ILib/tinyusb/src/portable/synopsys/dwc2 \
-ILib/tinyusb/src/portable/valentyusb/eptri \
-ILib/tinyusb/src/portable/wch \
-ILib/tinyusb/src/typec \
-ILib/u8g2/csrc
# compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(C_INCLUDES) $(C_DEFS) $(OPTIMIZATION_FLAGS)
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPTIMIZATION_FLAGS)
CXXFLAGS = $(MCU) $(CXX_DEFS) $(C_INCLUDES) $(OPTIMIZATION_FLAGS)
# Add additional flags
CFLAGS += -Wall -fdata-sections -ffunction-sections
ASFLAGS += -Wall -fdata-sections -ffunction-sections
CXXFLAGS += -fno-exceptions -fno-rtti
# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
CXXFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
# Output a list file for the compiled source file.
# This is a representative of the source code in assembly
ASSEMBLER_LIST_OUTPUT_FLAG = -Wa,-a,-ad,-alms=$(call add_release_directory,$<,lst)
CFLAGS += $(ASSEMBLER_LIST_OUTPUT_FLAG)
CXXFLAGS += $(ASSEMBLER_LIST_OUTPUT_FLAG)
#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = STM32F411XX_FLASH.ld
# libraries
LIBS = -lc -lm -lnosys
LIBDIR = \
-LLib/u8g2 \
-Ltinyusb
# Additional LD Flags from config file
ADDITIONALLDFLAGS = -Wl,--print-memory-usage -specs=nano.specs
LDFLAGS = $(MCU) $(ADDITIONALLDFLAGS) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIRECTORY)/$(TARGET).map,--cref -Wl,--gc-sections
#######################################
# build the application
#######################################
add_release_directory = $(sort $(addprefix $(RELEASE_DIRECTORY)/,$(addsuffix .$(2),$(basename $(notdir $(1))))))
OBJECTS = $(call add_release_directory,$(C_SOURCES),o)
OBJECTS += $(call add_release_directory,$(CXX_SOURCES),o)
OBJECTS += $(call add_release_directory,$(ASM_SOURCES),o)
vpath %.c $(sort $(dir $(C_SOURCES)))
vpath %.cc $(sort $(dir $(CXX_SOURCES)))
vpath %.cp $(sort $(dir $(CXX_SOURCES)))
vpath %.cxx $(sort $(dir $(CXX_SOURCES)))
vpath %.cpp $(sort $(dir $(CXX_SOURCES)))
vpath %.c++ $(sort $(dir $(CXX_SOURCES)))
vpath %.C $(sort $(dir $(CXX_SOURCES)))
vpath %.CPP $(sort $(dir $(CXX_SOURCES)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
vpath %.S $(sort $(dir $(ASM_SOURCES)))
#######################################
# all
#######################################
# note needs to be located as the first rule to be the default build rule
# default action: build all
all: $(RELEASE_DIRECTORY)/$(TARGET).elf $(RELEASE_DIRECTORY)/$(TARGET).hex $(RELEASE_DIRECTORY)/$(TARGET).bin $(RELEASE_DIRECTORY)/$(TARGET).lss
# C build
$(RELEASE_DIRECTORY)/%.o: %.c STM32Make.make | $(RELEASE_DIRECTORY)
$(CC) -c $(CFLAGS) $< -o $@
# C++ build
$(RELEASE_DIRECTORY)/%.o: %.cc STM32Make.make | $(RELEASE_DIRECTORY)
$(CXX) -c $(CXXFLAGS) $< -o $@
$(RELEASE_DIRECTORY)/%.o: %.cp STM32Make.make | $(RELEASE_DIRECTORY)
$(CXX) -c $(CXXFLAGS) $< -o $@
$(RELEASE_DIRECTORY)/%.o: %.cxx STM32Make.make | $(RELEASE_DIRECTORY)
$(CXX) -c $(CXXFLAGS) $< -o $@
$(RELEASE_DIRECTORY)/%.o: %.cpp STM32Make.make | $(RELEASE_DIRECTORY)
$(CXX) -c $(CXXFLAGS) $< -o $@
$(RELEASE_DIRECTORY)/%.o: %.c++ STM32Make.make | $(RELEASE_DIRECTORY)
$(CXX) -c $(CXXFLAGS) $< -o $@
$(RELEASE_DIRECTORY)/%.o: %.C STM32Make.make | $(RELEASE_DIRECTORY)
$(CXX) -c $(CXXFLAGS) $< -o $@
$(RELEASE_DIRECTORY)/%.o: %.CPP STM32Make.make | $(RELEASE_DIRECTORY)
$(CXX) -c $(CXXFLAGS) $< -o $@
#Assembly build
$(RELEASE_DIRECTORY)/%.o: %.s STM32Make.make | $(RELEASE_DIRECTORY)
$(AS) -c $(ASFLAGS) $< -o $@
$(RELEASE_DIRECTORY)/%.o: %.S STM32Make.make | $(RELEASE_DIRECTORY)
$(AS) -c $(ASFLAGS) $< -o $@
$(RELEASE_DIRECTORY)/%.o: %.sx STM32Make.make | $(RELEASE_DIRECTORY)
$(AS) -c $(ASFLAGS) $< -o $@
$(RELEASE_DIRECTORY)/$(TARGET).elf: $(OBJECTS) STM32Make.make | $(RELEASE_DIRECTORY)
@echo $(OBJECTS) > $@.in
$(CC) @$@.in $(LDFLAGS) -o $@
$(SZ) $@
$(RELEASE_DIRECTORY)/%.hex: $(RELEASE_DIRECTORY)/%.elf | $(RELEASE_DIRECTORY)
$(HEX) $< $@
$(RELEASE_DIRECTORY)/%.bin: $(RELEASE_DIRECTORY)/%.elf | $(RELEASE_DIRECTORY)
$(BIN) $< $@
$(RELEASE_DIRECTORY)/%.lss: $(RELEASE_DIRECTORY)/%.elf | $(RELEASE_DIRECTORY)
$(LSS) $< > $@
$(RELEASE_DIRECTORY):
$(call mkdir_function, $@)
$(BUILD_DIRECTORY): | $(RELEASE_DIRECTORY)
$(call mkdir_function, $@)
#######################################
# flash
#######################################
flash: all
"$(OPENOCD)" -f ./openocd.cfg -c "program $(RELEASE_DIRECTORY)/$(TARGET).elf verify reset exit"
#######################################
# erase
#######################################
erase: all
"$(OPENOCD)" -f ./openocd.cfg -c "init; reset halt; stm32f4x mass_erase 0; exit"
#######################################
# clean up
#######################################
clean:
$(REMOVE_DIRECTORY_COMMAND) $(BUILD_DIRECTORY)
#######################################
# custom makefile rules
#######################################
#######################################
# dependencies
#######################################
-include $(wildcard $(RELEASE_DIRECTORY)/*.d)
# *** EOF ***