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
))
18 UNSUPPORTED_TARGETS
:= \
28 SUPPORTED_TARGETS
:= $(filter-out $(UNSUPPORTED_TARGETS
), $(VALID_TARGETS
))
30 TARGETS_TOTAL
:= $(words $(SUPPORTED_TARGETS
))
32 TARGETS_PER_GROUP
:= $(shell expr
$(TARGETS_TOTAL
) / $(TARGET_GROUPS
) )
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
56 BASE_TARGET
:= $(TARGET
)
59 ifeq ($(filter $(TARGET
),$(OPBL_TARGETS
)), $(TARGET
))
63 ifeq ($(filter $(TARGET
),$(OSD_SLAVE_TARGETS
)), $(TARGET
))
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?
)
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?
)
85 ifeq ($(TARGET
),$(filter $(TARGET
),$(F3_TARGETS
)))
88 else ifeq ($(TARGET
),$(filter $(TARGET
), $(F4_TARGETS
)))
91 else ifeq ($(TARGET
),$(filter $(TARGET
), $(F7_TARGETS
)))
94 else ifeq ($(TARGET
),$(filter $(TARGET
), $(SITL_TARGETS
)))
98 else ifeq ($(TARGET
),$(filter $(TARGET
), $(F1_TARGETS
)))
101 $(error Unknown target MCU specified.
)
104 ifneq ($(BASE_TARGET
), $(TARGET
))
105 TARGET_FLAGS
:= $(TARGET_FLAGS
) -D
$(BASE_TARGET
)
108 TARGET_FLAGS
:= $(TARGET_FLAGS
) -D
$(TARGET_MCU
)