Chinaunix首页 | 论坛 | 博客
  • 博客访问: 387656
  • 博文数量: 61
  • 博客积分: 4650
  • 博客等级: 上校
  • 技术积分: 786
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-11 21:07
个人简介

少抱怨,多实干;

文章分类

全部博文(61)

文章存档

2017年(1)

2016年(13)

2015年(1)

2013年(2)

2011年(1)

2010年(3)

2009年(23)

2008年(17)

我的朋友

分类: 嵌入式

2016-09-08 21:50:52


点击(此处)折叠或打开

  1. 点击(此处)折叠或打开
  2. 点击(此处)折叠或打开
  3. #
  4. # Copyright (C) 2012 PX4 Development Team. All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions
  8. # are met:
  9. #
  10. # 1. Redistributions of source code must retain the above copyright
  11. # notice, this list of conditions and the following disclaimer.
  12. # 2. Redistributions in binary form must reproduce the above copyright
  13. # notice, this list of conditions and the following disclaimer in
  14. # the documentation and/or other materials provided with the
  15. # distribution.
  16. # 3. Neither the name PX4 nor the names of its contributors may be
  17. # used to endorse or promote products derived from this software
  18. # without specific prior written permission.
  19. #
  20. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24. # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  26. # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  27. # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  28. # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  30. # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  31. # POSSIBILITY OF SUCH DAMAGE.
  32. #
  33. #
  34. # Generic Makefile for PX4 firmware images.
  35. #
  36. # Requires:
  37. #
  38. # BOARD
  39. # Must be set to a board name known to the PX4 distribution (as
  40. # we need a corresponding NuttX export archive to link with).
  41. #
  42. # Optional:
  43. #
  44. # MODULES
  45. # Contains a list of module paths or path fragments used
  46. # to find modules. The names listed here are searched in
  47. # the following directories:
  48. #
  49. # $(MODULE_SEARCH_DIRS)
  50. # WORK_DIR
  51. # MODULE_SRC
  52. # PX4_MODULE_SRC
  53. #
  54. # Application directories are expected to contain a module.mk
  55. # file which provides build configuration for the module. See
  56. # makefiles/module.mk for more details.
  57. #
  58. # BUILTIN_COMMANDS
  59. # Contains a list of built-in commands not explicitly provided
  60. # by modules / libraries. Each entry in this list is formatted
  61. # as ...
  62. #
  63. # PX4_BASE:
  64. # Points to a PX4 distribution. Normally determined based on the
  65. # path to this file.
  66. #
  67. # CONFIG:
  68. # Used when searching for the configuration file, and available
  69. # to module Makefiles to select optional features.
  70. # If not set, CONFIG_FILE must be set and CONFIG will be derived
  71. # automatically from it.
  72. #
  73. # CONFIG_FILE:
  74. # If set, overrides the configuration file search logic. Sets
  75. # CONFIG to the name of the configuration file, strips any
  76. # leading config_ prefix and any suffix. e.g. config_board_foo.mk
  77. # results in CONFIG being set to 'board_foo'.
  78. #
  79. # WORK_DIR:
  80. # Sets the directory in which the firmware will be built. Defaults
  81. # to the directory 'build' under the directory containing the
  82. # parent Makefile.
  83. #
  84. # ROMFS_ROOT:
  85. # If set to the path to a directory, a ROMFS image will be generated
  86. # containing the files under the directory and linked into the final
  87. # image.
  88. #
  89. # MODULE_SEARCH_DIRS:
  90. # Extra directories to search first for MODULES before looking in the
  91. # usual places.
  92. #
  93. ################################################################################
  94. # Paths and configuration
  95. ################################################################################
  96. #
  97. # Work out where this file is, so we can find other makefiles in the
  98. # same directory.
  99. #
  100. # If PX4_BASE wasn't set previously, work out what it should be
  101. # and set it here now.
  102. #
  103. MK_DIR ?= $(dir $(lastword $(MAKEFILE_LIST)))
  104. #
  105. #MK_DIR 应该指向 "makefiles/"目录
  106. #PX4_BASE应该指向源码的顶层目录,同TOP_DIR
  107. ifeq ($(PX4_BASE),)
  108. export PX4_BASE := $(abspath $(MK_DIR)/..)
  109. endif
  110. $(info % PX4_BASE = $(PX4_BASE))
  111. ifneq ($(words $(PX4_BASE)),1)
  112. $(error Cannot build when the PX4_BASE path contains one or more space characters.)
  113. endif
  114. $(info % GIT_DESC = $(GIT_DESC))
  115. #
  116. # Set a default target so that included makefiles or errors here don't
  117. # cause confusion.
  118. #
  119. # XXX We could do something cute here with $(DEFAULT_GOAL) if it's not one
  120. # of the maintenance targets and set CONFIG based on it.
  121. #
  122. all: firmware
  123. #
  124. # Get path and tool config
  125. #
  126. include $(MK_DIR)/setup.mk
  127. #
  128. # Locate the configuration file
  129. #
  130. ifneq ($(CONFIG_FILE),)
  131. CONFIG := $(subst config_,,$(basename $(notdir $(CONFIG_FILE))))
  132. else
  133. CONFIG_FILE := $(wildcard $(PX4_MK_DIR)/config_$(CONFIG).mk)
  134. endif
  135. ifeq ($(CONFIG),)
  136. $(error Missing configuration name or file (specify with CONFIG=))
  137. endif
  138. export CONFIG
  139. include $(CONFIG_FILE)
  140. $(info % CONFIG = $(CONFIG))
  141. #上面内容,找出待编译的目录mk文件,并设备其为环境变量,并且include该mk文件,如:config_px4fmu-v2_default.mk
  142. #该mk文件用来设置源码位置,及buildin的命令,所以需要include进来.
  143. #
  144. #
  145. # Sanity-check the BOARD variable and then get the board config.
  146. # If BOARD was not set by the configuration, extract it automatically.
  147. #
  148. # The board config in turn will fetch the toolchain configuration.
  149. #
  150. ifeq ($(BOARD),)
  151. BOARD := $(firstword $(subst _, ,$(CONFIG)))
  152. endif
  153. BOARD_FILE := $(wildcard $(PX4_MK_DIR)/board_$(BOARD).mk)
  154. ifeq ($(BOARD_FILE),)
  155. $(error Config $(CONFIG) references board $(BOARD), but no board definition file found)
  156. endif
  157. export BOARD
  158. export BOARD_FILE
  159. include $(BOARD_FILE)
  160. $(info % BOARD = $(BOARD))
  161. #
  162. #找出BOARD_FILE文件,并加载它;如board_px4fmu-v2.mk
  163. #该文件加设置两个环境变量和编译工具相关的配置.
  164. #
  165. #
  166. # If WORK_DIR is not set, create a 'build' directory next to the
  167. # parent Makefile.
  168. #
  169. PARENT_MAKEFILE := $(lastword $(filter-out $(lastword $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
  170. ifeq ($(WORK_DIR),)
  171. export WORK_DIR := $(dir $(PARENT_MAKEFILE))build/
  172. endif
  173. $(info % WORK_DIR = $(WORK_DIR))
  174. #
  175. # Things that, if they change, might affect everything
  176. #
  177. GLOBAL_DEPS += $(MAKEFILE_LIST)
  178. #
  179. # Extra things we should clean
  180. #
  181. EXTRA_CLEANS =
  182. #
  183. # Append the per-board driver directory to the header search path.
  184. #
  185. INCLUDE_DIRS += $(PX4_MODULE_SRC)drivers/boards/$(BOARD)
  186. ################################################################################
  187. # NuttX libraries and paths
  188. ################################################################################
  189. include $(PX4_MK_DIR)/nuttx.mk
  190. ################################################################################
  191. # Modules
  192. ################################################################################
  193. # where to look for modules
  194. MODULE_SEARCH_DIRS += $(WORK_DIR) $(MODULE_SRC) $(PX4_MODULE_SRC)
  195. # sort and unique the modules list
  196. MODULES := $(sort $(MODULES))
  197. # locate the first instance of a module by full path or by looking on the
  198. # module search path
  199. define MODULE_SEARCH
  200. $(firstword $(abspath $(wildcard $(1)/module.mk)) \
  201. $(abspath $(foreach search_dir,$(MODULE_SEARCH_DIRS),$(wildcard $(search_dir)/$(1)/module.mk))) \
  202. MISSING_$1)
  203. endef
  204. # make a list of module makefiles and check that we found them all
  205. MODULE_MKFILES := $(foreach module,$(MODULES),$(call MODULE_SEARCH,$(module)))
  206. MISSING_MODULES := $(subst MISSING_,,$(filter MISSING_%,$(MODULE_MKFILES)))
  207. ifneq ($(MISSING_MODULES),)
  208. $(error Can't find module(s): $(MISSING_MODULES))
  209. endif
  210. # Make a list of the object files we expect to build from modules
  211. # Note that this path will typically contain a double-slash at the WORK_DIR boundary; this must be
  212. # preserved as it is used below to get the absolute path for the module.mk file correct.
  213. #
  214. MODULE_OBJS := $(foreach path,$(dir $(MODULE_MKFILES)),$(WORK_DIR)$(path)module.pre.o)
  215. # rules to build module objects
  216. .PHONY: $(MODULE_OBJS)
  217. $(MODULE_OBJS): relpath = $(patsubst $(WORK_DIR)%,%,$@)
  218. $(MODULE_OBJS): mkfile = $(patsubst %module.pre.o,%module.mk,$(relpath))
  219. $(MODULE_OBJS): workdir = $(@D)
  220. $(MODULE_OBJS): $(GLOBAL_DEPS) $(NUTTX_CONFIG_HEADER)
  221. $(Q) $(MKDIR) -p $(workdir)
  222. $(Q) $(MAKE) -r -f $(PX4_MK_DIR)module.mk \
  223. -C $(workdir) \
  224. MODULE_WORK_DIR=$(workdir) \
  225. MODULE_OBJ=$@ \
  226. MODULE_MK=$(mkfile) \
  227. MODULE_NAME=$(lastword $(subst /, ,$(workdir))) \
  228. module
  229. # make a list of phony clean targets for modules
  230. MODULE_CLEANS := $(foreach path,$(dir $(MODULE_MKFILES)),$(WORK_DIR)$(path)/clean)
  231. # rules to clean modules
  232. .PHONY: $(MODULE_CLEANS)
  233. $(MODULE_CLEANS): relpath = $(patsubst $(WORK_DIR)%,%,$@)
  234. $(MODULE_CLEANS): mkfile = $(patsubst %clean,%module.mk,$(relpath))
  235. $(MODULE_CLEANS):
  236. @$(ECHO) %% cleaning using $(mkfile)
  237. $(Q) $(MAKE) -r -f $(PX4_MK_DIR)module.mk \
  238. MODULE_WORK_DIR=$(dir $@) \
  239. MODULE_MK=$(mkfile) \
  240. clean
  241. ################################################################################
  242. # Libraries
  243. ################################################################################
  244. # where to look for libraries
  245. LIBRARY_SEARCH_DIRS += $(WORK_DIR) $(MODULE_SRC) $(PX4_MODULE_SRC)
  246. # sort and unique the library list
  247. LIBRARIES := $(sort $(LIBRARIES))
  248. # locate the first instance of a library by full path or by looking on the
  249. # library search path
  250. define LIBRARY_SEARCH
  251. $(firstword $(abspath $(wildcard $(1)/library.mk)) \
  252. $(abspath $(foreach search_dir,$(LIBRARY_SEARCH_DIRS),$(wildcard $(search_dir)/$(1)/library.mk))) \
  253. MISSING_$1)
  254. endef
  255. # make a list of library makefiles and check that we found them all
  256. LIBRARY_MKFILES := $(foreach library,$(LIBRARIES),$(call LIBRARY_SEARCH,$(library)))
  257. MISSING_LIBRARIES := $(subst MISSING_,,$(filter MISSING_%,$(LIBRARY_MKFILES)))
  258. ifneq ($(MISSING_LIBRARIES),)
  259. $(error Can't find library(s): $(MISSING_LIBRARIES))
  260. endif
  261. # Make a list of the archive files we expect to build from libraries
  262. # Note that this path will typically contain a double-slash at the WORK_DIR boundary; this must be
  263. # preserved as it is used below to get the absolute path for the library.mk file correct.
  264. #
  265. LIBRARY_LIBS := $(foreach path,$(dir $(LIBRARY_MKFILES)),$(WORK_DIR)$(path)library.a)
  266. # rules to build module objects
  267. .PHONY: $(LIBRARY_LIBS)
  268. $(LIBRARY_LIBS): relpath = $(patsubst $(WORK_DIR)%,%,$@)
  269. $(LIBRARY_LIBS): mkfile = $(patsubst %library.a,%library.mk,$(relpath))
  270. $(LIBRARY_LIBS): workdir = $(@D)
  271. $(LIBRARY_LIBS): $(GLOBAL_DEPS) $(NUTTX_CONFIG_HEADER)
  272. $(Q) $(MKDIR) -p $(workdir)
  273. $(Q) $(MAKE) -r -f $(PX4_MK_DIR)library.mk \
  274. -C $(workdir) \
  275. LIBRARY_WORK_DIR=$(workdir) \
  276. LIBRARY_LIB=$@ \
  277. LIBRARY_MK=$(mkfile) \
  278. LIBRARY_NAME=$(lastword $(subst /, ,$(workdir))) \
  279. library
  280. # make a list of phony clean targets for modules
  281. LIBRARY_CLEANS := $(foreach path,$(dir $(LIBRARY_MKFILES)),$(WORK_DIR)$(path)/clean)
  282. # rules to clean modules
  283. .PHONY: $(LIBRARY_CLEANS)
  284. $(LIBRARY_CLEANS): relpath = $(patsubst $(WORK_DIR)%,%,$@)
  285. $(LIBRARY_CLEANS): mkfile = $(patsubst %clean,%library.mk,$(relpath))
  286. $(LIBRARY_CLEANS):
  287. @$(ECHO) %% cleaning using $(mkfile)
  288. $(Q) $(MAKE) -r -f $(PX4_MK_DIR)library.mk \
  289. LIBRARY_WORK_DIR=$(dir $@) \
  290. LIBRARY_MK=$(mkfile) \
  291. clean
  292. ################################################################################
  293. # ROMFS generation
  294. ################################################################################
  295. ifneq ($(ROMFS_ROOT),)
  296. ifeq ($(wildcard $(ROMFS_ROOT)),)
  297. $(error ROMFS_ROOT specifies a directory that does not exist)
  298. endif
  299. #
  300. # Note that there is no support for more than one root directory or constructing
  301. # a root from several templates. That would be a nice feature.
  302. #
  303. # Add dependencies on anything in the ROMFS root directory
  304. ROMFS_FILES += $(wildcard \
  305. $(ROMFS_ROOT)/* \
  306. $(ROMFS_ROOT)/*/* \
  307. $(ROMFS_ROOT)/*/*/* \
  308. $(ROMFS_ROOT)/*/*/*/* \
  309. $(ROMFS_ROOT)/*/*/*/*/* \
  310. $(ROMFS_ROOT)/*/*/*/*/*/*)
  311. ifeq ($(ROMFS_FILES),)
  312. $(error ROMFS_ROOT $(ROMFS_ROOT) specifies a directory containing no files)
  313. endif
  314. ROMFS_DEPS += $(ROMFS_FILES)
  315. # Extra files that may be copied into the ROMFS /extras directory
  316. # ROMFS_EXTRA_FILES are required, ROMFS_OPTIONAL_FILES are optional
  317. ROMFS_EXTRA_FILES += $(wildcard $(ROMFS_OPTIONAL_FILES))
  318. ROMFS_DEPS += $(ROMFS_EXTRA_FILES)
  319. ROMFS_IMG = romfs.img
  320. ROMFS_SCRATCH = romfs_scratch
  321. ROMFS_CSRC = $(ROMFS_IMG:.img=.c)
  322. ROMFS_OBJ = $(ROMFS_CSRC:.c=.o)
  323. LIBS += $(ROMFS_OBJ)
  324. LINK_DEPS += $(ROMFS_OBJ)
  325. # Add autostart script
  326. ROMFS_AUTOSTART = $(PX4_BASE)/Tools/px_process_airframes.py
  327. # Remove all comments from startup and mixer files
  328. ROMFS_PRUNER = $(PX4_BASE)/Tools/px_romfs_pruner.py
  329. # Turn the ROMFS image into an object file
  330. $(ROMFS_OBJ): $(ROMFS_IMG) $(GLOBAL_DEPS)
  331. $(call BIN_TO_OBJ,$<,$@,romfs_img)
  332. # Generate the ROMFS image from the root
  333. $(ROMFS_IMG): $(ROMFS_SCRATCH) $(ROMFS_DEPS) $(GLOBAL_DEPS)
  334. @$(ECHO) "ROMFS: $@"
  335. $(Q) $(GENROMFS) -f $@ -d $(ROMFS_SCRATCH) -V "NSHInitVol"
  336. # Construct the ROMFS scratch root from the canonical root
  337. $(ROMFS_SCRATCH): $(ROMFS_DEPS) $(GLOBAL_DEPS)
  338. $(Q) $(MKDIR) -p $(ROMFS_SCRATCH)
  339. $(Q) $(COPYDIR) $(ROMFS_ROOT)/* $(ROMFS_SCRATCH)
  340. # delete all files in ROMFS_SCRATCH which start with a . or end with a ~
  341. $(Q) $(RM) $(ROMFS_SCRATCH)/*/.[!.]* $(ROMFS_SCRATCH)/*/*~
  342. ifneq ($(ROMFS_EXTRA_FILES),)
  343. $(Q) $(MKDIR) -p $(ROMFS_SCRATCH)/extras
  344. $(Q) $(COPY) $(ROMFS_EXTRA_FILES) $(ROMFS_SCRATCH)/extras
  345. endif
  346. $(Q) $(PYTHON) -u $(ROMFS_AUTOSTART) -a $(ROMFS_ROOT)/init.d/ -s $(ROMFS_SCRATCH)/init.d/rc.autostart
  347. # Execute in standard dir as well
  348. # so developers notice the generated file
  349. $(Q) $(PYTHON) -u $(ROMFS_AUTOSTART) -a $(ROMFS_ROOT)/init.d/ -s $(ROMFS_ROOT)/init.d/rc.autostart
  350. $(Q) $(PYTHON) -u $(ROMFS_PRUNER) --folder $(ROMFS_SCRATCH)
  351. EXTRA_CLEANS += $(ROMGS_OBJ) $(ROMFS_IMG)
  352. endif
  353. ################################################################################
  354. # Builtin command list generation
  355. ################################################################################
  356. #
  357. # Builtin commands can be generated by the configuration, in which case they
  358. # must refer to commands that already exist, or indirectly generated by modules
  359. # when they are built.
  360. #
  361. # The configuration supplies builtin command information in the BUILTIN_COMMANDS
  362. # variable. Applications make empty files in $(WORK_DIR)/builtin_commands whose
  363. # filename contains the same information.
  364. #
  365. # In each case, the command information consists of four fields separated with a
  366. # period. These fields are the command's name, its thread priority, its stack size
  367. # and the name of the function to call when starting the thread.
  368. #
  369. BUILTIN_CSRC = $(WORK_DIR)builtin_commands.c
  370. # command definitions from modules (may be empty at Makefile parsing time...)
  371. MODULE_COMMANDS = $(subst COMMAND.,,$(notdir $(wildcard $(WORK_DIR)builtin_commands/COMMAND.*)))
  372. # We must have at least one pre-defined builtin command in order to generate
  373. # any of this.
  374. #
  375. ifneq ($(BUILTIN_COMMANDS),)
  376. # (BUILTIN_PROTO,,)
  377. define BUILTIN_PROTO
  378. $(ECHO) 'extern int $(word 4,$1)(int argc, char *argv[]);' >> $2;
  379. endef
  380. # (BUILTIN_DEF,,)
  381. define BUILTIN_DEF
  382. $(ECHO) ' {"$(word 1,$1)", $(word 2,$1), $(word 3,$1), $(word 4,$1)},' >> $2;
  383. endef
  384. # Don't generate until modules have updated their command files
  385. $(BUILTIN_CSRC): $(GLOBAL_DEPS) $(MODULE_OBJS) $(MODULE_MKFILES) $(BUILTIN_COMMAND_FILES)
  386. @$(ECHO) "CMDS: $@"
  387. $(Q) $(ECHO) '/* builtin command list - automatically generated, do not edit */' > $@
  388. $(Q) $(ECHO) '#include ' >> $@
  389. $(Q) $(ECHO) '#include ' >> $@
  390. $(Q) $(foreach spec,$(BUILTIN_COMMANDS),$(call BUILTIN_PROTO,$(subst ., ,$(spec)),$@))
  391. $(Q) $(foreach spec,$(MODULE_COMMANDS),$(call BUILTIN_PROTO,$(subst ., ,$(spec)),$@))
  392. $(Q) $(ECHO) 'const struct builtin_s g_builtins[] = {' >> $@
  393. $(Q) $(foreach spec,$(BUILTIN_COMMANDS),$(call BUILTIN_DEF,$(subst ., ,$(spec)),$@))
  394. $(Q) $(foreach spec,$(MODULE_COMMANDS),$(call BUILTIN_DEF,$(subst ., ,$(spec)),$@))
  395. $(Q) $(ECHO) ' {NULL, 0, 0, NULL}' >> $@
  396. $(Q) $(ECHO) '};' >> $@
  397. $(Q) $(ECHO) 'const int g_builtin_count = $(words $(BUILTIN_COMMANDS) $(MODULE_COMMANDS));' >> $@
  398. SRCS += $(BUILTIN_CSRC)
  399. EXTRA_CLEANS += $(BUILTIN_CSRC)
  400. endif
  401. ################################################################################
  402. # Default SRCS generation
  403. ################################################################################
  404. #
  405. # If there are no SRCS, the build will fail; in that case, generate an empty
  406. # source file.
  407. #
  408. ifeq ($(SRCS),)
  409. EMPTY_SRC = $(WORK_DIR)empty.c
  410. $(EMPTY_SRC):
  411. $(Q) $(ECHO) '/* this is an empty file */' > $@
  412. SRCS += $(EMPTY_SRC)
  413. endif
  414. ################################################################################
  415. # Build rules
  416. ################################################################################
  417. #
  418. # What we're going to build.
  419. #
  420. PRODUCT_BUNDLE = $(WORK_DIR)firmware.px4
  421. PRODUCT_BIN = $(WORK_DIR)firmware.bin
  422. PRODUCT_ELF = $(WORK_DIR)firmware.elf
  423. PRODUCT_PARAMXML = $(WORK_DIR)/parameters.xml
  424. PRODUCT_AIRFRAMEXML = $(WORK_DIR)/airframes.xml
  425. .PHONY: firmware
  426. firmware: $(PRODUCT_BUNDLE)
  427. #
  428. # Object files we will generate from sources
  429. #
  430. OBJS := $(foreach src,$(SRCS),$(WORK_DIR)$(src).o)
  431. #
  432. # SRCS -> OBJS rules
  433. #
  434. $(OBJS): $(GLOBAL_DEPS)
  435. $(filter %.c.o,$(OBJS)): $(WORK_DIR)%.c.o: %.c $(GLOBAL_DEPS)
  436. $(call COMPILE,$<,$@)
  437. $(filter %.cpp.o,$(OBJS)): $(WORK_DIR)%.cpp.o: %.cpp $(GLOBAL_DEPS)
  438. $(call COMPILEXX,$<,$@)
  439. $(filter %.S.o,$(OBJS)): $(WORK_DIR)%.S.o: %.S $(GLOBAL_DEPS)
  440. $(call ASSEMBLE,$<,$@)
  441. #
  442. # Built product rules
  443. #
  444. $(PRODUCT_BUNDLE): $(PRODUCT_BIN)
  445. @$(ECHO) %% Generating $@
  446. ifdef GEN_PARAM_XML
  447. $(Q) $(PYTHON) $(PX4_BASE)/Tools/px_process_params.py --src-path $(PX4_BASE)/src --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml
  448. $(Q) $(PYTHON) $(PX4_BASE)/Tools/px_process_airframes.py -a $(PX4_BASE)/ROMFS/px4fmu_common/init.d/ --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml
  449. $(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \
  450. --git_identity $(PX4_BASE) \
  451. --parameter_xml $(PRODUCT_PARAMXML) \
  452. --airframe_xml $(PRODUCT_AIRFRAMEXML) \
  453. --image $< > $@
  454. else
  455. $(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \
  456. --git_identity $(PX4_BASE) \
  457. --image $< > $@
  458. endif
  459. $(PRODUCT_BIN): $(PRODUCT_ELF)
  460. $(call SYM_TO_BIN,$<,$@)
  461. $(PRODUCT_ELF): $(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS) $(GLOBAL_DEPS) $(LINK_DEPS) $(MODULE_MKFILES)
  462. $(call LINK,$@,$(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS))
  463. #
  464. # Utility rules
  465. #
  466. .PHONY: upload
  467. upload: $(PRODUCT_BUNDLE) $(PRODUCT_BIN)
  468. $(Q) $(MAKE) -f $(PX4_MK_DIR)/upload.mk \
  469. METHOD=serial \
  470. CONFIG=$(CONFIG) \
  471. BOARD=$(BOARD) \
  472. BUNDLE=$(PRODUCT_BUNDLE) \
  473. BIN=$(PRODUCT_BIN)
  474. .PHONY: clean
  475. clean: $(MODULE_CLEANS)
  476. @$(ECHO) %% cleaning
  477. $(Q) $(REMOVE) $(PRODUCT_BUNDLE) $(PRODUCT_BIN) $(PRODUCT_ELF)
  478. $(Q) $(REMOVE) $(OBJS) $(DEP_INCLUDES) $(EXTRA_CLEANS)
  479. $(Q) $(RMDIR) $(NUTTX_EXPORT_DIR)
  480. #
  481. # DEP_INCLUDES is defined by the toolchain include in terms of $(OBJS)
  482. #
  483. -include $(DEP_INCLUDES)
  484. PX4_firmware.zip


阅读(1295) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~