Move default DEBUG_MODE from common_pre.h into common_defaults_post.h (#8085)
[betaflight.git] / make / targets.mk
blob99d9ee844eb4191cf2490365f6931073f6235a6f
1 include $(ROOT)/make/targets_list.mk
3 ifeq ($(filter $(TARGET),$(NOBUILD_TARGETS)), $(TARGET))
4 ALTERNATES := $(sort $(filter-out target, $(basename $(notdir $(wildcard $(ROOT)/src/main/target/$(TARGET)/*.mk)))))
5 $(error The target specified, $(TARGET), cannot be built. Use one of the ALT targets: $(ALTERNATES))
6 endif
8 BASE_TARGET := $(call get_base_target,$(TARGET))
9 ifneq ($(TARGET),$(BASE_TARGET))
10 include $(ROOT)/src/main/target/$(BASE_TARGET)/$(TARGET).mk
11 endif
13 ifeq ($(filter $(TARGET),$(OPBL_TARGETS)), $(TARGET))
14 OPBL = yes
15 endif
17 # silently ignore if the file is not present. Allows for target specific.
18 -include $(ROOT)/src/main/target/$(BASE_TARGET)/target.mk
20 F4_TARGETS := $(F405_TARGETS) $(F411_TARGETS) $(F446_TARGETS)
21 F7_TARGETS := $(F7X2RE_TARGETS) $(F7X5XE_TARGETS) $(F7X5XG_TARGETS) $(F7X5XI_TARGETS) $(F7X6XG_TARGETS)
23 ifeq ($(filter $(TARGET),$(VALID_TARGETS)),)
24 $(error Target '$(TARGET)' is not valid, must be one of $(VALID_TARGETS). Have you prepared a valid target.mk?)
25 endif
27 ifeq ($(filter $(TARGET),$(F1_TARGETS) $(F3_TARGETS) $(F4_TARGETS) $(F7_TARGETS) $(SITL_TARGETS)),)
28 $(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?)
29 endif
31 ifeq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS)))
32 TARGET_MCU := STM32F3
34 else ifeq ($(TARGET),$(filter $(TARGET), $(F4_TARGETS)))
35 TARGET_MCU := STM32F4
37 else ifeq ($(TARGET),$(filter $(TARGET), $(F7_TARGETS)))
38 TARGET_MCU := STM32F7
40 else ifeq ($(TARGET),$(filter $(TARGET), $(SITL_TARGETS)))
41 TARGET_MCU := SITL
42 SIMULATOR_BUILD = yes
44 else ifeq ($(TARGET),$(filter $(TARGET), $(F1_TARGETS)))
45 TARGET_MCU := STM32F1
46 else
47 $(error Unknown target MCU specified.)
48 endif
50 ifneq ($(BASE_TARGET), $(TARGET))
51 TARGET_FLAGS := $(TARGET_FLAGS) -D$(BASE_TARGET)
52 endif
54 TARGET_FLAGS := $(TARGET_FLAGS) -D$(TARGET_MCU)