CMS Debug Mode fix
[betaflight.git] / Makefile
blob2e798d70c594c1c86d453135ec27c670b8659f3b
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 ?= BETAFLIGHTF3
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/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/main/target/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 ?= BETAFLIGHTF3 OMNIBUSF4 SPRACINGF7DUAL 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)
431 flash_$(TARGET): $(TARGET_HEX)
432 $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
433 $(V0) echo -n 'R' >$(SERIAL_DEVICE)
434 $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
436 ## flash : flash firmware (.hex) onto flight controller
437 flash: flash_$(TARGET)
439 st-flash_$(TARGET): $(TARGET_BIN)
440 $(V0) st-flash --reset write $< 0x08000000
442 ## st-flash : flash firmware (.bin) onto flight controller
443 st-flash: st-flash_$(TARGET)
445 ifneq ($(OPENOCD_COMMAND),)
446 openocd-gdb: $(TARGET_ELF)
447 $(V0) $(OPENOCD_COMMAND) & $(CROSS_GDB) $(TARGET_ELF) -ex "target remote localhost:3333" -ex "load"
448 endif
450 binary:
451 $(V0) $(MAKE) -j $(TARGET_BIN)
453 hex:
454 $(V0) $(MAKE) -j $(TARGET_HEX)
456 unbrick_$(TARGET): $(TARGET_HEX)
457 $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
458 $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
460 ## unbrick : unbrick flight controller
461 unbrick: unbrick_$(TARGET)
463 ## cppcheck : run static analysis on C source code
464 cppcheck: $(CSOURCES)
465 $(V0) $(CPPCHECK)
467 cppcheck-result.xml: $(CSOURCES)
468 $(V0) $(CPPCHECK) --xml-version=2 2> cppcheck-result.xml
470 # mkdirs
471 $(DL_DIR):
472 mkdir -p $@
474 $(TOOLS_DIR):
475 mkdir -p $@
477 $(BUILD_DIR):
478 mkdir -p $@
480 ## version : print firmware version
481 version:
482 @echo $(FC_VER)
484 ## help : print this help message and exit
485 help: Makefile make/tools.mk
486 @echo ""
487 @echo "Makefile for the $(FORKNAME) firmware"
488 @echo ""
489 @echo "Usage:"
490 @echo " make [V=<verbosity>] [TARGET=<target>] [OPTIONS=\"<options>\"]"
491 @echo "Or:"
492 @echo " make <target> [V=<verbosity>] [OPTIONS=\"<options>\"]"
493 @echo ""
494 @echo "Valid TARGET values are: $(VALID_TARGETS)"
495 @echo ""
496 @sed -n 's/^## //p' $?
498 ## targets : print a list of all valid target platforms (for consumption by scripts)
499 targets:
500 @echo "Valid targets: $(VALID_TARGETS)"
501 @echo "Supported targets: $(SUPPORTED_TARGETS)"
502 @echo "Unsupported targets: $(UNSUPPORTED_TARGETS)"
503 @echo "Target: $(TARGET)"
504 @echo "Base target: $(BASE_TARGET)"
505 @echo "targets-group-1: $(GROUP_1_TARGETS)"
506 @echo "targets-group-2: $(GROUP_2_TARGETS)"
507 @echo "targets-group-3: $(GROUP_3_TARGETS)"
508 @echo "targets-group-4: $(GROUP_4_TARGETS)"
509 @echo "targets-group-rest: $(GROUP_OTHER_TARGETS)"
511 @echo "targets-group-1: $(words $(GROUP_1_TARGETS)) targets"
512 @echo "targets-group-2: $(words $(GROUP_2_TARGETS)) targets"
513 @echo "targets-group-3: $(words $(GROUP_3_TARGETS)) targets"
514 @echo "targets-group-4: $(words $(GROUP_4_TARGETS)) targets"
515 @echo "targets-group-rest: $(words $(GROUP_OTHER_TARGETS)) targets"
516 @echo "total in all groups $(words $(SUPPORTED_TARGETS)) targets"
518 ## target-mcu : print the MCU type of the target
519 target-mcu:
520 @echo $(TARGET_MCU)
522 ## targets-by-mcu : make all targets that have a MCU_TYPE mcu
523 targets-by-mcu:
524 $(V1) for target in $(VALID_TARGETS); do \
525 TARGET_MCU_TYPE=$$($(MAKE) -s TARGET=$${target} target-mcu); \
526 if [ "$${TARGET_MCU_TYPE}" = "$${MCU_TYPE}" ]; then \
527 if [ "$${DO_BUILD}" = 1 ]; then \
528 echo "Building target $${target}..."; \
529 $(MAKE) TARGET=$${target}; \
530 if [ $$? -ne 0 ]; then \
531 echo "Building target $${target} failed, aborting."; \
532 exit 1; \
533 fi; \
534 else \
535 echo -n "$${target} "; \
536 fi; \
537 fi; \
538 done
539 @echo
541 ## targets-f3 : make all F3 targets
542 targets-f3:
543 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F3 DO_BUILD=1
545 targets-f3-print:
546 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F3
548 ## targets-f4 : make all F4 targets
549 targets-f4:
550 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F4 DO_BUILD=1
552 targets-f4-print:
553 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F4
555 ## targets-f7 : make all F7 targets
556 targets-f7:
557 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F7 DO_BUILD=1
559 targets-f7-print:
560 $(V1) $(MAKE) -s targets-by-mcu MCU_TYPE=STM32F7
562 ## test : run the Betaflight test suite
563 ## junittest : run the Betaflight test suite, producing Junit XML result files.
564 ## 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)
565 ## test-all: run the Betaflight test suite including all per-target expanded tests
566 test junittest test-all test-representative:
567 $(V0) cd src/test && $(MAKE) $@
569 ## test_help : print the help message for the test suite (including a list of the available tests)
570 test_help:
571 $(V0) cd src/test && $(MAKE) help
573 ## test_% : run test 'test_%' from the test suite
574 test_%:
575 $(V0) cd src/test && $(MAKE) $@
578 check-target-independence:
579 $(V1) for test_target in $(VALID_TARGETS); do \
580 FOUND=$$(grep -rE "\W$${test_target}(\W.*)?$$" src/main | grep -vE "(//)|(/\*).*\W$${test_target}(\W.*)?$$" | grep -vE "^src/main/target"); \
581 if [ "$${FOUND}" != "" ]; then \
582 echo "Target dependencies for target '$${test_target}' found:"; \
583 echo "$${FOUND}"; \
584 exit 1; \
585 fi; \
586 done
588 check-fastram-usage-correctness:
589 $(V1) NON_TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM_ZERO_INIT\W.*=.*" src/main/ | grep -Ev "=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \
590 if [ "$${NON_TRIVIALLY_INITIALIZED}" != "" ]; then \
591 echo "Non-trivially initialized FAST_RAM_ZERO_INIT variables found, use FAST_RAM instead:"; \
592 echo "$${NON_TRIVIALLY_INITIALIZED}"; \
593 exit 1; \
594 fi; \
595 TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM\W.*;" src/main/ | grep -v "="); \
596 EXPLICITLY_TRIVIALLY_INITIALIZED=$$(grep -Ern "\W?FAST_RAM\W.*;" src/main/ | grep -E "=\s*(false|NULL|0(\.0*f?)?)\s*[,;]"); \
597 if [ "$${TRIVIALLY_INITIALIZED}$${EXPLICITLY_TRIVIALLY_INITIALIZED}" != "" ]; then \
598 echo "Trivially initialized FAST_RAM variables found, use FAST_RAM_ZERO_INIT instead to save FLASH:"; \
599 echo "$${TRIVIALLY_INITIALIZED}\n$${EXPLICITLY_TRIVIALLY_INITIALIZED}"; \
600 exit 1; \
603 check-platform-included:
604 $(V1) PLATFORM_NOT_INCLUDED=$$(find src/main -type d -name target -prune -o -type f -name \*.c -exec grep -L "^#include \"platform.h\"" {} \;); \
605 if [ "$$(echo $${PLATFORM_NOT_INCLUDED} | grep -v -e '^$$' | wc -l)" -ne 0 ]; then \
606 echo "The following compilation units do not include the required target specific configuration provided by 'platform.h':"; \
607 echo "$${PLATFORM_NOT_INCLUDED}"; \
608 exit 1; \
611 # rebuild everything when makefile changes
612 $(TARGET_OBJS): Makefile $(TARGET_DIR)/target.mk $(wildcard make/*)
615 # include auto-generated dependencies
616 -include $(TARGET_DEPS)