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 DEFAULT_TARGET ?
= STM32F405
22 # Compile-time options
25 # compile for External Storage Bootloader support
28 # compile for target loaded into RAM
31 # reserve space for custom defaults
32 CUSTOM_DEFAULTS_EXTENDED ?
= no
35 # empty - ordinary build with all optimizations enabled
36 # INFO - ordinary build with debug symbols and all optimizations enabled
37 # GDB - debug build with minimum number of optimizations
40 # Insert the debugging hardfault debugger
41 # releases should not be built with this flag as it does not disable pwm output
44 # Serial port/Device for flashing
45 SERIAL_DEVICE ?
= $(firstword $(wildcard /dev
/ttyACM
*) $(firstword $(wildcard /dev
/ttyUSB
*) no-port-found
))
47 # Flash size (KB). Some low-end chips actually have more flash than advertised, use this to override.
50 ###############################################################################
51 # Things that need to be maintained as the source changes
57 ROOT
:= $(patsubst %/,%,$(dir $(lastword
$(MAKEFILE_LIST
))))
58 SRC_DIR
:= $(ROOT
)/src
/main
59 OBJECT_DIR
:= $(ROOT
)/obj
/main
60 BIN_DIR
:= $(ROOT
)/obj
61 CMSIS_DIR
:= $(ROOT
)/lib
/main
/CMSIS
62 INCLUDE_DIRS
:= $(SRC_DIR
) \
63 $(ROOT
)/src
/main
/target \
64 $(ROOT
)/src
/main
/startup
65 LINKER_DIR
:= $(ROOT
)/src
/link
67 ## V : Set verbosity level based on the V= parameter
70 include $(ROOT
)/make
/build_verbosity.mk
72 # Build tools, so we all share the same versions
73 # import macros common to all supported build systems
74 include $(ROOT
)/make
/system-id.mk
76 # developer preferences, edit these at will, they'll be gitignored
77 -include $(ROOT
)/make
/local.mk
79 # pre-build sanity checks
80 include $(ROOT
)/make
/checks.mk
82 # configure some directories that are relative to wherever ROOT_DIR is located
83 TOOLS_DIR ?
= $(ROOT
)/tools
84 DL_DIR
:= $(ROOT
)/downloads
88 # import macros that are OS specific
89 include $(ROOT
)/make
/$(OSFAMILY
).mk
91 # include the tools makefile
92 include $(ROOT
)/make
/tools.mk
94 # default xtal value for F4 targets
97 # used for turning on features like VCP and SDCARD
101 TARGET
:= $(DEFAULT_TARGET
)
104 include $(ROOT
)/make
/targets.mk
106 REVISION
:= norevision
107 ifeq ($(shell git diff
--shortstat
),)
108 REVISION
:= $(shell git log
-1 --format
="%h")
111 FC_VER_MAJOR
:= $(shell grep
" FC_VERSION_MAJOR" src
/main
/build
/version.h | awk
'{print $$3}' )
112 FC_VER_MINOR
:= $(shell grep
" FC_VERSION_MINOR" src
/main
/build
/version.h | awk
'{print $$3}' )
113 FC_VER_PATCH
:= $(shell grep
" FC_VERSION_PATCH" src
/main
/build
/version.h | awk
'{print $$3}' )
115 FC_VER
:= $(FC_VER_MAJOR
).
$(FC_VER_MINOR
).
$(FC_VER_PATCH
)
117 # Search path for sources
118 VPATH
:= $(SRC_DIR
):$(SRC_DIR
)/startup
119 FATFS_DIR
= $(ROOT
)/lib
/main
/FatFS
120 FATFS_SRC
= $(notdir $(wildcard $(FATFS_DIR
)/*.c
))
122 CSOURCES
:= $(shell find
$(SRC_DIR
) -name
'*.c')
128 # Default Tool options - can be overridden in {mcu}.mk files.
131 OPTIMISE_DEFAULT
:= -Og
133 LTO_FLAGS
:= $(OPTIMISE_DEFAULT
)
134 DEBUG_FLAGS
= -ggdb3
-gdwarf-5
-DDEBUG
139 OPTIMISATION_BASE
:= -flto
-fuse-linker-plugin
-ffast-math
-fmerge-all-constants
140 OPTIMISE_DEFAULT
:= -O2
141 OPTIMISE_SPEED
:= -Ofast
144 LTO_FLAGS
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
147 VPATH
:= $(VPATH
):$(ROOT
)/make
/mcu
148 VPATH
:= $(VPATH
):$(ROOT
)/make
150 # start specific includes
151 include $(ROOT
)/make
/mcu
/$(TARGET_MCU
).mk
153 # openocd specific includes
154 include $(ROOT
)/make
/openocd.mk
156 # Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already.
157 ifeq ($(TARGET_FLASH_SIZE
),)
158 ifneq ($(MCU_FLASH_SIZE
),)
159 TARGET_FLASH_SIZE
:= $(MCU_FLASH_SIZE
)
161 $(error MCU_FLASH_SIZE not configured for target
$(TARGET
))
165 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DTARGET_FLASH_SIZE
=$(TARGET_FLASH_SIZE
)
167 ifneq ($(HSE_VALUE
),)
168 DEVICE_FLAGS
:= $(DEVICE_FLAGS
) -DHSE_VALUE
=$(HSE_VALUE
)
171 TARGET_DIR
= $(ROOT
)/src
/main
/target
/$(TARGET
)
172 TARGET_DIR_SRC
= $(notdir $(wildcard $(TARGET_DIR
)/*.c
))
176 ifeq ($(CUSTOM_DEFAULTS_EXTENDED
),yes
)
177 TARGET_FLAGS
+= -DUSE_CUSTOM_DEFAULTS
=
178 EXTRA_LD_FLAGS
+= -Wl
,--defsym
=USE_CUSTOM_DEFAULTS_EXTENDED
=1
181 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
182 $(ROOT
)/lib
/main
/MAVLink
184 INCLUDE_DIRS
:= $(INCLUDE_DIRS
) \
187 VPATH
:= $(VPATH
):$(TARGET_DIR
)
189 include $(ROOT
)/make
/source.mk
191 ###############################################################################
192 # Things that might need changing to use different tools
195 # Find out if ccache is installed on the system
197 RESULT
= $(shell (which
$(CCACHE
) > /dev
/null
2>&1; echo
$$?
) )
203 CROSS_CC
:= $(CCACHE
) $(ARM_SDK_PREFIX
)gcc
204 CROSS_CXX
:= $(CCACHE
) $(ARM_SDK_PREFIX
)g
++
205 CROSS_GDB
:= $(ARM_SDK_PREFIX
)gdb
206 OBJCOPY
:= $(ARM_SDK_PREFIX
)objcopy
207 OBJDUMP
:= $(ARM_SDK_PREFIX
)objdump
208 READELF
:= $(ARM_SDK_PREFIX
)readelf
209 SIZE
:= $(ARM_SDK_PREFIX
)size
210 DFUSE-PACK
:= src
/utils
/dfuse-pack.py
215 CC_DEBUG_OPTIMISATION
:= $(OPTIMISE_DEFAULT
)
216 CC_DEFAULT_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_DEFAULT
)
217 CC_SPEED_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SPEED
)
218 CC_SIZE_OPTIMISATION
:= $(OPTIMISATION_BASE
) $(OPTIMISE_SIZE
)
219 CC_NO_OPTIMISATION
:=
222 # Added after GCC version update, remove once the warnings have been fixed
226 EXTRA_WARNING_FLAGS
:= -Wold-style-definition
228 CFLAGS
+= $(ARCH_FLAGS
) \
229 $(addprefix -D
,$(OPTIONS
)) \
230 $(addprefix -I
,$(INCLUDE_DIRS
)) \
233 -Wall
-Wextra
-Werror
-Wpedantic
-Wunsafe-loop-optimizations
-Wdouble-promotion \
234 $(EXTRA_WARNING_FLAGS
) \
235 -ffunction-sections \
241 -DUSE_STDPERIPH_DRIVER \
244 -D
'__FORKNAME__="$(FORKNAME)"' \
245 -D
'__TARGET__="$(TARGET)"' \
246 -D
'__REVISION__="$(REVISION)"' \
251 ASFLAGS
= $(ARCH_FLAGS
) \
253 -x assembler-with-cpp \
254 $(addprefix -I
,$(INCLUDE_DIRS
)) \
267 -Wl
,-gc-sections
,-Map
,$(TARGET_MAP
) \
268 -Wl
,-L
$(LINKER_DIR
) \
270 -Wl
,--no-wchar-size-warning \
271 -Wl
,--print-memory-usage \
276 ###############################################################################
277 # No user-serviceable parts below
278 ###############################################################################
280 CPPCHECK
= cppcheck
$(CSOURCES
) --enable
=all --platform
=unix64 \
281 --std
=c99
--inline-suppr
--quiet
--force \
282 $(addprefix -I
,$(INCLUDE_DIRS
)) \
283 -I
/usr
/include -I
/usr
/include/linux
285 TARGET_NAME
:= $(TARGET
)
288 TARGET_NAME
:= $(TARGET_NAME
)_
$(REVISION
)
291 TARGET_FULLNAME
= $(FORKNAME
)_
$(FC_VER
)_
$(TARGET_NAME
)
294 # Things we will build
296 TARGET_BIN
= $(BIN_DIR
)/$(TARGET_FULLNAME
).bin
297 TARGET_HEX
= $(BIN_DIR
)/$(TARGET_FULLNAME
).hex
298 TARGET_DFU
= $(BIN_DIR
)/$(TARGET_FULLNAME
).dfu
299 TARGET_ZIP
= $(BIN_DIR
)/$(TARGET_FULLNAME
).zip
300 TARGET_OBJ_DIR
= $(OBJECT_DIR
)/$(TARGET_NAME
)
301 TARGET_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET_NAME
).elf
302 TARGET_EXST_ELF
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET_NAME
)_EXST.elf
303 TARGET_UNPATCHED_BIN
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET_NAME
)_UNPATCHED.bin
304 TARGET_LST
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET_NAME
).lst
305 TARGET_OBJS
= $(addsuffix .o
,$(addprefix $(TARGET_OBJ_DIR
)/,$(basename $(SRC
))))
306 TARGET_DEPS
= $(addsuffix .d
,$(addprefix $(TARGET_OBJ_DIR
)/,$(basename $(SRC
))))
307 TARGET_MAP
= $(OBJECT_DIR
)/$(FORKNAME
)_
$(TARGET_NAME
).map
309 TARGET_EXST_HASH_SECTION_FILE
= $(TARGET_OBJ_DIR
)/exst_hash_section.bin
311 TARGET_EF_HASH
:= $(shell echo
-n
"$(EXTRA_FLAGS)" | openssl dgst
-md5 | awk
'{print $$2;}')
312 TARGET_EF_HASH_FILE
:= $(TARGET_OBJ_DIR
)/.efhash_
$(TARGET_EF_HASH
)
314 CLEAN_ARTIFACTS
:= $(TARGET_BIN
)
315 CLEAN_ARTIFACTS
+= $(TARGET_HEX_REV
) $(TARGET_HEX
)
316 CLEAN_ARTIFACTS
+= $(TARGET_ELF
) $(TARGET_OBJS
) $(TARGET_MAP
)
317 CLEAN_ARTIFACTS
+= $(TARGET_LST
)
318 CLEAN_ARTIFACTS
+= $(TARGET_DFU
)
320 # Make sure build date and revision is updated on every incremental build
321 $(TARGET_OBJ_DIR
)/build
/version.o
: $(SRC
)
323 # List of buildable ELF files and their object dependencies.
324 # It would be nice to compute these lists, but that seems to be just beyond make.
326 $(TARGET_LST
): $(TARGET_ELF
)
327 $(V0
) $(OBJDUMP
) -S
--disassemble
$< > $@
330 $(TARGET_BIN
): $(TARGET_ELF
)
331 @echo
"Creating BIN $(TARGET_BIN)" "$(STDOUT)"
332 $(V1
) $(OBJCOPY
) -O binary
$< $@
334 $(TARGET_HEX
): $(TARGET_ELF
)
335 @echo
"Creating HEX $(TARGET_HEX)" "$(STDOUT)"
336 $(V1
) $(OBJCOPY
) -O ihex
--set-start
0x8000000 $< $@
338 $(TARGET_DFU
): $(TARGET_HEX
)
339 @echo
"Creating DFU $(TARGET_DFU)" "$(STDOUT)"
340 $(V1
) $(PYTHON
) $(DFUSE-PACK
) -i
$< $@
343 CLEAN_ARTIFACTS
+= $(TARGET_UNPATCHED_BIN
) $(TARGET_EXST_HASH_SECTION_FILE
) $(TARGET_EXST_ELF
)
345 $(TARGET_UNPATCHED_BIN
): $(TARGET_ELF
)
346 @echo
"Creating BIN (without checksum) $(TARGET_UNPATCHED_BIN)" "$(STDOUT)"
347 $(V1
) $(OBJCOPY
) -O binary
$< $@
349 $(TARGET_BIN
): $(TARGET_UNPATCHED_BIN
)
350 @echo
"Creating EXST $(TARGET_BIN)" "$(STDOUT)"
351 # Linker script should allow .bin generation from a .elf which results in a file that is the same length as the FIRMWARE_SIZE.
352 # These 'dd' commands will pad a short binary to length FIRMWARE_SIZE.
353 $(V1
) dd if
=/dev
/zero ibs
=1k count
=$(FIRMWARE_SIZE
) of
=$(TARGET_BIN
)
354 $(V1
) dd if
=$(TARGET_UNPATCHED_BIN
) of
=$(TARGET_BIN
) conv
=notrunc
356 @echo
"Generating MD5 hash of binary" "$(STDOUT)"
357 $(V1
) openssl dgst
-md5
$(TARGET_BIN
) > $(TARGET_UNPATCHED_BIN
).md5
359 @echo
"Patching MD5 hash into binary" "$(STDOUT)"
360 $(V1
) cat
$(TARGET_UNPATCHED_BIN
).md5 | awk
'{printf("%08x: %s",(1024*$(FIRMWARE_SIZE))-16,$$2);}' | xxd
-r
- $(TARGET_BIN
)
361 $(V1
) echo
$(FIRMWARE_SIZE
) | awk
'{printf("-s 0x%08x -l 16 -c 16 %s",(1024*$$1)-16,"$(TARGET_BIN)");}' | xargs xxd
363 # Note: From the objcopy manual "If you do not specify outfile, objcopy creates a temporary file and destructively renames the result with the name of infile"
364 # Due to this a temporary file must be created and removed, even though we're only extracting data from the input file.
365 # If this temporary file is NOT used the $(TARGET_ELF) is modified, and running make a second time will result in
366 # a) regeneration of $(TARGET_BIN), and
367 # b) the results of $(TARGET_BIN) will not be as expected.
368 @echo
"Extracting HASH section from unpatched EXST elf $(TARGET_ELF)" "$(STDOUT)"
369 $(OBJCOPY
) $(TARGET_ELF
) $(TARGET_EXST_ELF
).tmp
--dump-section .exst_hash
=$(TARGET_EXST_HASH_SECTION_FILE
) -j .exst_hash
370 rm $(TARGET_EXST_ELF
).tmp
372 @echo
"Patching MD5 hash into HASH section" "$(STDOUT)"
373 $(V1
) cat
$(TARGET_UNPATCHED_BIN
).md5 | awk
'{printf("%08x: %s",64-16,$$2);}' | xxd
-r
- $(TARGET_EXST_HASH_SECTION_FILE
)
375 $(V1
) @echo
"Patching updated HASH section into $(TARGET_EXST_ELF)" "$(STDOUT)"
376 $(OBJCOPY
) $(TARGET_ELF
) $(TARGET_EXST_ELF
) --update-section .exst_hash
=$(TARGET_EXST_HASH_SECTION_FILE
)
378 $(V1
) $(READELF
) -S
$(TARGET_EXST_ELF
)
379 $(V1
) $(READELF
) -l
$(TARGET_EXST_ELF
)
381 $(TARGET_HEX
): $(TARGET_BIN
)
382 $(if
$(EXST_ADJUST_VMA
),,$(error
"EXST_ADJUST_VMA not specified"))
384 @echo
"Creating EXST HEX from patched EXST BIN $(TARGET_BIN), VMA Adjust $(EXST_ADJUST_VMA)" "$(STDOUT)"
385 $(V1
) $(OBJCOPY
) -I binary
-O ihex
--adjust-vma
=$(EXST_ADJUST_VMA
) $(TARGET_BIN
) $@
389 $(TARGET_ELF
): $(TARGET_OBJS
) $(LD_SCRIPT
) $(LD_SCRIPTS
)
390 @echo
"Linking $(TARGET_NAME)" "$(STDOUT)"
391 $(V1
) $(CROSS_CC
) -o
$@
$(filter-out %.
ld,$^
) $(LD_FLAGS
)
392 $(V1
) $(SIZE
) $(TARGET_ELF
)
396 ## compile_file takes two arguments: (1) optimisation description string and (2) optimisation compiler flag
398 echo
"%% ($(1)) $<" "$(STDOUT)" && \
399 $(CROSS_CC
) -c
-o
$@
$(CFLAGS
) $(2) $<
403 $(TARGET_OBJ_DIR
)/%.o
: %.c
404 $(V1
) mkdir
-p
$(dir $@
)
405 $(V1
) $(if
$(findstring $<,$(NOT_OPTIMISED_SRC
)), \
406 $(call compile_file
,not optimised
, $(CC_NO_OPTIMISATION
)) \
408 $(call compile_file
,debug
,$(CC_DEBUG_OPTIMISATION
)) \
411 $(TARGET_OBJ_DIR
)/%.o
: %.c
412 $(V1
) mkdir
-p
$(dir $@
)
413 $(V1
) $(if
$(findstring $<,$(NOT_OPTIMISED_SRC
)), \
414 $(call compile_file
,not optimised
,$(CC_NO_OPTIMISATION
)) \
416 $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SPEED_OPTIMISED_SRC
)), \
417 $(call compile_file
,speed optimised
,$(CC_SPEED_OPTIMISATION
)) \
419 $(if
$(findstring $(subst .
/src
/main
/,,$<),$(SIZE_OPTIMISED_SRC
)), \
420 $(call compile_file
,size optimised
,$(CC_SIZE_OPTIMISATION
)) \
422 $(call compile_file
,optimised
,$(CC_DEFAULT_OPTIMISATION
)) \
429 $(TARGET_OBJ_DIR
)/%.o
: %.s
430 $(V1
) mkdir
-p
$(dir $@
)
431 @echo
"%% $(notdir $<)" "$(STDOUT)"
432 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
434 $(TARGET_OBJ_DIR
)/%.o
: %.S
435 $(V1
) mkdir
-p
$(dir $@
)
436 @echo
"%% $(notdir $<)" "$(STDOUT)"
437 $(V1
) $(CROSS_CC
) -c
-o
$@
$(ASFLAGS
) $<
440 ## all : Build all currently built targets
443 ## all_all : Build all targets (including legacy / unsupported)
444 all_all
: $(VALID_TARGETS
)
447 $(V0
) @echo
"Building $@" && \
448 $(MAKE
) hex TARGET
=$@
&& \
449 echo
"Building $@ succeeded."
454 TARGETS_CLEAN
= $(addsuffix _clean
,$(VALID_TARGETS
))
456 ## clean : clean up temporary / machine-generated files
458 @echo
"Cleaning $(TARGET_NAME)"
459 $(V0
) rm -f
$(CLEAN_ARTIFACTS
)
460 $(V0
) rm -rf
$(TARGET_OBJ_DIR
)
461 @echo
"Cleaning $(TARGET_NAME) succeeded."
463 ## test_clean : clean up temporary / machine-generated files (tests)
468 $(V0
) cd src
/test && $(MAKE
) clean || true
470 ## <TARGET>_clean : clean up one specific target (alias for above)
472 $(V0
) $(MAKE
) -j TARGET
=$(subst _clean
,,$@
) clean
474 ## clean_all : clean all valid targets
475 clean_all
: $(TARGETS_CLEAN
) test_clean
477 TARGETS_FLASH
= $(addsuffix _flash
,$(VALID_TARGETS
))
479 ## <TARGET>_flash : build and flash a target
481 $(V0
) $(MAKE
) hex TARGET
=$(subst _flash
,,$@
)
482 ifneq (,$(findstring /dev
/ttyUSB
,$(SERIAL_DEVICE
)))
483 $(V0
) $(MAKE
) tty_flash TARGET
=$(subst _flash
,,$@
)
485 $(V0
) $(MAKE
) dfu_flash TARGET
=$(subst _flash
,,$@
)
488 ## tty_flash : flash firmware (.hex) onto flight controller via a serial port
490 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
491 $(V0
) echo
-n
'R' > $(SERIAL_DEVICE
)
492 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
494 ## dfu_flash : flash firmware (.bin) onto flight controller via a DFU mode
496 ifneq (no-port-found
,$(SERIAL_DEVICE
))
497 # potentially this is because the MCU already is in DFU mode, try anyway
498 $(V0
) echo
-n
'R' > $(SERIAL_DEVICE
)
501 $(V0
) $(MAKE
) $(TARGET_DFU
)
502 $(V0
) dfu-util
-a
0 -D
$(TARGET_DFU
) -s
:leave
504 st-flash_
$(TARGET
): $(TARGET_BIN
)
505 $(V0
) st-flash
--reset write
$< 0x08000000
507 ## st-flash : flash firmware (.bin) onto flight controller
508 st-flash
: st-flash_
$(TARGET
)
510 ifneq ($(OPENOCD_COMMAND
),)
511 openocd-gdb
: $(TARGET_ELF
)
512 $(V0
) $(OPENOCD_COMMAND
) & $(CROSS_GDB
) $(TARGET_ELF
) -ex
"target remote localhost:3333" -ex
"load"
515 TARGETS_ZIP
= $(addsuffix _zip
,$(VALID_TARGETS
))
517 ## <TARGET>_zip : build target and zip it (useful for posting to GitHub)
519 $(V0
) $(MAKE
) hex TARGET
=$(subst _zip
,,$@
)
520 $(V0
) $(MAKE
) zip TARGET
=$(subst _zip
,,$@
)
523 $(V0
) zip
$(TARGET_ZIP
) $(TARGET_HEX
)
526 $(V0
) $(MAKE
) -j
$(TARGET_BIN
)
529 $(V0
) $(MAKE
) -j
$(TARGET_HEX
)
531 TARGETS_REVISION
= $(addsuffix _rev
,$(VALID_TARGETS
))
532 ## <TARGET>_rev : build target and add revision to filename
534 $(V0
) $(MAKE
) hex REV
=yes TARGET
=$(subst _rev
,,$@
)
536 all_rev
: $(addsuffix _rev
,$(CI_TARGETS
))
538 unbrick_
$(TARGET
): $(TARGET_HEX
)
539 $(V0
) stty
-F
$(SERIAL_DEVICE
) raw speed
115200 -crtscts cs8
-parenb
-cstopb
-ixon
540 $(V0
) stm32flash
-w
$(TARGET_HEX
) -v
-g
0x0 -b
115200 $(SERIAL_DEVICE
)
542 ## unbrick : unbrick flight controller
543 unbrick
: unbrick_
$(TARGET
)
545 ## cppcheck : run static analysis on C source code
546 cppcheck
: $(CSOURCES
)
549 cppcheck-result.xml
: $(CSOURCES
)
550 $(V0
) $(CPPCHECK
) --xml-version
=2 2> cppcheck-result.xml
559 ## version : print firmware version
563 ## help : print this help message and exit
564 help
: Makefile make
/tools.mk
566 @echo
"Makefile for the $(FORKNAME) firmware"
569 @echo
" make [V=<verbosity>] [TARGET=<target>] [OPTIONS=\"<options>\"]"
571 @echo
" make <target> [V=<verbosity>] [OPTIONS=\"<options>\"]"
573 @echo
"Valid TARGET values are: $(VALID_TARGETS)"
575 @sed
-n
's/^## //p' $?
577 ## targets : print a list of all valid target platforms (for consumption by scripts)
579 @echo
"Valid targets: $(VALID_TARGETS)"
580 @echo
"Built targets: $(CI_TARGETS)"
581 @echo
"Default target: $(TARGET)"
586 ## target-mcu : print the MCU type of the target
590 ## targets-by-mcu : make all targets that have a MCU_TYPE mcu
592 $(V1
) for target in
$${TARGETS}; do \
593 TARGET_MCU_TYPE
=$$($(MAKE
) -s TARGET
=$${target} target-mcu
); \
594 if
[ "$${TARGET_MCU_TYPE}" = "$${MCU_TYPE}" ]; then \
595 if
[ "$${DO_BUILD}" = 1 ]; then \
596 echo
"Building target $${target}..."; \
597 $(MAKE
) TARGET
=$${target}; \
598 if
[ $$?
-ne
0 ]; then \
599 echo
"Building target $${target} failed, aborting."; \
603 echo
-n
"$${target} "; \
609 ## targets-f4 : make all F4 targets
611 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F4 TARGETS
="$(VALID_TARGETS)" DO_BUILD
=1
614 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F4 TARGETS
="$(VALID_TARGETS)"
617 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F4 TARGETS
="$(CI_TARGETS)"
619 ## targets-f7 : make all F7 targets
621 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F7 TARGETS
="$(VALID_TARGETS)" DO_BUILD
=1
624 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F7 TARGETS
="$(VALID_TARGETS)"
627 $(V1
) $(MAKE
) -s targets-by-mcu MCU_TYPE
=STM32F7 TARGETS
="$(CI_TARGETS)"
629 ## test : run the Betaflight test suite
630 ## junittest : run the Betaflight test suite, producing Junit XML result files.
631 ## 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)
632 ## test-all: run the Betaflight test suite including all per-target expanded tests
633 test junittest test-all test-representative
:
634 $(V0
) cd src
/test && $(MAKE
) $@
636 ## test_help : print the help message for the test suite (including a list of the available tests)
638 $(V0
) cd src
/test && $(MAKE
) help
640 ## test_versions : print the compiler versions used for the test suite
642 $(V0
) cd src
/test && $(MAKE
) versions
644 ## test_% : run test 'test_%' from the test suite
646 $(V0
) cd src
/test && $(MAKE
) $@
648 $(TARGET_EF_HASH_FILE
):
649 $(V1
) mkdir
-p
$(dir $@
)
650 $(V0
) rm -f
$(TARGET_OBJ_DIR
)/.efhash_
*
651 @echo
"EF HASH -> $(TARGET_EF_HASH_FILE)"
652 $(V1
) touch
$(TARGET_EF_HASH_FILE
)
654 # rebuild everything when makefile changes or the extra flags have changed
655 $(TARGET_OBJS
): $(TARGET_EF_HASH_FILE
) Makefile
$(TARGET_DIR
)/target.mk
$(wildcard make
/*)
657 # include auto-generated dependencies
658 -include $(TARGET_DEPS
)