囉嗦:越會一件事情,就會忘了不會一件事情的感覺。前段時間在微信上看到這句話,深以爲然,這就是爲什麼很多時候懂的人覺得自己講的很清楚了,但是不懂的人卻覺得並沒有講的清楚明瞭,簡單易懂。以下把自己學習理解的過程記錄下來,歡迎大神指點。
1.PX4的makefile當中用到的Makefile語法
本小節給出Makefile文件中使用到部分語法的簡單說明,如果想要完全理解、讀懂、甚至編寫Makefile,需要仔細閱讀《GNU Makefile 中文手冊》。
:= --直接式變量展開,引用的變量或者函數都會被其定義值替換,如果:= 右端爲空,可能是賦值了一個空格;
= 及 define --遞歸式變量展開,在引用處只是文本替換,在使用時纔會展開;
$ --取變量值操作,可以嵌套使用,例如$($(X))。同時可以用於調用內嵌函數:$(FCTION ARGUMENTS);
?= --條件賦值,只有變量尚未被賦值的情況下,才能將?=後邊的值賦給變量;
patsubst --模式替換,引用格式:$(patsubst A,B,(VAR)), VAR表示變量,下同,例如:$(patsubst %.c %.o, a.c,b.c);
wildcard --通用符,引用格式如:$(wildcard *.c),當前路徑下的所有.c結尾的文件;
+= --追加賦值,VAR定義時給一個基本值,+=就在原來的變量基礎上增加一 個賦值,注意不是覆蓋;
% --模式字符,例如:%.c 表示後綴爲.c模式的文件;
ifeq、ifneq --條件判斷關鍵字;
ifdef、ifndef --條件判斷關鍵字;
// + --命令行前使用+,表示;
subset --字符串替換,例如:$(subst,e,E,feet),結果爲:fEEt;
filter --過濾函數,例如:$(filter %.c %.s, $(VAR)),返回VAR中所有後綴爲.c,.s的文件;
sort --將字符串升序排列,並去掉重複單詞;
word --取單詞函數,$(word 1, text),取text的第1個單詞;
wordlist --取字符串函數,$(word 1,5, text)表示取text的第1個到第5個單詞字串;
words --統計字符串中單詞數目;
firstword --取字符串的第一個單詞,lastword同理取最後一個單詞;
dir --取目錄,包含指定文件的路徑目錄;
basename --取前綴函數,例如 $(basename src/foo.c),返回值爲src/foo;
foreach --循環執行;
call --實現用戶自定義函數的引用,$(call 函數,參數1,參數2,...);
@echo --在界面上輸出build信息;
eval --比較複雜,沒看懂,構造一個依賴關係鏈,其主要功能是根據參 數關係、結構,對它們進行替換展開;
shell --大致功能是將shell的參數放入shell環境中執行並返回結果;
error --$(error TEXT...),返回錯誤信息並退出執行;
MAKECMDGOALS
-(用戶輸入的)命令行參數;
$@ -表示規則的目標文件名,一般與改符號上文中的文件相對應,例如前邊出現.C,可能默認就是對應的.O文件
2.PX4的makefile編譯過程分析
本次編譯過程基於Windows下的PX4Toolchain中的PX4 Console模式,方法參考PX4開發手冊或網上教程,輸入的指令爲:
以下是對Makefile原文註解:
- ############################################################################
- #
- # Copyright (c) 2015 - 2017 PX4 Development Team. All rights reserved.
- #
- #部分版權、使用等的申明,此處刪去
- #
- ############################################################################
- # Enforce the presence of the GIT repository
- #
- # We depend on our submodules, so we have to prevent attempts to
- # compile without it being present.
- # 強制性保證GIT repository存在,由於於PX4依賴於其子模塊,
- # 所以必須防止在缺少子模塊的情況下編譯,從而有了此處的強制檢查
- # $(wildcard .git)用來獲取工作路徑下所有後綴爲.git的文件,執行GIT檢查
- # ifeq...endif爲條件判斷
- ifeq ($(wildcard .git),)
- $(error YOU HAVE TO USE GIT TO DOWNLOAD THIS REPOSITORY. ABORTING.)
- endif
- # Help
- # --------------------------------------------------------------------
- # Don't be afraid of this makefile, it is just passing
- # arguments to cmake to allow us to keep the wiki pages etc.
- # that describe how to build the px4 firmware
- # the same even when using cmake instead of make.
- # 這個Makefile主要是講怎麼傳遞參數,怎麼編譯px4固件,同時使用make和cmake是一樣的
- # Example usage:三種使用方法示例
- #
- # make px4fmu-v2_default (builds)
- # make px4fmu-v2_default upload (builds and uploads)
- # make px4fmu-v2_default test (builds and tests)
- #
- # This tells cmake to build the nuttx px4fmu-v2 default config in the
- # directory build/nuttx_px4fmu-v2_default and then call make
- # in that directory with the target upload.
- # 以上的命令告訴cmake使用build/nuttx_px4fmu-v2_default的默認配置來build nuttx
- # px4fmu,然後調用該路徑下的make來上傳target(編譯好的文件)
- # 明確設置默認的build目標,編譯目標爲all,編譯規則爲posix_sitl_default,如果make不指定編譯
- # 目標就會編譯默認目標,此處輸出的編譯目標是px4fmu-v2_default
- all: posix_sitl_default # (默認build就是這個)
- # Parsing 解析
- # --------------------------------------------------------------------
- # assume 1st argument passed is the main target, the
- # rest are arguments to pass to the makefile generated
- # by cmake in the subdirectory
- # 假設第傳遞的第一個參數是主目標,餘下的參數是傳輸給子路徑下的cmake產生的makefile的
- # MAKECMDGOALS 就是輸出的命令行參數px4fmu-v2_default
- # FIRST_ARG 變量值就是px4fmu
- FIRST_ARG := $(firstword$(MAKECMDGOALS))
- # ARGS的變量值就是default
- ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
- #如果j爲賦值,就將j賦值爲4
- j ?= 4
- # ninja賦值給NINJA_BIN,ninja貌似是一套編譯工具,在此處沒有用到
- NINJA_BIN := ninja
- ifndef NO_NINJA_BUILD
- NINJA_BUILD := $(shell $(NINJA_BIN) --version 2>/dev/null)
- ifndef NINJA_BUILD
- NINJA_BIN:=ninja-build
- NINJA_BUILD := $(shell $(NINJA_BIN) --version 2>/dev/null)
- endif
- endif
- ifdef NINJA_BUILD
- PX4_CMAKE_GENERATOR := Ninja
- PX4_MAKE := $(NINJA_BIN)
- ifdef VERBOSE
- PX4_MAKE_ARGS := -v
- else
- PX4_MAKE_ARGS :=
- endif
- else
- #SYSTEMROOT C:\windows
- ifdef SYSTEMROOT
- # Windows 在windows系統下
- PX4_CMAKE_GENERATOR := "MSYS\ Makefiles"
- #在其餘系統下,主要是Linux
- else
- PX4_CMAKE_GENERATOR := "Unix\ Makefiles"
- endif
- #$(MAKE) 其實就是make命令
- PX4_MAKE = $(MAKE)
- #設置編譯參數 -j4 --no-print-directory:同一時刻可同時允許執行4行命令,
- #禁止所有關於目錄信息的打印
- PX4_MAKE_ARGS = -j$(j) --no-print-directory
- endif
- #firmware所在的文件夾,我的是:/f/px4/firmware
- SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
- # check if replay env variable is set & set build dir accordingly
- # 檢查是否定義relay環境變量,並更改build目錄的後綴:BUILD_DIR_SUFFIX
- ifdef replay
- BUILD_DIR_SUFFIX := _replay
- else
- BUILD_DIR_SUFFIX :=
- endif
- # additional config parameters passed to cmake
- # 添加額外的配置參數
- ifdef EXTERNAL_MODULES_LOCATION
- CMAKE_ARGS += -DEXTERNAL_MODULES_LOCATION:STRING=$(EXTERNAL_MODULES_LOCATION)
- endif
- ifdef PX4_CMAKE_BUILD_TYPE
- CMAKE_ARGS += -DCMAKE_BUILD_TYPE=${PX4_CMAKE_BUILD_TYPE}
- endif
- # Functions 函數
- # --------------------------------------------------------------------
- # 描述如何build一個cmake配置文件, 定義了cmke-build命令規則
- define cmake-build
- +@$(eval BUILD_DIR =$(SRC_DIR)/build/$@$(BUILD_DIR_SUFFIX))
- +@if [ $(PX4_CMAKE_GENERATOR) = "Ninja" ] && [ -e $(BUILD_DIR)/Makefile ]; then rm -rf $(BUILD_DIR); fi
- #以下命令是就是創建build文件夾,用cmake進行編譯,然後再刪除build文件夾
- #本次編譯就是走這個流程,注意這裏的cmake編譯的應該是CMakelist.txt文件,不是直接的.cmake文件
- #$(2)應該是第二個參數,也就是傳遞的CMakelist.txt的路徑,$(1)應該是傳遞的編譯目標的名稱,本次是nuttx_px4fmu-v2_default
- +@if [ ! -e $(BUILD_DIR)/CMakeCache.txt ]; then mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake $(2) -G"$(PX4_CMAKE_GENERATOR)" $(CMAKE_ARGS) -DCONFIG=$(1) || (rm -rf $(BUILD_DIR)); fi
- +@(cd $(BUILD_DIR) && $(PX4_MAKE) $(PX4_MAKE_ARGS) $(ARGS))
- endef
- COLOR_BLUE = \033[0;34m
- NO_COLOR = \033[m
- define colorecho
- +@echo "${COLOR_BLUE}${1} ${NO_COLOR}"
- endef
- # Get a list of all config targets cmake/configs/*.cmake
- # 獲得所有cmake/configs/下所有的cmake目標文件,
- # 本次編譯的nuttx_px4fmu-v2_defualt就是從這裏獲得
- ALL_CONFIG_TARGETS :=$(basename $(shell find "$(SRC_DIR)/cmake/configs" -maxdepth 1 ! -name '*_common*' ! -name '*_sdflight_*' -name '*.cmake' -print | sed -e 's:^.*/::' | sort))
- # Strip off leading nuttx_
- # 去掉NUTTX_前綴並返回,這樣NUTTX_CONFIG_TARGETS就是包含了所有關於NUTTX配置的一個組
- NUTTX_CONFIG_TARGETS := $(patsubst nuttx_%,%,$(filter nuttx_%,$(ALL_CONFIG_TARGETS)))
- # ADD CONFIGS HERE 在此添加配置
- # --------------------------------------------------------------------
- # Do not put any spaces between function arguments.
- # All targets. 所有的目標
- # $(ALL_CONFIG_TARGETS)指代了所有的編譯目標,
- # 每個目標都執行$(call cmake-build,$@,$(SRC_DIR))這個命令行
- # 這是一種簡便的書寫模式
- $(ALL_CONFIG_TARGETS):
- $(call cmake-build,$@,$(SRC_DIR))
- # Abbreviated config targets.
- # nuttx_ is left off by default; provide a rule to allow that. 只和nuttx相關的目標
- # $(NUTTX_CONFIG_TARGETS):指代了所有的編譯目標,在本次就是px4fmu-v2_default
- # 每個目標都執行$(call cmake-build,$@,$(SRC_DIR))這個命令行,等價於
- # $(call cmake-build,nuttx_px4fmu-v2_default,/f/px4/firmware),本次編譯就是由此處進入到對
- # nuttx_px4fmu-v2_default的編譯
- $(NUTTX_CONFIG_TARGETS):
- $(call cmake-build,nuttx_$@,$(SRC_DIR))
- #######################################################################################
- #
- #從此往後的就是一些僞目標,對本次編譯來講不重要,這些僞目標的作用有:
- #1. 如clean執行清除任務,並不生成可執行目標,這種爲目標的主要作用是執行命令
- #2. 爲了同時創建多個可執行目標,將一個爲目標例如all作爲終極目標,同時將
- # 其依賴多僞目標
- #
- #######################################################################################
- all_nuttx_targets: $(NUTTX_CONFIG_TARGETS)
- posix: posix_sitl_default
- broadcast: posix_sitl_broadcast
- # All targets with just dependencies but no recipe must either be marked as phony (or have the special @: as recipe).
- # 通過.PHONY將其冒號後的目標申明爲僞目標,主要爲了防止一些意外情況
- .PHONY: all posix broadcast all_nuttx_targets
- # Multi- config targets. 多目標(板)配置
- eagle_default: posix_eagle_default qurt_eagle_default
- eagle_rtps: posix_eagle_rtps qurt_eagle_default
- eagle_legacy_default: posix_eagle_legacy qurt_eagle_legacy
- excelsior_default: posix_excelsior_default qurt_excelsior_default
- excelsior_rtps: posix_excelsior_rtps qurt_excelsior_default
- excelsior_legacy_default: posix_excelsior_legacy qurt_excelsior_legacy
- .PHONY: eagle_default eagle_rtps eagle_legacy_default
- .PHONY: excelsior_default excelsior_rtps excelsior_legacy_default
- # Other targets
- # --------------------------------------------------------------------
- .PHONY: qgc_firmware px4fmu_firmware misc_qgc_extra_firmware alt_firmware check_rtps
- # QGroundControl flashable NuttX firmware
- qgc_firmware: px4fmu_firmware misc_qgc_extra_firmware
- # px4fmu NuttX firmware
- px4fmu_firmware: \
- check_px4io-v2_default \
- check_px4fmu-v2_default \
- check_px4fmu-v3_default \
- check_px4fmu-v4_default \
- check_px4fmu-v4pro_default \
- check_px4fmu-v5_default \
- sizes
- misc_qgc_extra_firmware: \
- check_aerocore2_default \
- check_aerofc-v1_default \
- check_auav-x21_default \
- check_crazyflie_default \
- check_mindpx-v2_default \
- check_px4fmu-v2_lpe \
- check_tap-v1_default \
- sizes
- # Other NuttX firmware
- alt_firmware: \
- check_nxphlite-v3_default \
- check_px4-same70xplained-v1_default \
- check_px4-stm32f4discovery_default \
- check_px4cannode-v1_default \
- check_px4esc-v1_default \
- check_px4nucleoF767ZI-v1_default \
- check_s2740vc-v1_default \
- sizes
- # builds with RTPS
- check_rtps: \
- check_px4fmu-v3_rtps \
- check_px4fmu-v4_rtps \
- check_px4fmu-v4pro_rtps \
- check_posix_sitl_rtps \
- sizes
- .PHONY: sizes check quick_check check_rtps uorb_graphs
- sizes:
- @-find build -name *.elf -type f | xargs size 2> /dev/null || :
- # All default targets that don't require a special build environment
- check: check_posix_sitl_default px4fmu_firmware misc_qgc_extra_firmware alt_firmware tests check_format
- # quick_check builds a single nuttx and posix target, runs testing, and checks the style
- quick_check: check_posix_sitl_default check_px4fmu-v4pro_default tests check_format
- check_%:
- @echo
- $(call colorecho,"Building" $(subst check_,,$@))
- @$(MAKE) --no-print-directory $(subst check_,,$@)
- @echo
- uorb_graphs:
- @./Tools/uorb_graph/create_from_startupscript.sh
- @./Tools/uorb_graph/create.py --src-path src --exclude-path src/examples --file Tools/uorb_graph/graph_full
- @$(MAKE) --no-print-directory px4fmu-v2_default uorb_graph
- @$(MAKE) --no-print-directory px4fmu-v4_default uorb_graph
- @$(MAKE) --no-print-directory posix_sitl_default uorb_graph
- .PHONY: coverity_scan
- coverity_scan: posix_sitl_default
- # Documentation
- # --------------------------------------------------------------------
- .PHONY: parameters_metadata airframe_metadata module_documentation px4_metadata
- parameters_metadata:
- @python $(SRC_DIR)/src/modules/systemlib/param/px_process_params.py -s `find $(SRC_DIR)/src -maxdepth 4 -type d` --inject-xml $(SRC_DIR)/src/modules/systemlib/param/parameters_injected.xml --markdown
- @python $(SRC_DIR)/src/modules/systemlib/param/px_process_params.py -s `find $(SRC_DIR)/src -maxdepth 4 -type d` --inject-xml $(SRC_DIR)/src/modules/systemlib/param/parameters_injected.xml --xml
- airframe_metadata:
- @python $(SRC_DIR)/Tools/px_process_airframes.py -v -a $(SRC_DIR)/ROMFS/px4fmu_common/init.d --markdown
- @python $(SRC_DIR)/Tools/px_process_airframes.py -v -a $(SRC_DIR)/ROMFS/px4fmu_common/init.d --xml
- module_documentation:
- @python $(SRC_DIR)/Tools/px_process_module_doc.py -v --markdown $(SRC_DIR)/modules --src-path $(SRC_DIR)/src
- px4_metadata: parameters_metadata airframe_metadata module_documentation
- # Astyle
- # --------------------------------------------------------------------
- .PHONY: check_format format
- check_format:
- $(call colorecho,"Checking formatting with astyle")
- @$(SRC_DIR)/Tools/astyle/check_code_style_all.sh
- @cd $(SRC_DIR) &&git diff --check
- format:
- $(call colorecho,"Formatting with astyle")
- @$(SRC_DIR)/Tools/astyle/check_code_style_all.sh --fix
- # Testing
- # --------------------------------------------------------------------
- .PHONY: tests tests_coverage tests_mission tests_offboard rostest
- tests:
- @$(MAKE) --no-print-directory posix_sitl_default test_results \
- ASAN_OPTIONS="color=always:check_initialization_order=1:detect_stack_use_after_return=1" \
- UBSAN_OPTIONS="color=always"
- tests_coverage:
- @$(MAKE) clean
- @$(MAKE) --no-print-directory posix_sitl_default PX4_CMAKE_BUILD_TYPE=Coverage
- @$(MAKE) --no-print-directory posix_sitl_default sitl_gazebo PX4_CMAKE_BUILD_TYPE=Coverage
- @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_missions.test
- @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_offboard_attctl.test
- @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_offboard_posctl.test
- @$(MAKE) --no-print-directory posix_sitl_default test_coverage_genhtml PX4_CMAKE_BUILD_TYPE=Coverage
- @echo "Open $(SRC_DIR)/build/posix_sitl_default/coverage-html/index.html to see coverage"
- rostest: posix_sitl_default
- @$(MAKE) --no-print-directory posix_sitl_default sitl_gazebo
- tests_mission: rostest
- @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_missions.test
- tests_offboard: rostest
- @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_offboard_attctl.test
- @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_offboard_posctl.test
- # static analyzers (scan-build, clang-tidy, cppcheck)
- # --------------------------------------------------------------------
- .PHONY: scan-build posix_sitl_default-clang clang-tidy clang-tidy-fix clang-tidy-quiet cppcheck check_stack
- scan-build:
- @export CCC_CC=clang
- @export CCC_CXX=clang++
- @rm -rf $(SRC_DIR)/build/posix_sitl_default-scan-build
- @rm -rf $(SRC_DIR)/build/scan-build/report_latest
- @mkdir -p $(SRC_DIR)/build/posix_sitl_default-scan-build
- @cd $(SRC_DIR)/build/posix_sitl_default-scan-build && scan-build cmake $(SRC_DIR) -GNinja -DCONFIG=posix_sitl_default
- @scan-build -o $(SRC_DIR)/build/scan-build cmake --build $(SRC_DIR)/build/posix_sitl_default-scan-build
- @find $(SRC_DIR)/build/scan-build -maxdepth 1 -mindepth 1 -type d -exec cp -r "{}" $(SRC_DIR)/build/scan-build/report_latest \;
- posix_sitl_default-clang:
- @mkdir -p $(SRC_DIR)/build/posix_sitl_default-clang
- @cd $(SRC_DIR)/build/posix_sitl_default-clang && cmake $(SRC_DIR) $(CMAKE_ARGS) -G"$(PX4_CMAKE_GENERATOR)" -DCONFIG=posix_sitl_default -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
- @$(PX4_MAKE) -C $(SRC_DIR)/build/posix_sitl_default-clang
- clang-tidy: posix_sitl_default-clang
- @cd $(SRC_DIR)/build/posix_sitl_default-clang && $(SRC_DIR)/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j) -p .
- # to automatically fix a single check at a time, eg modernize-redundant-void-arg
- # % run-clang-tidy-4.0.py -fix -j4 -checks=-\*,modernize-redundant-void-arg -p .
- clang-tidy-fix: posix_sitl_default-clang
- @cd $(SRC_DIR)/build/posix_sitl_default-clang && $(SRC_DIR)/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j) -fix -p .
- # modified version of run-clang-tidy.py to return error codes and only output relevant results
- clang-tidy-quiet: posix_sitl_default-clang
- @cd $(SRC_DIR)/build/posix_sitl_default-clang && $(SRC_DIR)/Tools/run-clang-tidy.py -header-filter=".*\.hpp" -j$(j) -p .
- # TODO: Fix cppcheck errors then try --enable=warning,performance,portability,style,unusedFunction or --enable=all
- cppcheck: posix_sitl_default
- @mkdir -p $(SRC_DIR)/build/cppcheck
- @cppcheck -i$(SRC_DIR)/src/examples --enable=performance --std=c++11 --std=c99 --std=posix --project=$(SRC_DIR)/build/posix_sitl_default/compile_commands.json --xml-version=2 2> $(SRC_DIR)/build/cppcheck/cppcheck-result.xml > /dev/null
- @cppcheck-htmlreport --source-encoding=ascii --file=$(SRC_DIR)/build/cppcheck/cppcheck-result.xml --report-dir=$(SRC_DIR)/build/cppcheck --source-dir=$(SRC_DIR)/src/
- check_stack: px4fmu-v4pro_default
- @echo "Checking worst case stack usage with checkstack.pl ..."
- @echo " "
- @echo "Top 10:"
- @cd $(SRC_DIR)/build/px4fmu-v4pro_default && mkdir -p stack_usage && arm-none-eabi-objdump -d nuttx_px4fmu-v4pro_default.elf | $(SRC_DIR)/Tools/stack_usage/checkstack.pl arm 0 > stack_usage/checkstack_output.txt 2> stack_usage/checkstack_errors.txt
- @head -n 10 $(SRC_DIR)/build/px4fmu-v4pro_default/stack_usage/checkstack_output.txt | c++filt
- @echo " "
- @echo "Symbols with 'main', 'thread' or 'task':"
- @cat $(SRC_DIR)/build/px4fmu-v4pro_default/stack_usage/checkstack_output.txt | c++filt | grep -E 'thread|main|task'
- # Cleanup
- # --------------------------------------------------------------------
- .PHONY: clean submodulesclean submodulesupdate gazeboclean distclean
- clean:
- @rm -rf $(SRC_DIR)/build
- submodulesclean:
- @git submodule foreach --quiet --recursive git clean -ff -x -d
- @git submodule update --quiet --init --recursive --force || true
- @git submodule sync --recursive
- @git submodule update --init --recursive --force
- submodulesupdate:
- @git submodule update --quiet --init --recursive || true
- @git submodule sync --recursive
- @git submodule update --init --recursive
- gazeboclean:
- @rm -rf ~/.gazebo/*
- distclean: gazeboclean
- @git submodule deinit -f .
- @git clean -ff -x -d -e ".project" -e ".cproject" -e ".idea" -e ".settings" -e ".vscode"
- # --------------------------------------------------------------------
- # All other targets are handled by PX4_MAKE. Add a rule here to avoid printing an error.
- %:
- $(if $(filter $(FIRST_ARG),$@), \
- $(error"$@ cannot be the first argument. Use '$(MAKE) help|list_config_targets' to get a list of all possible [configuration] targets."),@#)
- #help:
- # @echo
- # @echo "Type 'make ' and hit the tab key twice to see a list of the available"
- # @echo "build configurations."
- # @echo
- empty :=
- space := $(empty) $(empty)
- # Print a list of non-config targets (based on http://stackoverflow.com/a/26339924/1487069)
- help:
- @echo "Usage: $(MAKE) <target>"
- @echo "Where <target> is one of:"
- @echo
- @echo "Or, $(MAKE) <config_target> [<make_target(s)>]"
- @echo "Use '$(MAKE) list_config_targets' for a list of configuration targets."
- @echo "$()"
- # Print a list of all config targets.
- list_config_targets:
- @for targ in $(patsubst nuttx_%,[nuttx_]%,$(ALL_CONFIG_TARGETS));do echo $$targ;done
在默認的Makefile添加以下函數,可以將Makefile中變量值打印出來,更加清晰的查看Makefile的配置和運行過程:
- .PHONY:VARValue
- VARValue:
- @echo "$(MAKEFILE_LIST)"
- @echo "$(MAKECMDGOALS)"
- @echo "$(SRC_DIR)"
- @echo "$(PX4_MAKE)"
- @echo "$(PX4_CMAKE_GENERATOR)"
- @echo "$(SYSTEMROOT)"
- @echo "$(PX4_MAKE_ARGS)"
- @echo "$(ALL_CONFIG_TARGETS)"
- @echo "$(NUTTX_CONFIG_TARGETS)"
結果爲:
接下來應該是編譯:F:\px4\Firmware\CMakeLists.txt文件
——Eidted By RobotBrain.M LESS BUT BETTER.