Fixed build for targets without RC smoothing.
[betaflight.git] / Makefile
blobcd29ce63f222c14916e4d421369f48b76169eee1
1 ###############################################################################
2 # "THE BEER-WARE LICENSE" (Revision 42):
3 # <msmith@FreeBSD.ORG> wrote this file. As long as you retain this notice you
4 # can do whatever you want with this stuff. If we meet some day, and you think
5 # this stuff is worth it, you can buy me a beer in return
6 ###############################################################################
8 # Makefile for building the betaflight firmware.
10 # Invoke this with 'make help' to see the list of supported targets.
12 ###############################################################################
15 # Things that the user might override on the commandline
18 # The target to build, see VALID_TARGETS below
19 TARGET ?= OMNIBUSF4
21 # Compile-time options
22 OPTIONS ?=
24 # compile for OpenPilot BootLoader support
25 OPBL ?= no
27 # Debugger optons:
28 # empty - ordinary build with all optimizations enabled
29 # RELWITHDEBINFO - ordinary build with debug symbols and all optimizations enabled
30 # GDB - debug build with minimum number of optimizations
31 DEBUG ?=
33 # Insert the debugging hardfault debugger
34 # releases should not be built with this flag as it does not disable pwm output
35 DEBUG_HARDFAULTS ?=
37 # Serial port/Device for flashing
38 SERIAL_DEVICE ?= $(firstword $(wildcard /dev/ttyACM*) $(firstword $(wildcard /dev/ttyUSB*) no-port-found))
40 # Flash size (KB). Some low-end chips actually have more flash than advertised, use this to override.
41 FLASH_SIZE ?=
44 ###############################################################################
45 # Things that need to be maintained as the source changes
48 FORKNAME = betaflight
50 # Working directories
51 ROOT := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
52 SRC_DIR := $(ROOT)/src/main
53 OBJECT_DIR := $(ROOT)/obj/main
54 BIN_DIR := $(ROOT)/obj
55 CMSIS_DIR := $(ROOT)/lib/main/CMSIS
56 INCLUDE_DIRS := $(SRC_DIR) \
57 $(ROOT)/src/main/target \
58 $(ROOT)/src/main/startup
59 LINKER_DIR := $(ROOT)/src/link
61 ## V : Set verbosity level based on the V= parameter
62 ## V=0 Low
63 ## V=1 High
64 include $(ROOT)/make/build_verbosity.mk
66 # Build tools, so we all share the same versions
67 # import macros common to all supported build systems
68 include $(ROOT)/make/system-id.mk
70 # developer preferences, edit these at will, they'll be gitignored
71 -include $(ROOT)/make/local.mk
73 # configure some directories that are relative to wherever ROOT_DIR is located
74 ifndef TOOLS_DIR
75 TOOLS_DIR := $(ROOT)/tools
76 endif
77 BUILD_DIR := $(ROOT)/build
78 DL_DIR := $(ROOT)/downloads
80 export RM := rm
82 # import macros that are OS specific
83 include $(ROOT)/make/$(OSFAMILY).mk
85 # include the tools makefile
86 include $(ROOT)/make/tools.mk
88 # default xtal value for F4 targets
89 HSE_VALUE ?= 8000000
91 # used for turning on features like VCP and SDCARD
92 FEATURES =
94 # used to disable features based on flash space shortage (larger number => more features disabled)
95 FEATURE_CUT_LEVEL_SUPPLIED := $(FEATURE_CUT_LEVEL)
96 FEATURE_CUT_LEVEL =
98 # The list of targets to build for 'pre-push'
99 PRE_PUSH_TARGET_LIST ?= OMNIBUSF4 STM32F405 SPRACINGF7DUAL STM32F7X2 SITL test-representative
101 include $(ROOT)/make/targets.mk
103 REVISION := $(shell git log -1 --format="%h")
105 FC_VER_MAJOR := $(shell grep " FC_VERSION_MAJOR" src/main/build/version.h | awk '{print $$3}' )
106 FC_VER_MINOR := $(shell grep " FC_VERSION_MINOR" src/main/build/version.h | awk '{print $$3}' )
107 FC_VER_PATCH := $(shell grep " FC_VERSION_PATCH" src/main/build/version.h | awk '{print $$3}' )
109 FC_VER := $(FC_VER_MAJOR).$(FC_VER_MINOR).$(FC_VER_PATCH)
111 # Search path for sources
112 VPATH := $(SRC_DIR):$(SRC_DIR)/startup
113 USBFS_DIR = $(ROOT)/lib/main/STM32_USB-FS-Device_Driver
114 USBPERIPH_SRC = $(notdir $(wildcard $(USBFS_DIR)/src/*.c))
115 FATFS_DIR = $(ROOT)/lib/main/FatFS
116 FATFS_SRC = $(notdir $(wildcard $(FATFS_DIR)/*.c))
118 CSOURCES := $(shell find $(SRC_DIR) -name '*.c')
120 LD_FLAGS :=
123 # Default Tool options - can be overridden in {mcu}.mk files.
125 ifeq ($(DEBUG),GDB)
126 OPTIMISE_DEFAULT := -Og
128 LTO_FLAGS := $(OPTIMISE_DEFAULT)
129 DEBUG_FLAGS = -ggdb3 -DDEBUG
130 else
131 ifeq ($(DEBUG),INFO)
132 DEBUG_FLAGS = -ggdb3
133 endif
134 OPTIMISATION_BASE := -flto -fuse-linker-plugin -ffast-math
135 OPTIMISE_DEFAULT := -O2
136 OPTIMISE_SPEED := -Ofast
137 OPTIMISE_SIZE := -Os
139 LTO_FLAGS := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED)
140 endif
142 VPATH := $(VPATH):$(ROOT)/make/mcu
143 VPATH := $(VPATH):$(ROOT)/make
145 # start specific includes
146 include $(ROOT)/make/mcu/$(TARGET_MCU).mk
148 # openocd specific includes
149 include $(ROOT)/make/openocd.mk
151 # Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already.
152 ifeq ($(FLASH_SIZE),)
153 ifneq ($(TARGET_FLASH),)
154 FLASH_SIZE := $(TARGET_FLASH)
155 else
156 $(error FLASH_SIZE not configured for target $(TARGET))
157 endif
158 endif
160 DEVICE_FLAGS := $(DEVICE_FLAGS) -DFLASH_SIZE=$(FLASH_SIZE)
162 ifneq ($(HSE_VALUE),)
163 DEVICE_FLAGS := $(DEVICE_FLAGS) -DHSE_VALUE=$(HSE_VALUE)
164 endif
166 ifneq ($(FEATURE_CUT_LEVEL_SUPPLIED),)
167 DEVICE_FLAGS := $(DEVICE_FLAGS) -DFEATURE_CUT_LEVEL=$(FEATURE_CUT_LEVEL_SUPPLIED)
168 else ifneq ($(FEATURE_CUT_LEVEL),)
169 DEVICE_FLAGS := $(DEVICE_FLAGS) -DFEATURE_CUT_LEVEL=$(FEATURE_CUT_LEVEL)
170 endif
172 TARGET_DIR = $(ROOT)/src/main/target/$(BASE_TARGET)
173 TARGET_DIR_SRC = $(notdir $(wildcard $(TARGET_DIR)/*.c))
175 ifeq ($(OPBL),yes)
176 TARGET_FLAGS := -DOPBL $(TARGET_FLAGS)
177 .DEFAULT_GOAL := binary
178 else
179 .DEFAULT_GOAL := hex
180 endif
182 INCLUDE_DIRS := $(INCLUDE_DIRS) \
183 $(ROOT)/lib/main/MAVLink
185 INCLUDE_DIRS := $(INCLUDE_DIRS) \
186 $(TARGET_DIR)
188 VPATH := $(VPATH):$(TARGET_DIR)
190 include $(ROOT)/make/source.mk
192 ###############################################################################
193 # Things that might need changing to use different tools
196 # Find out if ccache is installed on the system
197 CCACHE := ccache
198 RESULT = $(shell (which $(CCACHE) > /dev/null 2>&1; echo $$?) )
199 ifneq ($(RESULT),0)
200 CCACHE :=
201 endif
203 # Tool names
204 CROSS_CC := $(CCACHE) $(ARM_SDK_PREFIX)gcc
205 CROSS_CXX := $(CCACHE) $(ARM_SDK_PREFIX)g++
206 CROSS_GDB := $(ARM_SDK_PREFIX)gdb
207 OBJCOPY := $(ARM_SDK_PREFIX)objcopy
208 OBJDUMP := $(ARM_SDK_PREFIX)objdump
209 SIZE := $(ARM_SDK_PREFIX)size
212 # Tool options.
214 CC_DEBUG_OPTIMISATION := $(OPTIMISE_DEFAULT)
215 CC_DEFAULT_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_DEFAULT)
216 CC_SPEED_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SPEED)
217 CC_SIZE_OPTIMISATION := $(OPTIMISATION_BASE) $(OPTIMISE_SIZE)
218 CC_NO_OPTIMISATION :=
220 CFLAGS += $(ARCH_FLAGS) \
221 $(addprefix -D,$(OPTIONS)) \
222 $(addprefix -I,$(INCLUDE_DIRS)) \
223 $(DEBUG_FLAGS) \
224 -std=gnu11 \
225 -Wall -Wextra -Wunsafe-loop-optimizations -Wdouble-promotion \
226 -ffunction-sections \
227 -fdata-sections \
228 -fno-common \
229 -pedantic \
230 $(DEVICE_FLAGS) \
231 -D_GNU_SOURCE \
232 -DUSE_STDPERIPH_DRIVER \
233 -D$(TARGET) \
234 $(TARGET_FLAGS) \
235 -D'__FORKNAME__="$(FORKNAME)"' \
236 -D'__TARGET__="$(TARGET)"' \
237 -D'__REVISION__="$(REVISION)"' \
238 -save-temps=obj \
239 -MMD -MP \
240 $(EXTRA_FLAGS)
242 ASFLAGS = $(ARCH_FLAGS) \
243 $(DEBUG_FLAGS) \
244 -x assembler-with-cpp \
245 $(addprefix -I,$(INCLUDE_DIRS)) \
246 -MMD -MP
248 ifeq ($(LD_FLAGS),)
249 LD_FLAGS = -lm \
250 -nostartfiles \
251 --specs=nano.specs \
252 -lc \
253 -lnosys \
254 $(ARCH_FLAGS) \
255 $(LTO_FLAGS) \
256 $(DEBUG_FLAGS) \
257 -static \
258 -Wl,-gc-sections,-Map,$(TARGET_MAP) \
259 -Wl,-L$(LINKER_DIR) \
260 -Wl,--cref \
261 -Wl,--no-wchar-size-warning \
262 -Wl,--print-memory-usage \
263 -T$(LD_SCRIPT)
264 endif
266 ###############################################################################
267 # No user-serviceable parts below
268 ###############################################################################
270 CPPCHECK = cppcheck $(CSOURCES) --enable=all --platform=unix64 \
271 --std=c99 --inline-suppr --quiet --force \
272 $(addprefix -I,$(INCLUDE_DIRS)) \
273 -I/usr/include -I/usr/include/linux
276 # Things we will build
278 TARGET_BIN = $(BIN_DIR)/$(FORKNAME)_$(FC_VER)_$(TARGET).bin
279 TARGET_HEX = $(BIN_DIR)/$(FORKNAME)_$(FC_VER)_$(TARGET).hex
280 TARGET_ELF = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).elf
281 TARGET_LST = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).lst
282 TARGET_OBJS = $(addsuffix .o,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $(SRC))))
283 TARGET_DEPS = $(addsuffix .d,$(addprefix $(OBJECT_DIR)/$(TARGET)/,$(basename $(SRC))))
284 TARGET_MAP = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).map
287 CLEAN_ARTIFACTS := $(TARGET_BIN)
288 CLEAN_ARTIFACTS += $(TARGET_HEX)
289 CLEAN_ARTIFACTS += $(TARGET_ELF) $(TARGET_OBJS) $(TARGET_MAP)
290 CLEAN_ARTIFACTS += $(TARGET_LST)
292 # Make sure build date and revision is updated on every incremental build
293 $(OBJECT_DIR)/$(TARGET)/build/version.o : $(SRC)
295 # List of buildable ELF files and their object dependencies.
296 # It would be nice to compute these lists, but that seems to be just beyond make.
298 $(TARGET_LST): $(TARGET_ELF)
299 $(V0) $(OBJDUMP) -S --disassemble $< > $@
301 $(TARGET_HEX): $(TARGET_ELF)
302 @echo "Creating HEX $(TARGET_HEX)" "$(STDOUT)"
303 $(V1) $(OBJCOPY) -O ihex --set-start 0x8000000 $< $@
305 $(TARGET_BIN): $(TARGET_ELF)
306 @echo "Creating BIN $(TARGET_BIN)" "$(STDOUT)"
307 $(V1) $(OBJCOPY) -O binary $< $@
309 $(TARGET_ELF): $(TARGET_OBJS) $(LD_SCRIPT)
310 @echo "Linking $(TARGET)" "$(STDOUT)"
311 $(V1) $(CROSS_CC) -o $@ $(filter-out %.ld,$^) $(LD_FLAGS)
312 $(V1) $(SIZE) $(TARGET_ELF)
314 # Compile
316 ## compile_file takes two arguments: (1) optimisation description string and (2) optimisation compiler flag
317 define compile_file
318 echo "%% ($(1)) $<" "$(STDOUT)" && \
319 $(CROSS_CC) -c -o $@ $(CFLAGS) $(2) $<
320 endef
322 ifeq ($(DEBUG),GDB)
323 $(OBJECT_DIR)/$(TARGET)/%.o: %.c
324 $(V1) mkdir -p $(dir $@)
325 $(V1) $(if $(findstring $<,$(NOT_OPTIMISED_SRC)), \
326 $(call compile_file,not optimised, $(CC_NO_OPTIMISATION)) \
328 $(call compile_file,debug,$(CC_DEBUG_OPTIMISATION)) \
330 else
331 $(OBJECT_DIR)/$(TARGET)/%.o: %.c
332 $(V1) mkdir -p $(dir $@)
333 $(V1) $(if $(findstring $<,$(NOT_OPTIMISED_SRC)), \
334 $(call compile_file,not optimised,$(CC_NO_OPTIMISATION)) \
336 $(if $(findstring $(subst ./src/main/,,$<),$(SPEED_OPTIMISED_SRC)), \
337 $(call compile_file,speed optimised,$(CC_SPEED_OPTIMISATION)) \
339 $(if $(findstring $(subst ./src/main/,,$<),$(SIZE_OPTIMISED_SRC)), \
340 $(call compile_file,size optimised,$(CC_SIZE_OPTIMISATION)) \
342 $(call compile_file,optimised,$(CC_DEFAULT_OPTIMISATION)) \
346 endif
348 # Assemble
349 $(OBJECT_DIR)/$(TARGET)/%.o: %.s
350 $(V1) mkdir -p $(dir $@)
351 @echo "%% $(notdir $<)" "$(STDOUT)"
352 $(V1) $(CROSS_CC) -c -o $@ $(ASFLAGS) $<
354 $(OBJECT_DIR)/$(TARGET)/%.o: %.S
355 $(V1) mkdir -p $(dir $@)
356 @echo "%% $(notdir $<)" "$(STDOUT)"
357 $(V1) $(CROSS_CC) -c -o $@ $(ASFLAGS) $<
360 ## all : Build all targets (excluding unsupported)
361 all: $(SUPPORTED_TARGETS)
363 ## all_with_unsupported : Build all targets (including unsupported)
364 all_with_unsupported: $(VALID_TARGETS)
366 ## unsupported : Build unsupported targets
367 unsupported: $(UNSUPPORTED_TARGETS)
369 ## pre-push : The minimum verification that should be run before pushing, to check if CI has a chance of succeeding
370 pre-push:
371 $(MAKE) $(addprefix clean_,$(PRE_PUSH_TARGET_LIST)) $(PRE_PUSH_TARGET_LIST) EXTRA_FLAGS=-Werror
373 ## official : Build all official (travis) targets
374 official: $(OFFICIAL_TARGETS)
376 ## targets-group-1 : build some targets
377 targets-group-1: $(GROUP_1_TARGETS)
379 ## targets-group-2 : build some targets
380 targets-group-2: $(GROUP_2_TARGETS)
382 ## targets-group-3 : build some targets
383 targets-group-3: $(GROUP_3_TARGETS)
385 ## targets-group-3 : build some targets
386 targets-group-4: $(GROUP_4_TARGETS)
388 ## targets-group-rest: build the rest of the targets (not listed in group 1, 2 or 3)
389 targets-group-rest: $(GROUP_OTHER_TARGETS)
391 $(VALID_TARGETS):
392 $(V0) @echo "Building $@" && \
393 $(MAKE) binary hex TARGET=$@ && \
394 echo "Building $@ succeeded."
396 $(NOBUILD_TARGETS):
397 $(MAKE) TARGET=$@
399 CLEAN_TARGETS = $(addprefix clean_,$(VALID_TARGETS) )
400 TARGETS_CLEAN = $(addsuffix _clean,$(VALID_TARGETS) )
402 ## clean : clean up temporary / machine-generated files
403 clean:
404 @echo "Cleaning $(TARGET)"
405 $(V0) rm -f $(CLEAN_ARTIFACTS)
406 $(V0) rm -rf $(OBJECT_DIR)/$(TARGET)
407 @echo "Cleaning $(TARGET) succeeded."
409 ## clean_test : clean up temporary / machine-generated files (tests)
410 clean_test-%:
411 $(MAKE) clean_test
413 clean_test:
414 $(V0) cd src/test && $(MAKE) clean || true
416 ## clean_<TARGET> : clean up one specific target
417 $(CLEAN_TARGETS):
418 $(V0) $(MAKE) -j TARGET=$(subst clean_,,$@) clean
420 ## <TARGET>_clean : clean up one specific target (alias for above)
421 $(TARGETS_CLEAN):
422 $(V0) $(MAKE) -j TARGET=$(subst _clean,,$@) clean
424 ## clean_all : clean all valid targets
425 clean_all: $(CLEAN_TARGETS)
427 ## all_clean : clean all valid targets (alias for above)
428 all_clean: $(TARGETS_CLEAN)
430 FLASH_TARGETS = $(addprefix flash_,$(VALID_TARGETS) )
432 ## flash_<TARGET> : build and flash a target
433 $(FLASH_TARGETS):
434 ifneq (,$(findstring /dev/ttyUSB,$(SERIAL_DEVICE)))
435 $(V0) $(MAKE) -j hex TARGET=$(subst flash_,,$@)
436 $(V0) $(MAKE) tty_flash TARGET=$(subst flash_,,$@)
437 else
438 $(V0) $(MAKE) -j binary TARGET=$(subst flash_,,$@)
439 $(V0) $(MAKE) dfu_flash TARGET=$(subst flash_,,$@)
440 endif
442 ## tty_flash : flash firmware (.hex) onto flight controller via a serial port
443 tty_flash:
444 $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
445 $(V0) echo -n 'R' > $(SERIAL_DEVICE)
446 $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
448 ## dfu_flash : flash firmware (.bin) onto flight controller via a DFU mode
449 dfu_flash:
450 ifneq (no-port-found,$(SERIAL_DEVICE))
451 # potentially this is because the MCU already is in DFU mode, try anyway
452 $(V0) echo -n 'R' > $(SERIAL_DEVICE)
453 $(V0) sleep 1
454 endif
455 $(V0) dfu-util -a 0 -D $(TARGET_BIN) -s 0x08000000:leave
457 st-flash_$(TARGET): $(TARGET_BIN)
458 $(V0) st-flash --reset write $< 0x08000000
460 ## st-flash : flash firmware (.bin) onto flight controller
461 st-flash: st-flash_$(TARGET)
463 ifneq ($(OPENOCD_COMMAND),)
464 openocd-gdb: $(TARGET_ELF)
465 $(V0) $(OPENOCD_COMMAND) & $(CROSS_GDB) $(TARGET_ELF) -ex "target remote localhost:3333" -ex "load"
466 endif
468 binary:
469 $(V0) $(MAKE) -j $(TARGET_BIN)
471 hex:
472 $(V0) $(MAKE) -j $(TARGET_HEX)
474 unbrick_$(TARGET): $(TARGET_HEX)
475 $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
476 $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
478 ## unbrick : unbrick flight controller
479 unbrick: unbrick_$(TARGET)
481 ## cppcheck : run static analysis on C source code
482 cppcheck: $(CSOURCES)
483 $(V0) $(CPPCHECK)
485 cppcheck-result.xml: $(CSOURCES)
486 $(V0) $(CPPCHECK) --xml-version=2 2> cppcheck-result.xml
488 # mkdirs
489 $(DL_DIR):
490 mkdir -p $@
492 $(TOOLS_DIR):
493 mkdir -p $@
495 $(BUILD_DIR):
496 mkdir -p $@
498 ## version : print firmware version
499 version:
500 @echo $(FC_VER)
502 ## help : print this help message and exit
503 help: Makefile make/tools.mk
504 @echo ""
505 @echo "Makefile for the $(FORKNAME) firmware"
506 @echo ""
507 @echo "Usage:"
508 @echo " make [V=<verbosity>] [TARGET=<target>] [OPTIONS=\"<options>\"]"
509 @echo "Or:"
510 @echo " make <target> [V=<verbosity>] [OPTIONS=\"<options>\"]"
511 @echo ""
512 @echo "Valid TARGET values are: $(VALID_TARGETS)"
513 @echo ""
514 @sed -n 's/^## //p' $?
516 ## targets : print a list of all valid target platforms (for consumption by scripts)
517 targets:
518 @echo "Valid targets: $(VALID_TARGETS)"
519 @echo "Supported targets: $(SUPPORTED_TARGETS)"
520 @echo "Unsupported targets: $(UNSUPPORTED_TARGETS)"
521 @echo "Target: $(TARGET)"
522 @echo "Base target: $(BASE_TARGET)"
523 @echo "targets-group-1: $(GROUP_1_TARGETS)"
524 @echo "targets-group-2: $(GROUP_2_TARGETS)"
525 @echo "targets-group-3: $(GROUP_3_TARGETS)"
526 @echo "targets-group-4: $(GROUP_4_TARGETS)"
527 @echo "targets-group-rest: $(GROUP_OTHER_TARGETS)"
529 @echo "targets-group-1: $(words $(GROUP_1_TARGETS)) targets"
530 @echo "targets-group-2: $(words $(GROUP_2_TARGETS)) targets"
531 @echo "targets-group-3: $(words $(GROUP_3_TARGETS)) targets"
532 @echo "targets-group-4: $(words $(GROUP_4_TARGETS)) targets"
533 @echo "targets-group-rest: $(words $(GROUP_OTHER_TARGETS)) targets"
534 @echo "total in all groups $(words $(SUPPORTED_TARGETS)) targets"
536 ## target-mcu : print the MCU type of the target
537 target-mcu:
538 @echo $(TARGET_MCU)
540 ## targets-by-mcu : make all targets that have a MCU_TYPE mcu
541 targets-by-mcu:
542 $(V1) for target in $(VALID_TARGETS); do \
543 TARGET_MCU_TYPE=$$($(MAKE) -s TARGET=$${target} target-mcu); \
544 if [ "$${TARGET_MCU_TYPE}" = "$${MCU_TYPE}" ]; then \
545 if [ "$${DO_BUILD}" = 1 ]; then \
546 echo "Building target $${target}..."; \
547 $(MAKE) TARGET=$${target}; \
548 if [ $$? -ne 0 ]; then \
549 echo "Building target $${target} failed, aborting."; \
550 exit 1; \
551 fi; \
552 else \
553 echo -n "$${target} "; \
554 fi; \
555 fi; \
556 done
557 @echo
559 ## targets-f3 : make all F3 targets
560 targets-f3:
561 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F3 DO_BUILD=1
563 targets-f3-print:
564 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F3
566 ## targets-f4 : make all F4 targets
567 targets-f4:
568 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F4 DO_BUILD=1
570 targets-f4-print:
571 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F4
573 ## targets-f7 : make all F7 targets
574 targets-f7:
575 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F7 DO_BUILD=1
577 targets-f7-print:
578 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F7
580 ## test : run the Betaflight test suite
581 ## junittest : run the Betaflight test suite, producing Junit XML result files.
582 ## test-representative: run a representative subset of the Betaflight test suite (i.e. run all tests, but run each expanded test only for one target)
583 ## test-all: run the Betaflight test suite including all per-target expanded tests
584 test junittest test-all test-representative:
585 $(V0) cd src/test && $(MAKE) $@
587 ## test_help : print the help message for the test suite (including a list of the available tests)
588 test_help:
589 $(V0) cd src/test && $(MAKE) help
591 ## test_% : run test 'test_%' from the test suite
592 test_%:
593 $(V0) cd src/test && $(MAKE) $@
596 check-target-independence:
597 $(V1) for test_target in $(VALID_TARGETS); do \
598 FOUND=$$(grep -rE "\W$${test_target}(\W.*)?$$" src/main | grep -vE "(//)|(/\*).*\W$${test_target}(\W.*)?$$" | grep -vE "^src/main/target"); \
599 if [ "$${FOUND}" != "" ]; then \
600 echo "Target dependencies for target '$${test_target}' found:"; \
601 echo "$${FOUND}"; \
602 exit 1; \
603 fi; \
604 done
606 check-fastram-usage-correctness:
607 $(V1) NON_TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM_ZERO_INIT\W.*=.*" src/main/ | grep -Ev "=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \
608 if [ "$${NON_TRIVIALLY_INITIALIZED}" != "" ]; then \
609 echo "Non-trivially initialized FAST_RAM_ZERO_INIT variables found, use FAST_RAM instead:"; \
610 echo "$${NON_TRIVIALLY_INITIALIZED}"; \
611 exit 1; \
612 fi; \
613 TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM\W.*;" src/main/ | grep -v "="); \
614 EXPLICITLY_TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM\W.*;" src/main/ | grep -E "=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \
615 if [ "$${TRIVIALLY_INITIALIZED}$${EXPLICITLY_TRIVIALLY_INITIALIZED}" != "" ]; then \
616 echo "Trivially initialized FAST_RAM variables found, use FAST_RAM_ZERO_INIT instead to save FLASH:"; \
617 echo "$${TRIVIALLY_INITIALIZED}\n$${EXPLICITLY_TRIVIALLY_INITIALIZED}"; \
618 exit 1; \
621 check-platform-included:
622 $(V1) PLATFORM_NOT_INCLUDED=$$(find src/main -type d -name target -prune -o -type f -name \*.c -exec grep -L "^#include \"platform.h\"" {} \;); \
623 if [ "$$(echo $${PLATFORM_NOT_INCLUDED} | grep -v -e '^$$' | wc -l)" -ne 0 ]; then \
624 echo "The following compilation units do not include the required target specific configuration provided by 'platform.h':"; \
625 echo "$${PLATFORM_NOT_INCLUDED}"; \
626 exit 1; \
629 # rebuild everything when makefile changes
630 $(TARGET_OBJS): Makefile $(TARGET_DIR)/target.mk $(wildcard make/*)
633 # include auto-generated dependencies
634 -include $(TARGET_DEPS)