Implement DShot bit bang for AT32 (#12577)
[betaflight.git] / mk / config.mk
blobb5171869be168e92f159ce0f763a94ac80b56a4a
2 CONFIGS_REPO_URL ?= https://github.com/betaflight/config
4 BASE_CONFIGS = $(sort $(notdir $(patsubst %/,%,$(dir $(wildcard $(CONFIG_DIR)/configs/*/config.h)))))
6 ifneq ($(filter-out %_install test% %_clean clean% %-print %.hex %.h hex checks help configs $(BASE_TARGETS) $(BASE_CONFIGS),$(MAKECMDGOALS)),)
7 ifeq ($(wildcard $(CONFIG_DIR)/configs/),)
8 $(error `$(CONFIG_DIR)` not found. Have you hydrated configuration using: 'make configs'?)
9 endif
10 endif
12 ifneq ($(CONFIG),)
14 ifneq ($(TARGET),)
15 $(error TARGET or CONFIG should be specified. Not both.)
16 endif
18 CONFIG_FILE = $(CONFIG_DIR)/configs/$(CONFIG)/config.h
19 INCLUDE_DIRS += $(CONFIG_DIR)/configs/$(CONFIG)
21 ifneq ($(wildcard $(CONFIG_FILE)),)
23 CONFIG_REVISION := norevision
24 ifeq ($(shell git -C $(CONFIG_DIR) diff --shortstat),)
25 CONFIG_REVISION := $(shell git -C $(CONFIG_DIR) log -1 --format="%h")
26 CONFIG_REVISION_DEFINE := -D'__CONFIG_REVISION__="$(CONFIG_REVISION)"'
27 endif
29 TARGET := $(shell grep " FC_TARGET_MCU" $(CONFIG_FILE) | awk '{print $$3}' )
30 HSE_VALUE_MHZ := $(shell grep " SYSTEM_HSE_MHZ" $(CONFIG_FILE) | awk '{print $$3}' )
31 ifneq ($(HSE_VALUE_MHZ),)
32 HSE_VALUE := $(shell echo $$(( $(HSE_VALUE_MHZ) * 1000000 )) )
33 endif
35 GYRO_DEFINE := $(shell grep " USE_GYRO_" $(CONFIG_FILE) | awk '{print $$2}' )
37 ifeq ($(TARGET),)
38 $(error No TARGET identified. Is the $(CONFIG_FILE) valid for $(CONFIG)?)
39 endif
41 EXST_ADJUST_VMA := $(shell grep " FC_VMA_ADDRESS" $(CONFIG_FILE) | awk '{print $$3}' )
42 ifneq ($(EXST_ADJUST_VMA),)
43 EXST = yes
44 endif
46 else #exists
47 $(error `$(CONFIG_FILE)` not found. Have you hydrated configuration using: 'make configs'?)
48 endif #config_file exists
49 endif #config
51 .PHONY: configs
52 configs:
53 ifeq ($(wildcard $(CONFIG_DIR)),)
54 @echo "Hydrating clone for configs: $(CONFIG_DIR)"
55 $(V0) git clone $(CONFIGS_REPO_URL) $(CONFIG_DIR)
56 else
57 $(V0) git -C $(CONFIG_DIR) pull origin
58 endif
60 $(BASE_CONFIGS):
61 @echo "Building target config $@"
62 $(V0) $(MAKE) -j hex CONFIG=$@
63 @echo "Building target config $@ succeeded."
65 ## <CONFIG>_rev : build configured target and add revision to filename
66 $(addsuffix _rev,$(BASE_CONFIGS)):
67 $(V0) $(MAKE) -j hex CONFIG=$(subst _rev,,$@) REV=yes