Add in-flight adjustments support for feedforward terms
[betaflight.git] / make / targets.mk
blob807bd9f1254f563472a4aaba2f4fabaa7bf51919
1 OFFICIAL_TARGETS = ALIENFLIGHTF3 ALIENFLIGHTF4 ANYFCF7 BETAFLIGHTF3 BLUEJAYF4 FURYF4 REVO SIRINFPV SPARKY SPRACINGF3 SPRACINGF3EVO SPRACINGF3NEO SPRACINGF4EVO SPRACINGF7DUAL STM32F3DISCOVERY
2 ALT_TARGETS = $(sort $(filter-out target, $(basename $(notdir $(wildcard $(ROOT)/src/main/target/*/*.mk)))))
3 NOBUILD_TARGETS = $(sort $(filter-out target, $(basename $(notdir $(wildcard $(ROOT)/src/main/target/*/*.nomk)))))
4 OPBL_TARGETS = $(filter %_OPBL, $(ALT_TARGETS))
5 OSD_SLAVE_TARGETS = SPRACINGF3OSD
7 VALID_TARGETS = $(dir $(wildcard $(ROOT)/src/main/target/*/target.mk))
8 VALID_TARGETS := $(subst /,, $(subst ./src/main/target/,, $(VALID_TARGETS)))
9 VALID_TARGETS := $(VALID_TARGETS) $(ALT_TARGETS)
10 VALID_TARGETS := $(sort $(VALID_TARGETS))
11 VALID_TARGETS := $(filter-out $(NOBUILD_TARGETS), $(VALID_TARGETS))
13 ifeq ($(filter $(TARGET),$(NOBUILD_TARGETS)), $(TARGET))
14 ALTERNATES := $(sort $(filter-out target, $(basename $(notdir $(wildcard $(ROOT)/src/main/target/$(TARGET)/*.mk)))))
15 $(error The target specified, $(TARGET), cannot be built. Use one of the ALT targets: $(ALTERNATES))
16 endif
18 UNSUPPORTED_TARGETS := \
19 AFROMINI \
20 ALIENFLIGHTF1 \
21 BEEBRAIN \
22 CC3D \
23 CC3D_OPBL \
24 CJMCU \
25 MICROSCISKY \
26 NAZE
28 SUPPORTED_TARGETS := $(filter-out $(UNSUPPORTED_TARGETS), $(VALID_TARGETS))
30 TARGETS_TOTAL := $(words $(SUPPORTED_TARGETS))
31 TARGET_GROUPS := 5
32 TARGETS_PER_GROUP := $(shell expr $(TARGETS_TOTAL) / $(TARGET_GROUPS) )
34 ST := 1
35 ET := $(shell expr $(ST) + $(TARGETS_PER_GROUP))
36 GROUP_1_TARGETS := $(wordlist $(ST), $(ET), $(SUPPORTED_TARGETS))
38 ST := $(shell expr $(ET) + 1)
39 ET := $(shell expr $(ST) + $(TARGETS_PER_GROUP))
40 GROUP_2_TARGETS := $(wordlist $(ST), $(ET), $(SUPPORTED_TARGETS))
42 ST := $(shell expr $(ET) + 1)
43 ET := $(shell expr $(ST) + $(TARGETS_PER_GROUP))
44 GROUP_3_TARGETS := $(wordlist $(ST), $(ET), $(SUPPORTED_TARGETS))
46 ST := $(shell expr $(ET) + 1)
47 ET := $(shell expr $(ST) + $(TARGETS_PER_GROUP))
48 GROUP_4_TARGETS := $(wordlist $(ST), $(ET), $(SUPPORTED_TARGETS))
50 GROUP_OTHER_TARGETS := $(filter-out $(GROUP_1_TARGETS) $(GROUP_2_TARGETS) $(GROUP_3_TARGETS) $(GROUP_4_TARGETS), $(SUPPORTED_TARGETS))
52 ifeq ($(filter $(TARGET),$(ALT_TARGETS)), $(TARGET))
53 BASE_TARGET := $(firstword $(subst /,, $(subst ./src/main/target/,, $(dir $(wildcard $(ROOT)/src/main/target/*/$(TARGET).mk)))))
54 include $(ROOT)/src/main/target/$(BASE_TARGET)/$(TARGET).mk
55 else
56 BASE_TARGET := $(TARGET)
57 endif
59 ifeq ($(filter $(TARGET),$(OPBL_TARGETS)), $(TARGET))
60 OPBL = yes
61 endif
63 ifeq ($(filter $(TARGET),$(OSD_SLAVE_TARGETS)), $(TARGET))
64 # build an OSD SLAVE
65 OSD_SLAVE = yes
66 else
67 # build an FC
68 FC = yes
69 endif
71 # silently ignore if the file is not present. Allows for target specific.
72 -include $(ROOT)/src/main/target/$(BASE_TARGET)/target.mk
74 F4_TARGETS := $(F405_TARGETS) $(F411_TARGETS) $(F446_TARGETS)
75 F7_TARGETS := $(F7X2RE_TARGETS) $(F7X5XE_TARGETS) $(F7X5XG_TARGETS) $(F7X5XI_TARGETS) $(F7X6XG_TARGETS)
77 ifeq ($(filter $(TARGET),$(VALID_TARGETS)),)
78 $(error Target '$(TARGET)' is not valid, must be one of $(VALID_TARGETS). Have you prepared a valid target.mk?)
79 endif
81 ifeq ($(filter $(TARGET),$(F1_TARGETS) $(F3_TARGETS) $(F4_TARGETS) $(F7_TARGETS) $(SITL_TARGETS)),)
82 $(error Target '$(TARGET)' has not specified a valid STM group, must be one of F1, F3, F405, F411 or F7x5. Have you prepared a valid target.mk?)
83 endif
85 ifeq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS)))
86 TARGET_MCU := STM32F3
88 else ifeq ($(TARGET),$(filter $(TARGET), $(F4_TARGETS)))
89 TARGET_MCU := STM32F4
91 else ifeq ($(TARGET),$(filter $(TARGET), $(F7_TARGETS)))
92 TARGET_MCU := STM32F7
94 else ifeq ($(TARGET),$(filter $(TARGET), $(SITL_TARGETS)))
95 TARGET_MCU := SITL
96 SIMULATOR_BUILD = yes
98 else ifeq ($(TARGET),$(filter $(TARGET), $(F1_TARGETS)))
99 TARGET_MCU := STM32F1
100 else
101 $(error Unknown target MCU specified.)
102 endif
104 ifneq ($(BASE_TARGET), $(TARGET))
105 TARGET_FLAGS := $(TARGET_FLAGS) -D$(BASE_TARGET)
106 endif
108 TARGET_FLAGS := $(TARGET_FLAGS) -D$(TARGET_MCU)