forked from Ralim/IronOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
908 lines (792 loc) · 41.4 KB
/
Makefile
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
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
ifndef model
model:=Pinecil
endif
ALL_MINIWARE_MODELS=TS100 TS80 TS80P TS101
ALL_PINECIL_MODELS=Pinecil
ALL_PINECIL_V2_MODELS=Pinecilv2
ALL_MHP30_MODELS=MHP30
ALL_SEQURE_MODELS=S60
ALL_MODELS=$(ALL_MINIWARE_MODELS) $(ALL_PINECIL_MODELS) $(ALL_MHP30_MODELS) $(ALL_PINECIL_V2_MODELS) $(ALL_SEQURE_MODELS)
ifneq ($(model),$(filter $(model),$(ALL_MODELS)))
$(error Invalid model '$(model)', valid options are: $(ALL_MODELS))
endif
# Output folder
HEXFILE_DIR=Hexfile
# Temporary objects folder
OUTPUT_DIR_BASE=Objects
OUTPUT_DIR=Objects/$(model)
ALL_LANGUAGES=BG CS DA DE EN ES FI FR HR HU IT JA_JP LT NL NL_BE NB PL PT RU SK SL SR_CYRL SR_LATN SV TR UK VI YUE_HK ZH_CN ZH_TW
LANGUAGE_GROUP_CJK_LANGS=EN JA_JP YUE_HK ZH_TW ZH_CN
LANGUAGE_GROUP_CJK_NAME=Chinese+Japanese
ifdef custom_multi_langs
RUN_SHELL_CMD:=$(shell rm -Rf {Core/Gen,$(OUTPUT_DIR)/Core/Gen,$(HEXFILE_DIR)/*_Custom.*})
LANGUAGE_GROUP_CUSTOM_LANGS=$(custom_multi_langs)
LANGUAGE_GROUP_CUSTOM_NAME=Custom
endif
LANGUAGE_GROUP_CYRILLIC_LANGS=EN BG RU SR_CYRL SR_LATN UK
LANGUAGE_GROUP_CYRILLIC_NAME=Bulgarian+Russian+Serbian+Ukrainian
LANGUAGE_GROUP_EUR_LANGS=EN $(filter-out $(LANGUAGE_GROUP_CJK_LANGS) $(LANGUAGE_GROUP_CYRILLIC_LANGS),$(ALL_LANGUAGES))
LANGUAGE_GROUP_EUR_NAME=European
LANGUAGE_GROUPS=CUSTOM CJK CYRILLIC EUR
# Define for host Python
ifndef HOST_PYTHON
HOST_PYTHON:=python3
endif
# Defines for host tools
ifeq ($(HOST_CC),)
HOST_CC:=gcc
endif
HOST_OUTPUT_DIR=Objects/host
# DFU packing address to use
DEVICE_DFU_ADDRESS=0x08000000
DEVICE_DFU_VID_PID=0x28E9:0x0189
# Enumerate all of the include directories (HAL source dirs are used for clang-format only)
APP_INC_DIR=./Core/Inc
BRIEFLZ_INC_DIR=./Core/brieflz
MINIWARE_INC_CMSIS_DEVICE=./Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include
MINIWARE_CMSIS_CORE_INC_DIR=./Core/BSP/Miniware/Vendor/CMSIS/Include
MINIWARE_HAL_SRC_DIR= ./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver
MINIWARE_HAL_INC_DIR=./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc
MINIWARE_HAL_LEGACY_INC_DIR=./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/Legacy
MINIWARE_STARTUP_DIR=./Startup
MINIWARE_INC_DIR=./Core/BSP/Miniware
MINIWARE_LD_FILE=./Core/BSP/Miniware/stm32f103.ld
S60_INC_CMSIS_DEVICE=./Core/BSP/Sequre_S60/Vendor/CMSIS/Device/ST/STM32F1xx/Include
S60_CMSIS_CORE_INC_DIR=./Core/BSP/Sequre_S60/Vendor/CMSIS/Include
S60_HAL_SRC_DIR=./Core/BSP/Sequre_S60/Vendor/STM32F1xx_HAL_Driver
S60_HAL_INC_DIR=./Core/BSP/Sequre_S60/Vendor/STM32F1xx_HAL_Driver/Inc
S60_HAL_LEGACY_INC_DIR=./Core/BSP/Sequre_S60/Vendor/STM32F1xx_HAL_Driver/Inc/Legacy
S60_STARTUP_DIR=./Startup
S60_INC_DIR=./Core/BSP/Sequre_S60
S60_LD_FILE=./Core/BSP/Sequre_S60/stm32f103.ld
MHP30_INC_CMSIS_DEVICE=./Core/BSP/MHP30/Vendor/CMSIS/Device/ST/STM32F1xx/Include
MHP30_CMSIS_CORE_INC_DIR=./Core/BSP/MHP30/Vendor/CMSIS/Include
MHP30_HAL_SRC_DIR=./Core/BSP/MHP30/Vendor/STM32F1xx_HAL_Driver
MHP30_HAL_INC_DIR=./Core/BSP/MHP30/Vendor/STM32F1xx_HAL_Driver/Inc
MHP30_HAL_LEGACY_INC_DIR=./Core/BSP/MHP30/Vendor/STM32F1xx_HAL_Driver/Inc/Legacy
MHP30_STARTUP_DIR=./Startup
MHP30_INC_DIR=./Core/BSP/MHP30
MHP30_LD_FILE=./Core/BSP/MHP30/stm32f103.ld
PINE_INC_DIR=./Core/BSP/Pinecil
PINE_VENDOR_SRC_DIR=./Core/BSP/Pinecil/Vendor/SoC/gd32vf103/Common/Source
PINE_VENDOR_INC_DIR=./Core/BSP/Pinecil/Vendor/SoC/gd32vf103/Common/Include
PINE_VENDOR_USB_INC_DIR=./Core/BSP/Pinecil/Vendor/SoC/gd32vf103/Common/Include/Usb
PINE_NMSIS_INC_DIR=./Core/BSP/Pinecil/Vendor/NMSIS/Core/Include
PINE_FREERTOS_PORT_INC_DIR=./Core/BSP/Pinecil/Vendor/OS/FreeRTOS/Source/portable/GCC
PINECILV2_DIR=./Core/BSP/Pinecilv2
PINECILV2_MEM_DIR=$(PINECILV2_DIR)/MemMang
PINECILV2_SDK_DIR=$(PINECILV2_DIR)/bl_mcu_sdk
PINECILV2_VENDOR_BSP_DIR=$(PINECILV2_SDK_DIR)/bsp
PINECILV2_VENDOR_BSP_COMMON_DIR=$(PINECILV2_VENDOR_BSP_DIR)/bsp_common
PINECILV2_VENDOR_BSP_BOARD_DIR=$(PINECILV2_VENDOR_BSP_DIR)/board
PINECILV2_VENDOR_BSP_PLATFORM_DIR=$(PINECILV2_VENDOR_BSP_COMMON_DIR)/platform
PINECILV2_VENDOR_BSP_USB_DIR=$(PINECILV2_VENDOR_BSP_COMMON_DIR)/usb
PINECILV2_COMMON_DIR=$(PINECILV2_SDK_DIR)/common
PINECILV2_COMMON_BL_MATH_DIR=$(PINECILV2_COMMON_DIR)/bl_math
PINECILV2_COMMON_DEVICE_DIR=$(PINECILV2_COMMON_DIR)/device
PINECILV2_COMMON_LIST_DIR=$(PINECILV2_COMMON_DIR)/list
PINECILV2_COMMON_MISC_DIR=$(PINECILV2_COMMON_DIR)/misc
PINECILV2_COMMON_PARTITION_DIR=$(PINECILV2_COMMON_DIR)/partition
PINECILV2_COMMON_PID_DIR=$(PINECILV2_COMMON_DIR)/pid
PINECILV2_COMMON_RING_BUFFERDIR=$(PINECILV2_COMMON_DIR)/ring_buffer
PINECILV2_COMMON_SOFT_CRC_DIR=$(PINECILV2_COMMON_DIR)/soft_crc
PINECILV2_COMMON_TIMESTAMP_DIR=$(PINECILV2_COMMON_DIR)/timestamp
PINECILV2_COMPONENTS_DIR=$(PINECILV2_SDK_DIR)/components
PINECILV2_COMPONENTS_FREERTOS_DIR=$(PINECILV2_COMPONENTS_DIR)/freertos
PINECILV2_COMPONENTS_FREERTOS_BL602_DIR=$(PINECILV2_COMPONENTS_FREERTOS_DIR)/portable/gcc/risc-v/bl702
PINECILV2_COMPONENTS_BLE_STACK_PORT_INCLUDE_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/port/include
PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/include
PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_DRIVERS_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/include/drivers
PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_DRIVERS_BLUETOOTH_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/include/drivers/bluetooth
PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_BLUETOOTH_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/include/bluetooth
PINECILV2_COMPONENTS_BLE_STACK_COMMON_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/common
PINECILV2_COMPONENTS_BLE_STACK_COMMON_INCLUDE_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/common/include
PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_MISC_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/common/include/misc
PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_ZEPHYR_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/common/include/zephyr
PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_NET_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/common/include/net
PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_TOOLCHAIN_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/common/include/toolchain
PINECILV2_COMPONENTS_BLE_STACK_TINYCRYPT_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/common/tinycrypt/include
PINECILV2_COMPONENTS_BLE_STACK_TINYCRYPT_INCLUDE_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/common/tinycrypt/include/tinycrypt
PINECILV2_COMPONENTS_BLE_STACK_HOST_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/host
PINECILV2_COMPONENTS_BLE_STACK_BL_HCI_WRAPPER_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/bl_hci_wrapper
PINECILV2_COMPONENTS_BLE_CONTROLLER_BLE_INC_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/blecontroller/ble_inc
PINECILV2_COMPONENTS_BLE_STACK_BC_DEC_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/ble_stack/sbc/dec
# Binary blobs suck and they should be ashamed
PINECILV2_BLE_CRAPWARE_BLOB_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/blecontroller/lib
PINECILV2_RF_CRAPWARE_BLOB_DIR=$(PINECILV2_COMPONENTS_DIR)/ble/bl702_rf/lib
PINECILV2_COMPONENTS_NMSIS_DIR=$(PINECILV2_COMPONENTS_DIR)/nmsis
PINECILV2_COMPONENTS_NMSIS_CORE_INC_DIR=$(PINECILV2_COMPONENTS_NMSIS_DIR)/core/inc
PINECILV2_COMPONENTS_USB_STACK_DIR=$(PINECILV2_COMPONENTS_DIR)/usb_stack
PINECILV2_COMPONENTS_USB_STACK_COMMON_DIR=$(PINECILV2_COMPONENTS_USB_STACK_DIR)/common
PINECILV2_COMPONENTS_USB_STACK_CORE_DIR=$(PINECILV2_COMPONENTS_USB_STACK_DIR)/core
PINECILV2_COMPONENTS_USB_STACK_CDC_DIR=$(PINECILV2_COMPONENTS_USB_STACK_DIR)/class/cdc
PINECILV2_COMPONENTS_USB_STACK_WINUSB_DIR=$(PINECILV2_COMPONENTS_USB_STACK_DIR)/class/winusb
PINECILV2_DRIVERS_DIR=$(PINECILV2_SDK_DIR)/drivers/bl702_driver
PINECILV2_DRIVERS_HAL_DRV_INC_DIR=$(PINECILV2_DRIVERS_DIR)/hal_drv/inc
PINECILV2_DRIVERS_HAL_DRV_DEF_DIR=$(PINECILV2_DRIVERS_DIR)/hal_drv/default_config
PINECILV2_DRIVERS_REGS_DIR=$(PINECILV2_DRIVERS_DIR)/regs
PINECILV2_DRIVERS_RISCV_DIR=$(PINECILV2_DRIVERS_DIR)/risc-v
PINECILV2_DRIVERS_STARTUP_DIR=$(PINECILV2_DRIVERS_DIR)/startup
PINECILV2_DRIVERS_STD_DRV_DIR=$(PINECILV2_DRIVERS_DIR)/std_drv/inc
SOURCE_MIDDLEWARES_DIR=./Middlewares
FRTOS_CMIS_INC_DIR=./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
FRTOS_INC_DIR=./Middlewares/Third_Party/FreeRTOS/Source/include
DRIVER_INC_DIR=./Core/Drivers
BSP_INC_DIR=./Core/BSP
THREADS_INC_DIR=./Core/Threads
THREADS_OP_MODES_INC_DIR=./Core/Threads/OperatingModes
THREADS_OP_MODES_TOOLS_INC_DIR=./Core/Threads/OperatingModes/utils
SOURCE_THREADS_DIR=./Core/Threads
SOURCE_CORE_DIR=./Core/Src
SOURCE_BRIEFLZ_DIR=./Core/brieflz
SOURCE_DRIVERS_DIR=./Core/Drivers
INC_PD_DRIVERS_DIR=./Core/Drivers/usb-pd/include
PD_DRIVER_TESTS_DIR=./Core/Drivers/usb-pd/tests
PD_DRIVER_DIR=./Core/Drivers/usb-pd
# Excludes for clang-format
ALL_INCLUDES_EXCEPT:=-path $(BRIEFLZ_INC_DIR) \
-o -path $(PD_DRIVER_DIR) \
-o -path $(PINECILV2_SDK_DIR) \
-o -path $(DRIVER_INC_DIR) \
-o -path $(MINIWARE_HAL_INC_DIR) \
-o -path $(S60_HAL_INC_DIR) \
-o -path $(MHP30_HAL_INC_DIR) \
-o -path $(PINE_VENDOR_INC_DIR) \
-o -path $(MINIWARE_CMSIS_CORE_INC_DIR) \
-o -path $(S60_CMSIS_CORE_INC_DIR) \
-o -path $(MINIWARE_INC_CMSIS_DEVICE) \
-o -path $(S60_INC_CMSIS_DEVICE) \
-o -path $(MHP30_INC_CMSIS_DEVICE) \
-o -not -name "configuration.h"
ALL_SOURCE_EXCEPT:=-path $(SOURCE_BRIEFLZ_DIR) \
-o -path $(PD_DRIVER_DIR) \
-o -path $(PINECILV2_SDK_DIR) \
-o -path $(SOURCE_DRIVERS_DIR) \
-o -path $(MINIWARE_HAL_SRC_DIR) \
-o -path $(S60_HAL_SRC_DIR) \
-o -path $(MHP30_HAL_SRC_DIR) \
-o -path $(PINE_VENDOR_SRC_DIR) \
-o -path $(PINECILV2_MEM_DIR)
# Find-all's used for formatting; have to exclude external modules
ALL_INCLUDES=$(shell find ./Core -type d \( $(ALL_INCLUDES_EXCEPT) \) -prune -false -o \( -type f \( -name '*.h' -o -name '*.hpp' \) \) )
ALL_SOURCE=$(shell find ./Core -type d \( $(ALL_SOURCE_EXCEPT) \) -prune -false -o \( -type f \( -name '*.c' -o -name '*.cpp' \) \) )
# Device dependent settings
ifeq ($(model),$(filter $(model),$(ALL_MINIWARE_MODELS)))
$(info Building for Miniware )
DEVICE_INCLUDES=-I$(MINIWARE_INC_DIR) \
-I$(MINIWARE_INC_CMSIS_DEVICE) \
-I$(MINIWARE_CMSIS_CORE_INC_DIR) \
-I$(MINIWARE_HAL_INC_DIR) \
-I$(MINIWARE_HAL_LEGACY_INC_DIR)
DEVICE_BSP_DIR=./Core/BSP/Miniware
S_SRCS:=$(shell find $(MINIWARE_STARTUP_DIR) -type f -name '*.S')
LDSCRIPT=$(MINIWARE_LD_FILE)
ifeq ($(model),$(filter $(model),TS101))
flash_size=126k
bootldr_size=0x8000
DEVICE_DFU_ADDRESS=0x08008000
else
flash_size=62k
bootldr_size=0x4000
DEVICE_DFU_ADDRESS=0x08004000
endif
DEV_GLOBAL_DEFS=-D STM32F103T8Ux \
-D STM32F1 \
-D STM32 \
-D USE_HAL_DRIVER \
-D STM32F103xB \
-D USE_RTOS_SYSTICK \
-D GCC_ARMCM3 \
-D ARM_MATH_CM3 \
-D STM32F10X_MD \
-finline-limit=9999999
DEV_LDFLAGS=-Wl,--wrap=printf -Wl,--no-wchar-size-warning
DEV_AFLAGS=
DEV_CFLAGS=-D VECT_TAB_OFFSET=$(bootldr_size)U
DEV_CXXFLAGS=
CPUFLAGS=-mcpu=cortex-m3 \
-mthumb \
-mfloat-abi=soft
DEVICE_DFU_VID_PID=0x1209:0xDB42
endif # ALL_MINIWARE_MODELS
ifeq ($(model),$(filter $(model),$(ALL_SEQURE_MODELS)))
$(info Building for Sequre )
DEVICE_INCLUDES=-I$(S60_INC_DIR) \
-I$(S60_INC_CMSIS_DEVICE) \
-I$(S60_CMSIS_CORE_INC_DIR) \
-I$(S60_HAL_INC_DIR) \
-I$(S60_HAL_LEGACY_INC_DIR)
DEVICE_BSP_DIR=./Core/BSP/Sequre_S60
S_SRCS:=$(shell find $(S60_STARTUP_DIR) -type f -name '*.S')
LDSCRIPT=$(S60_LD_FILE)
DEV_GLOBAL_DEFS=-D STM32F103T8Ux \
-D STM32F1 \
-D STM32 \
-D USE_HAL_DRIVER \
-D STM32F103xB \
-D USE_RTOS_SYSTICK \
-D GCC_ARMCM3 \
-D ARM_MATH_CM3 \
-D STM32F10X_MD \
-finline-limit=9999999
DEV_LDFLAGS=-Wl,--wrap=printf -Wl,--no-wchar-size-warning
DEV_AFLAGS=
DEV_CFLAGS=-D VECT_TAB_OFFSET=$(bootldr_size)U
DEV_CXXFLAGS=
CPUFLAGS=-mcpu=cortex-m3 \
-mthumb \
-mfloat-abi=soft
flash_size=62k
bootldr_size=0x4400
DEVICE_DFU_ADDRESS=0x08004400
DEVICE_DFU_VID_PID=0x1209:0xDB42
endif # ALL_SEQURE_MODELS
ifeq ($(model),$(filter $(model),$(ALL_MHP30_MODELS)))
$(info Building for MHP30 )
DEVICE_INCLUDES=-I$(MHP30_INC_DIR) \
-I$(MHP30_INC_CMSIS_DEVICE) \
-I$(MHP30_CMSIS_CORE_INC_DIR) \
-I$(MHP30_HAL_INC_DIR) \
-I$(MHP30_HAL_LEGACY_INC_DIR)
DEVICE_BSP_DIR=./Core/BSP/MHP30
S_SRCS:=$(shell find $(MHP30_STARTUP_DIR) -type f -name '*.S')
LDSCRIPT=$(MHP30_LD_FILE)
DEV_GLOBAL_DEFS=-D STM32F103T8Ux \
-D STM32F1 \
-D STM32 \
-D USE_HAL_DRIVER \
-D STM32F103xB \
-D USE_RTOS_SYSTICK \
-D GCC_ARMCM3 \
-D ARM_MATH_CM3 \
-D STM32F10X_MD
DEV_LDFLAGS=
DEV_AFLAGS=
DEV_CFLAGS=-D VECT_TAB_OFFSET=$(bootldr_size)U
DEV_CXXFLAGS=
CPUFLAGS=-mcpu=cortex-m3 \
-mthumb \
-mfloat-abi=soft
flash_size=126k
bootldr_size=32k
DEVICE_DFU_ADDRESS=0x08008000
DEVICE_DFU_VID_PID=0x1209:0xDB42
endif # ALL_MHP30_MODELS
ifeq ($(model),$(ALL_PINECIL_MODELS))
$(info Building for Pine64 Pinecilv1)
DEVICE_INCLUDES=-I$(PINE_INC_DIR) \
-I$(PINE_VENDOR_INC_DIR) \
-I$(PINE_VENDOR_USB_INC_DIR) \
-I$(PINE_NMSIS_INC_DIR) \
-I$(PINE_FREERTOS_PORT_INC_DIR)
DEVICE_BSP_DIR=./Core/BSP/Pinecil
S_SRCS:=$(shell find $(PINE_INC_DIR) -type f -name '*.S') $(info $(S_SRCS) )
ASM_INC=-I$(PINE_RISCV_INC_DIR)
LDSCRIPT=./Core/BSP/Pinecil/Vendor/SoC/gd32vf103/Board/pinecil/Source/GCC/gcc_gd32vf103_flashxip.ld
flash_size=128k
bootldr_size=0x0
# Flags
CPUFLAGS=-march=rv32imac \
-mabi=ilp32 \
-mcmodel=medany \
-fsigned-char \
-fno-builtin \
-nostartfiles
DEV_LDFLAGS=-nostartfiles
DEV_AFLAGS=
DEV_GLOBAL_DEFS=-DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP
DEV_CFLAGS=-D VECT_TAB_OFFSET=$(bootldr_size)U
DEV_CXXFLAGS=
endif # ALL_PINECIL_MODELS
ifeq ($(model),$(ALL_PINECIL_V2_MODELS))
$(info Building for Pine64 Pinecilv2 )
DEVICE_INCLUDES=-I$(PINECILV2_DIR) \
-I$(PINECILV2_SDK_DIR) \
-I$(PINECILV2_VENDOR_BSP_COMMON_DIR) \
-I$(PINECILV2_VENDOR_BSP_PLATFORM_DIR) \
-I$(PINECILV2_COMMON_DIR) \
-I$(PINECILV2_COMMON_BL_MATH_DIR) \
-I$(PINECILV2_COMMON_DEVICE_DIR) \
-I$(PINECILV2_COMMON_LIST_DIR) \
-I$(PINECILV2_COMMON_MISC_DIR) \
-I$(PINECILV2_COMMON_PARTITION_DIR) \
-I$(PINECILV2_COMMON_PID_DIR) \
-I$(PINECILV2_COMMON_RING_BUFFERDIR) \
-I$(PINECILV2_COMMON_SOFT_CRC_DIR) \
-I$(PINECILV2_COMMON_TIMESTAMP_DIR) \
-I$(PINECILV2_COMPONENTS_DIR) \
-I$(PINECILV2_COMPONENTS_FREERTOS_DIR) \
-I$(PINECILV2_COMPONENTS_FREERTOS_BL602_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_DRIVERS_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_DRIVERS_BLUETOOTH_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_PORT_INCLUDE_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_BLUETOOTH_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_COMMON_INCLUDE_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_COMMON_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_MISC_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_ZEPHYR_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_NET_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_TOOLCHAIN_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_INCLUDE_TOOLCHAIN_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_TINYCRYPT_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_TINYCRYPT_INCLUDE_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_HOST_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_BL_HCI_WRAPPER_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_CONTROLLER_BLE_INC_DIR) \
-I$(PINECILV2_COMPONENTS_BLE_STACK_BC_DEC_DIR) \
-I$(PINECILV2_COMPONENTS_NMSIS_DIR) \
-I$(PINECILV2_COMPONENTS_USB_STACK_DIR) \
-I$(PINECILV2_DRIVERS_DIR) \
-I$(PINECILV2_DRIVERS_HAL_DRV_INC_DIR) \
-I$(PINECILV2_DRIVERS_HAL_DRV_DEF_DIR) \
-I$(PINECILV2_DRIVERS_REGS_DIR) \
-I$(PINECILV2_DRIVERS_RISCV_DIR) \
-I$(PINECILV2_DRIVERS_STARTUP_DIR) \
-I$(PINECILV2_DRIVERS_STD_DRV_DIR) \
-I$(PINECILV2_VENDOR_BSP_PLATFORM_DIR) \
-I$(PINECILV2_VENDOR_BSP_USB_DIR) \
-I$(PINECILV2_COMPONENTS_USB_STACK_COMMON_DIR) \
-I$(PINECILV2_COMPONENTS_USB_STACK_CORE_DIR) \
-I$(PINECILV2_COMPONENTS_USB_STACK_CDC_DIR) \
-I$(PINECILV2_COMPONENTS_USB_STACK_WINUSB_DIR) \
-I$(PINECILV2_COMPONENTS_NMSIS_CORE_INC_DIR)
DEVICE_BSP_DIR=./Core/BSP/Pinecilv2
S_SRCS:=$(shell find $(PINECILV2_DIR) -type d \( -path $(PINECILV2_VENDOR_BSP_COMMON_DIR) \) -prune -false -o -type f -name '*.S') $(info $(S_SRCS) )
ASM_INC=$(DEVICE_INCLUDES)
LDSCRIPT=./Core/BSP/Pinecilv2/bl_mcu_sdk/drivers/bl702_driver/bl702_flash.ld
# Flags
CPUFLAGS=-march=rv32imafc \
-mabi=ilp32f \
-mcmodel=medany \
-fsigned-char \
-fno-builtin \
-nostartfiles \
-DportasmHANDLE_INTERRUPT=FreeRTOS_Interrupt_Handler \
-DARCH_RISCV \
-D__RISCV_FEATURE_MVE=0 \
-DBL702 \
-DBFLB_USE_ROM_DRIVER=1 \
DEV_LDFLAGS=-nostartfiles \
-L $(PINECILV2_BLE_CRAPWARE_BLOB_DIR) \
-L $(PINECILV2_RF_CRAPWARE_BLOB_DIR) \
-l blecontroller_702_m0s1s \
-l bl702_rf
DEV_AFLAGS=
DEV_GLOBAL_DEFS=-DCFG_FREERTOS \
-DARCH_RISCV \
-DBL702 \
-DCFG_BLE_ENABLE \
-DBFLB_BLE \
-DCFG_BLE \
-DOPTIMIZE_DATA_EVT_FLOW_FROM_CONTROLLER \
-DBL_MCU_SDK \
-DCFG_CON=2 \
-DCFG_BLE_TX_BUFF_DATA=2 \
-DCONFIG_BT_PERIPHERAL \
-DCONFIG_BT_L2CAP_DYNAMIC_CHANNEL \
-DCONFIG_BT_GATT_CLIENT \
-DCONFIG_BT_CONN \
-DCONFIG_BT_GATT_DIS_PNP \
-DCONFIG_BT_GATT_DIS_SERIAL_NUMBER \
-DCONFIG_BT_GATT_DIS_FW_REV \
-DCONFIG_BT_GATT_DIS_HW_REV \
-DCONFIG_BT_GATT_DIS_SW_REV \
-DCONFIG_BT_ECC \
-DCONFIG_BT_GATT_DYNAMIC_DB \
-DCONFIG_BT_GATT_SERVICE_CHANGED \
-DCONFIG_BT_KEYS_OVERWRITE_OLDEST \
-DCONFIG_BT_KEYS_SAVE_AGING_COUNTER_ON_PAIRING \
-DCONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS \
-DCONFIG_BT_BONDABLE \
-DCONFIG_BT_HCI_VS_EVT_USER \
-DCONFIG_BT_ASSERT \
-DCONFIG_BT_SIGNING \
-DCONFIG_BT_SETTINGS_CCC_LAZY_LOADING \
-DCONFIG_BT_SETTINGS_USE_PRINTK \
-DCFG_SLEEP \
-DCONFIG_BT_ALLROLES \
-DCONFIG_BT_CENTRAL \
-DCONFIG_BT_OBSERVER \
-DCONFIG_BT_BROADCASTER \
-DCFG_BLE_STACK_DBG_PRINT \
-DportasmHANDLE_INTERRUPT=FreeRTOS_Interrupt_Handler \
-DCONFIG_BT_DEVICE_NAME=\"Pinecil\" \
-DCONFIG_BT_DEVICE_APPEARANCE=0x06C1
# -DBFLB_USE_HAL_DRIVER \
# -DCONFIG_BT_SMP
# Required to be turned off due to their drivers tripping warnings
DEV_CFLAGS= -Wno-error=enum-conversion -Wno-type-limits -Wno-implicit-fallthrough
DEV_CXXFLAGS= $(DEV_CFLAGS)
flash_size=128k
bootldr_size=0x0
endif # ALL_PINECIL_V2_MODELS
INCLUDES=-I$(APP_INC_DIR) \
-I$(BRIEFLZ_INC_DIR) \
-I$(FRTOS_CMIS_INC_DIR) \
-I$(FRTOS_INC_DIR) \
-I$(DRIVER_INC_DIR) \
-I$(BSP_INC_DIR) \
-I$(THREADS_INC_DIR) \
-I$(THREADS_OP_MODES_INC_DIR) \
-I$(THREADS_OP_MODES_TOOLS_INC_DIR) \
-I$(INC_PD_DRIVERS_DIR) \
$(DEVICE_INCLUDES)
EXCLUDED_DIRS:=-path $(PINECILV2_VENDOR_BSP_ES8388_DIR) \
-o -path $(PINECILV2_VENDOR_BSP_IMAGE_SENSOR_DIR) \
-o -path $(PINECILV2_VENDOR_BSP_LVGL_DIR) \
-o -path $(PINECILV2_VENDOR_BSP_MCU_LCD_DIR) \
-o -path $(PINECILV2_VENDOR_BSP_BOARD_DIR) \
-o -path $(PINECILV2_VENDOR_BSP_USB_DIR)
SOURCE:=$(shell find $(SOURCE_THREADS_DIR) -type f -name '*.c') \
$(shell find $(SOURCE_CORE_DIR) -type f -name '*.c') \
$(shell find $(SOURCE_DRIVERS_DIR) -type f -name '*.c') \
$(shell find $(DEVICE_BSP_DIR) -type d \( $(EXCLUDED_DIRS) \) -prune -false -o -type f -name '*.c') \
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.c') \
$(SOURCE_BRIEFLZ_DIR)/depack.c
# We exclude the USB-PD stack tests $(PD_DRIVER_TESTS_DIR)
SOURCE_CPP:=$(shell find $(SOURCE_THREADS_DIR) -type f -name '*.cpp') \
$(shell find $(SOURCE_CORE_DIR) -type f -name '*.cpp') \
$(shell find $(SOURCE_DRIVERS_DIR) -path $(PD_DRIVER_TESTS_DIR) -prune -false -o -type f -name '*.cpp') \
$(shell find $(DEVICE_BSP_DIR) -type d \( $(EXCLUDED_DIRS) \) -prune -false -o -type f -name '*.cpp') \
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp')
# Code optimisation ------------------------------------------------------------
OPTIM=-Os \
-fno-jump-tables \
-foptimize-strlen \
-faggressive-loop-optimizations \
-fdevirtualize-at-ltrans \
-fmerge-all-constants \
-fshort-wchar \
-flto \
-finline-small-functions \
-finline-functions \
-findirect-inlining \
-fdiagnostics-color \
-ffunction-sections \
-fdata-sections \
-fshort-enums \
-fsingle-precision-constant \
-fno-common \
-fno-math-errno \
-ffast-math \
-ffinite-math-only \
-fno-signed-zeros \
-fsingle-precision-constant
# Global defines ---------------------------------------------------------------
GLOBAL_DEFINES+=$(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U -fshort-wchar
ifdef swd_enable
GLOBAL_DEFINES+=-DSWD_ENABLE
endif
# Libs -------------------------------------------------------------------------
LIBS=
# Compilers --------------------------------------------------------------------
COMPILER=gcc
# arm-none-eabi is the general ARM compiler
# riscv-none-embed is the riscv compiler
# riscv-nuclei-elf is the nuclei tuned one for their cores
ifeq ($(model),$(filter $(model),$(ALL_MINIWARE_MODELS) $(ALL_MHP30_MODELS)))
COMPILER_PREFIX=arm-none-eabi
endif
ifeq ($(model),$(filter $(model),$(ALL_SEQURE_MODELS) ))
COMPILER_PREFIX=arm-none-eabi
endif
ifeq ($(model),$(filter $(model),$(ALL_PINECIL_MODELS) $(ALL_PINECIL_V2_MODELS)))
COMPILER_PREFIX=riscv-none-elf
endif
# Programs ---------------------------------------------------------------------
CC=$(COMPILER_PREFIX)-gcc
CPP=$(COMPILER_PREFIX)-g++
OBJCOPY=$(COMPILER_PREFIX)-objcopy
SIZE=$(COMPILER_PREFIX)-size
OBJDUMP=$(COMPILER_PREFIX)-objdump
# Use gcc in assembler mode so we can use defines etc in assembly
AS=$(COMPILER_PREFIX)-gcc -x assembler-with-cpp
# Linker flags -----------------------------------------------------------------
LINKER_FLAGS=-Wl,--gc-sections \
-Wl,--wrap=malloc \
-Wl,--wrap=free \
-Wl,--undefined=vTaskSwitchContext \
-Wl,--undefined=pxCurrentTCB \
-Wl,--defsym=__FLASH_SIZE__=$(flash_size) \
-Wl,--defsym=__BOOTLDR_SIZE__=$(bootldr_size) \
-Wl,--print-memory-usage \
--specs=nosys.specs \
--specs=nano.specs \
$(DEV_LDFLAGS)
# Compiler flags ---------------------------------------------------------------
CHECKOPTIONS=-Wtrigraphs \
-Wuninitialized \
-Wmissing-braces \
-Wfloat-equal \
-Wunreachable-code \
-Wswitch-default \
-Wreturn-type \
-Wundef \
-Wparentheses \
-Wnonnull \
-Winit-self \
-Wmissing-include-dirs \
-Wsequence-point \
-Wswitch \
-Wformat \
-Wsign-compare \
-Waddress \
-Waggregate-return \
-Wmissing-field-initializers \
-Wshadow \
-Wno-unused-parameter \
-Wdouble-promotion
CHECKOPTIONS_C=$(CHECKOPTIONS) -Wbad-function-cast
CXXFLAGS=$(DEV_CXXFLAGS) \
$(CPUFLAGS) \
$(INCLUDES) \
$(GLOBAL_DEFINES) \
-D${COMPILER} \
-MMD \
$(CHECKOPTIONS) \
-std=c++17 \
$(OPTIM) \
-fno-rtti \
-fno-exceptions \
-fno-non-call-exceptions \
-fno-use-cxa-atexit \
-fno-strict-aliasing \
-fno-threadsafe-statics \
-T$(LDSCRIPT)
CFLAGS=$(DEV_CFLAGS) \
$(CPUFLAGS) \
$(INCLUDES) \
$(CHECKOPTIONS_C) \
$(GLOBAL_DEFINES) \
-D${COMPILER} \
-MMD \
-std=gnu11 \
$(OPTIM) \
-T$(LDSCRIPT) \
-c
AFLAGS=$(CPUFLAGS) \
$(DEV_AFLAGS) \
$(GLOBAL_DEFINES) \
$(OPTIM) \
$(ASM_INC) \
$(INCLUDES)
OBJS=$(SOURCE:.c=.o)
OBJS_CPP=$(SOURCE_CPP:.cpp=.o)
OBJS_S=$(S_SRCS:.S=.o)
OUT_OBJS=$(addprefix $(OUTPUT_DIR)/,$(OBJS))
OUT_OBJS_CPP=$(addprefix $(OUTPUT_DIR)/,$(OBJS_CPP))
OUT_OBJS_S=$(addprefix $(OUTPUT_DIR)/,$(OBJS_S))
default: firmware-EN
firmware-%: $(HEXFILE_DIR)/$(model)_%.hex $(HEXFILE_DIR)/$(model)_%.bin $(HEXFILE_DIR)/$(model)_%.dfu
@true
# Targets for binary files
%.hex: %.elf Makefile
$(OBJCOPY) $< -O ihex $@
%.bin: %.elf Makefile
$(OBJCOPY) $< -O binary $@
$(SIZE) $<
%.dfu: %.bin Makefile
$(HOST_PYTHON) dfuse-pack.py -b $(DEVICE_DFU_ADDRESS)@0:$< -D $(DEVICE_DFU_VID_PID) $@
$(HEXFILE_DIR)/$(model)_%.elf: \
$(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) \
$(OUTPUT_DIR)/Core/Gen/Translation.%.o \
$(OUTPUT_DIR)/Core/LangSupport/lang_single.o \
Makefile $(LDSCRIPT)
@test -d $(@D) || mkdir -p $(@D)
@echo Linking $@
@$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) \
$(OUTPUT_DIR)/Core/Gen/Translation.$*.o \
$(OUTPUT_DIR)/Core/LangSupport/lang_single.o \
$(LIBS) $(LINKER_FLAGS) -o$@ -Wl,-Map=$@.map
$(HEXFILE_DIR)/$(model)_string_compressed_%.elf: \
$(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) \
$(OUTPUT_DIR)/Core/Gen/Translation_brieflz.%.o \
$(OUTPUT_DIR)/Core/LangSupport/lang_single.o \
Makefile $(LDSCRIPT)
@test -d $(@D) || mkdir -p $(@D)
@echo Linking $@
@$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) \
$(OUTPUT_DIR)/Core/Gen/Translation_brieflz.$*.o \
$(OUTPUT_DIR)/Core/LangSupport/lang_single.o \
$(LIBS) $(LINKER_FLAGS) -o$@ -Wl,-Map=$@.map
$(HEXFILE_DIR)/$(model)_font_compressed_%.elf: \
$(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) \
$(OUTPUT_DIR)/Core/Gen/Translation_brieflz_font.%.o \
$(OUTPUT_DIR)/Core/LangSupport/lang_single.o \
Makefile $(LDSCRIPT)
@test -d $(@D) || mkdir -p $(@D)
@echo Linking $@
@$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) \
$(OUTPUT_DIR)/Core/Gen/Translation_brieflz_font.$*.o \
$(OUTPUT_DIR)/Core/LangSupport/lang_single.o \
$(LIBS) $(LINKER_FLAGS) -o$@ -Wl,-Map=$@.map
$(OUT_OBJS): $(OUTPUT_DIR)/%.o: %.c Makefile
@test -d $(@D) || mkdir -p $(@D)
@$(CC) -c $(CFLAGS) $< -o $@
$(OUTPUT_DIR)/%.o: %.cpp Makefile
@test -d $(@D) || mkdir -p $(@D)
@$(CPP) -c $(CXXFLAGS) $< -o $@
$(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.S Makefile
@test -d $(@D) || mkdir -p $(@D)
@echo 'Building file: $<'
@$(AS) -c $(AFLAGS) $< -o $@
Core/Gen/Translation.%.cpp $(OUTPUT_DIR)/Core/Gen/translation.files/%.pickle: ../Translations/translation_%.json \
../Translations/make_translation.py \
../Translations/translations_definitions.json \
../Translations/font_tables.py \
Makefile ../Translations/wqy-bitmapsong/wenquanyi_9pt.bdf \
Core/Gen/macros.txt
@test -d Core/Gen || mkdir -p Core/Gen
@test -d $(OUTPUT_DIR)/Core/Gen/translation.files || mkdir -p $(OUTPUT_DIR)/Core/Gen/translation.files
@echo 'Generating translations for language $*'
@$(HOST_PYTHON) ../Translations/make_translation.py \
--macros $(CURDIR)/Core/Gen/macros.txt \
-o $(CURDIR)/Core/Gen/Translation.$*.cpp \
--output-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/$*.pickle \
$*
Core/Gen/macros.txt: Makefile
@test -d $(CURDIR)/Core/Gen || mkdir -p $(CURDIR)/Core/Gen
echo "#include <configuration.h>" | $(CC) -dM -E $(CFLAGS) -MF $(CURDIR)/Core/Gen/macros.tmp - > $(CURDIR)/Core/Gen/macros.txt
# The recipes to produce compressed translation data
$(OUTPUT_DIR)/Core/Gen/translation.files/%.o: Core/Gen/Translation.%.cpp
@test -d $(@D) || mkdir -p $(@D)
@echo Generating $@
@$(CPP) -c $(filter-out -flto ,$(CXXFLAGS)) $< -o $@
$(OUTPUT_DIR)/Core/Gen/translation.files/multi.%.o: Core/Gen/Translation_multi.%.cpp
@test -d $(@D) || mkdir -p $(@D)
@echo Generating $@
@$(CPP) -c $(filter-out -flto ,$(CXXFLAGS)) $< -o $@
$(HOST_OUTPUT_DIR)/brieflz/libbrieflz.so: Core/brieflz/brieflz.c Core/brieflz/depack.c
@test -d $(@D) || mkdir -p $(@D)
@echo Building host brieflz shared library $@
@$(HOST_CC) -fPIC -shared -DBLZ_DLL -DBLZ_DLL_EXPORTS -O $^ -o $@
Core/Gen/Translation_brieflz.%.cpp: $(OUTPUT_DIR)/Core/Gen/translation.files/%.o $(OUTPUT_DIR)/Core/Gen/translation.files/%.pickle $(HOST_OUTPUT_DIR)/brieflz/libbrieflz.so Core/Gen/macros.txt
@test -d $(@D) || mkdir -p $(@D)
@echo Generating BriefLZ compressed translation for $*
@OBJCOPY=$(OBJCOPY) $(HOST_PYTHON) ../Translations/make_translation.py \
--macros $(PWD)/Core/Gen/macros.txt \
-o $(PWD)/Core/Gen/Translation_brieflz.$*.cpp \
--input-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/$*.pickle \
--strings-obj $(OUTPUT_DIR)/Core/Gen/translation.files/$*.o \
$*
Core/Gen/Translation_brieflz_font.%.cpp: $(OUTPUT_DIR)/Core/Gen/translation.files/%.pickle $(HOST_OUTPUT_DIR)/brieflz/libbrieflz.so Core/Gen/macros.txt
@test -d $(@D) || mkdir -p $(@D)
@echo Generating BriefLZ compressed translation for $*
@$(HOST_PYTHON) ../Translations/make_translation.py \
--macros $(PWD)/Core/Gen/macros.txt \
-o $(PWD)/Core/Gen/Translation_brieflz_font.$*.cpp \
--input-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/$*.pickle \
--compress-font \
$*
# The recipes to produce multi-language firmwares:
# Usage: $(eval $(call multi_lang_rule,$(1)=group_code,$(2)=group_name,$(3)=lang_codes))
define multi_lang_rule
$(HEXFILE_DIR)/$(model)_multi_$(2).elf: \
$(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) \
$(OUTPUT_DIR)/Core/Gen/Translation_multi.$(1).o \
$(OUTPUT_DIR)/Core/LangSupport/lang_multi.o \
Makefile $(LDSCRIPT)
@test -d $$(@D) || mkdir -p $$(@D)
@echo Linking $$@
@$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) \
$(OUTPUT_DIR)/Core/Gen/Translation_multi.$(1).o \
$(OUTPUT_DIR)/Core/LangSupport/lang_multi.o \
$(LIBS) $(LINKER_FLAGS) -o$$@ -Wl,-Map=$$@.map
$(HEXFILE_DIR)/$(model)_multi_compressed_$(2).elf: \
$(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) \
$(OUTPUT_DIR)/Core/Gen/Translation_brieflz_multi.$(1).o \
$(OUTPUT_DIR)/Core/LangSupport/lang_multi.o \
Makefile $(LDSCRIPT)
@test -d $$(@D) || mkdir -p $$(@D)
@echo Linking $$@
@$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) \
$(OUTPUT_DIR)/Core/Gen/Translation_brieflz_multi.$(1).o \
$(OUTPUT_DIR)/Core/LangSupport/lang_multi.o \
$(LIBS) $(LINKER_FLAGS) -o$$@ -Wl,-Map=$$@.map
Core/Gen/Translation_multi.$(1).cpp: $(patsubst %,../Translations/translation_%.json,$(3)) \
../Translations/make_translation.py \
../Translations/translations_definitions.json \
../Translations/font_tables.py \
Makefile ../Translations/wqy-bitmapsong/wenquanyi_9pt.bdf \
Core/Gen/macros.txt
@test -d Core/Gen || mkdir -p Core/Gen
@test -d $(OUTPUT_DIR)/Core/Gen/translation.files || mkdir -p $(OUTPUT_DIR)/Core/Gen/translation.files
@echo 'Generating translations for multi-language $(2)'
@$(HOST_PYTHON) ../Translations/make_translation.py \
--macros $(PWD)/Core/Gen/macros.txt \
-o $(PWD)/Core/Gen/Translation_multi.$(1).cpp \
--output-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).pickle \
$(3)
$(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).pickle: Core/Gen/Translation_multi.$(1).cpp
Core/Gen/Translation_brieflz_multi.$(1).cpp: $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).o $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).pickle $(HOST_OUTPUT_DIR)/brieflz/libbrieflz.so Core/Gen/macros.txt
@test -d $$(@D) || mkdir -p $$(@D)
@echo Generating BriefLZ compressed translation for multi-language $(2)
@OBJCOPY=$(OBJCOPY) $(HOST_PYTHON) ../Translations/make_translation.py \
--macros $(PWD)/Core/Gen/macros.txt \
-o $(PWD)/Core/Gen/Translation_brieflz_multi.$(1).cpp \
--input-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).pickle \
--strings-obj $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).o \
--compress-font \
$(3)
endef # multi_lang_rule
# Add multi-language firmware rules:
$(foreach group_code,$(LANGUAGE_GROUPS),$(eval $(call multi_lang_rule,$(group_code),$(LANGUAGE_GROUP_$(group_code)_NAME),$(LANGUAGE_GROUP_$(group_code)_LANGS))))
# Clean up targets
clean:
rm -Rf Core/Gen
rm -Rf $(OUTPUT_DIR_BASE)
rm -Rf $(HEXFILE_DIR)/*
rm -Rf ../Translations/__pycache__
clean-all: clean
rm -Rf $(HEXFILE_DIR)
# Code style checks using clang-format
# Show only list of affected files for debug purposes
check-style-list:
@ret=0; for src in $(ALL_SOURCE) $(ALL_INCLUDES) ; do \
var=`clang-format "$$src" | diff "$$src" - | wc -l` ; \
if [ $$var -ne 0 ] ; then \
echo "$$src" ; \
ret=1; test -n "$(STOP)" && break; \
fi ; \
grep -H -n -e "^ .*if .*)$$" -e "^ .*else$$" -e "^ .* do$$" -e "^ .*while .*)$$" -e "^ .*for .*)$$" "$$src" | grep -v -e "^.*//" -e "^.*:.*: .*if ((.*[^)])$$" | sed 's,^,\n\n,; s,: ,:1: error: probably missing { or } for conditional or loop block:\n>>>,;' | grep -q -e "^.*$$" ; \
if [ "$$?" -ne 1 ]; then \
echo "$$src" ; \
ret=1; test -n "$(STOP)" && break; \
fi ; \
done ; \
if [ $$ret -eq 0 ] ; then \
echo "Style check: PASS" && exit 0 ; \
else \
echo "Style check: FAIL!" && echo "Please, check the log above for the details." && exit 1 ; \
fi ;
# Show output in gcc-like error compatible format for IDEs/editors; call `make check-style STOP=1` to exit after first failed file
# NOTICE:
# - clang-format has neat option for { } in condition blocks but it's available only since version 15:
# * https://clang.llvm.org/docs/ClangFormatStyleOptions.html#insertbraces
# - grep block in the middle used to trace missing { and } for if/else BUT IT'S VERY SPECULATIVE, very-very hacky & dirty
check-style:
@ret=0; for src in $(ALL_SOURCE) $(ALL_INCLUDES) ; do \
var=`clang-format "$$src" | diff "$$src" - | wc -l` ; \
if [ $$var -ne 0 ] ; then \
clang-format "$$src" | diff "$$src" - | sed 's/^---/-------------------------------------------------------------------------------/; s/^< /--- /; s/^> /+++ /; /^[0-9].*/ s/[acd,].*$$/ERROR1/; /^[0-9].*/ s,^,\n\n\n\n'"$$src"':,; /ERROR1$$/ s,ERROR1$$,:1: error: clang-format code style mismatch:,; ' ; \
ret=1; test -n "$(STOP)" && break; \
fi ; \
grep -H -n -e "^ .*if .*)$$" -e "^ .*else$$" -e "^ .* do$$" -e "^ .*while .*)$$" -e "^ .*for .*)$$" "$$src" | grep -v -e "^.*//" -e "^.*:.*: .*if ((.*[^)])$$" | sed 's,^,\n\n,; s,: ,:1: error: probably missing { or } for conditional or loop block:\n>>>,;' | grep -e "^.*$$" ; \
if [ "$$?" -ne 1 ]; then \
ret=1; test -n "$(STOP)" && break; \
fi ; \
done ; \
if [ $$ret -eq 0 ] ; then \
echo "Style check: PASS" && exit 0 ; \
else \
echo "Style check: FAIL!" && echo "Please, check the log above for the details." && exit 1 ; \
fi ;
.PHONY: check-style-list check-style all clean default clean-all
.SECONDARY:
# Pull in dependency info for *existing* .o files
-include $(OUT_OBJS:.o=.d)
-include $(OUT_OBJS_CPP:.o=.d)
-include $(OUTPUT_DIR)/Core/Gen/Translation.*.d
-include $(OUTPUT_DIR)/Core/Gen/Translation_*.d
-include $(OUTPUT_DIR)/Core/Gen/translation.files/*.d