forked from Archive/PX4-Autopilot
makefile cleanup
Moved nuttx specific make rules to files in makefiles/nuttx. All target specific makefiles are in their target sub directories. To minimize file duplication, targets that share rules include a common file. For example the posix and posix-arm targets both use makefiles/posix/posix_elf.mk Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
parent
da5014fe95
commit
26d2589e97
142
Makefile
142
Makefile
|
@ -105,142 +105,17 @@ upload:
|
|||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(PX4_TARGET_OS),nuttx)
|
||||
#
|
||||
# Built products
|
||||
#
|
||||
DESIRED_FIRMWARES = $(foreach config,$(CONFIGS),$(IMAGE_DIR)$(config).px4)
|
||||
STAGED_FIRMWARES = $(foreach config,$(KNOWN_CONFIGS),$(IMAGE_DIR)$(config).px4)
|
||||
FIRMWARES = $(foreach config,$(KNOWN_CONFIGS),$(BUILD_DIR)$(config).build/firmware.px4)
|
||||
|
||||
all: $(DESIRED_FIRMWARES)
|
||||
|
||||
#
|
||||
# Copy FIRMWARES into the image directory.
|
||||
#
|
||||
# XXX copying the .bin files is a hack to work around the PX4IO uploader
|
||||
# not supporting .px4 files, and it should be deprecated onced that
|
||||
# is taken care of.
|
||||
#
|
||||
$(STAGED_FIRMWARES): $(IMAGE_DIR)%.px4: $(BUILD_DIR)%.build/firmware.px4
|
||||
@$(ECHO) %% Copying $@
|
||||
$(Q) $(COPY) $< $@
|
||||
$(Q) $(COPY) $(patsubst %.px4,%.bin,$<) $(patsubst %.px4,%.bin,$@)
|
||||
|
||||
#
|
||||
# Generate FIRMWARES.
|
||||
#
|
||||
.PHONY: $(FIRMWARES)
|
||||
$(BUILD_DIR)%.build/firmware.px4: config = $(patsubst $(BUILD_DIR)%.build/firmware.px4,%,$@)
|
||||
$(BUILD_DIR)%.build/firmware.px4: work_dir = $(BUILD_DIR)$(config).build/
|
||||
$(FIRMWARES): $(BUILD_DIR)%.build/firmware.px4: checkgitversion generateuorbtopicheaders checksubmodules
|
||||
@$(ECHO) %%%%
|
||||
@$(ECHO) %%%% Building $(config) in $(work_dir)
|
||||
@$(ECHO) %%%%
|
||||
$(Q) $(MKDIR) -p $(work_dir)
|
||||
$(Q) $(MAKE) -r -C $(work_dir) \
|
||||
-f $(PX4_MK_DIR)firmware.mk \
|
||||
CONFIG=$(config) \
|
||||
WORK_DIR=$(work_dir) \
|
||||
$(FIRMWARE_GOAL)
|
||||
|
||||
#
|
||||
# Make FMU firmwares depend on the corresponding IO firmware.
|
||||
#
|
||||
# This is a pretty vile hack, since it hard-codes knowledge of the FMU->IO dependency
|
||||
# and forces the _default config in all cases. There has to be a better way to do this...
|
||||
#
|
||||
FMU_VERSION = $(patsubst px4fmu-%,%,$(word 1, $(subst _, ,$(1))))
|
||||
define FMU_DEP
|
||||
$(BUILD_DIR)$(1).build/firmware.px4: $(IMAGE_DIR)px4io-$(call FMU_VERSION,$(1))_default.px4
|
||||
endef
|
||||
FMU_CONFIGS := $(filter px4fmu%,$(CONFIGS))
|
||||
$(foreach config,$(FMU_CONFIGS),$(eval $(call FMU_DEP,$(config))))
|
||||
|
||||
#
|
||||
# Build the NuttX export archives.
|
||||
#
|
||||
# Note that there are no explicit dependencies extended from these
|
||||
# archives. If NuttX is updated, the user is expected to rebuild the
|
||||
# archives/build area manually. Likewise, when the 'archives' target is
|
||||
# invoked, all archives are always rebuilt.
|
||||
#
|
||||
# XXX Should support fetching/unpacking from a separate directory to permit
|
||||
# downloads of the prebuilt archives as well...
|
||||
#
|
||||
NUTTX_ARCHIVES = $(foreach board,$(BOARDS),$(ARCHIVE_DIR)$(board).export)
|
||||
.PHONY: archives
|
||||
archives: checksubmodules $(NUTTX_ARCHIVES)
|
||||
|
||||
# We cannot build these parallel; note that we also force -j1 for the
|
||||
# sub-make invocations.
|
||||
ifneq ($(filter archives,$(MAKECMDGOALS)),)
|
||||
.NOTPARALLEL:
|
||||
endif
|
||||
|
||||
J?=1
|
||||
|
||||
$(ARCHIVE_DIR)%.export: board = $(notdir $(basename $@))
|
||||
$(ARCHIVE_DIR)%.export: configuration = nsh
|
||||
$(NUTTX_ARCHIVES): $(ARCHIVE_DIR)%.export: $(NUTTX_SRC)
|
||||
@$(ECHO) %% Configuring NuttX for $(board)
|
||||
$(Q) (cd $(NUTTX_SRC) && $(RMDIR) nuttx-export)
|
||||
$(Q) $(MAKE) -r -j$(J) -C $(NUTTX_SRC) -r $(MQUIET) distclean
|
||||
$(Q) (cd $(NUTTX_SRC)/configs && $(COPYDIR) $(PX4_BASE)nuttx-configs/$(board) .)
|
||||
$(Q) (cd $(NUTTX_SRC)tools && ./configure.sh $(board)/$(configuration))
|
||||
@$(ECHO) %% Exporting NuttX for $(board)
|
||||
$(Q) $(MAKE) -r -j$(J) -C $(NUTTX_SRC) -r $(MQUIET) CONFIG_ARCH_BOARD=$(board) export
|
||||
$(Q) $(MKDIR) -p $(dir $@)
|
||||
$(Q) $(COPY) $(NUTTX_SRC)nuttx-export.zip $@
|
||||
$(Q) (cd $(NUTTX_SRC)/configs && $(RMDIR) $(board))
|
||||
|
||||
#
|
||||
# The user can run the NuttX 'menuconfig' tool for a single board configuration with
|
||||
# make BOARDS=<boardname> menuconfig
|
||||
#
|
||||
ifeq ($(MAKECMDGOALS),menuconfig)
|
||||
ifneq ($(words $(BOARDS)),1)
|
||||
$(error BOARDS must specify exactly one board for the menuconfig goal)
|
||||
endif
|
||||
BOARD = $(BOARDS)
|
||||
menuconfig: $(NUTTX_SRC)
|
||||
@$(ECHO) %% Configuring NuttX for $(BOARD)
|
||||
$(Q) (cd $(NUTTX_SRC) && $(RMDIR) nuttx-export)
|
||||
$(Q) $(MAKE) -r -j$(J) -C $(NUTTX_SRC) -r $(MQUIET) distclean
|
||||
$(Q) (cd $(NUTTX_SRC)/configs && $(COPYDIR) $(PX4_BASE)nuttx-configs/$(BOARD) .)
|
||||
$(Q) (cd $(NUTTX_SRC)tools && ./configure.sh $(BOARD)/nsh)
|
||||
@$(ECHO) %% Running menuconfig for $(BOARD)
|
||||
$(Q) $(MAKE) -r -j$(J) -C $(NUTTX_SRC) -r $(MQUIET) oldconfig
|
||||
$(Q) $(MAKE) -r -j$(J) -C $(NUTTX_SRC) -r $(MQUIET) menuconfig
|
||||
@$(ECHO) %% Saving configuration file
|
||||
$(Q)$(COPY) $(NUTTX_SRC).config $(PX4_BASE)nuttx-configs/$(BOARD)/nsh/defconfig
|
||||
else
|
||||
menuconfig:
|
||||
@$(ECHO) ""
|
||||
@$(ECHO) "The menuconfig goal must be invoked without any other goal being specified"
|
||||
@$(ECHO) ""
|
||||
|
||||
endif
|
||||
|
||||
$(NUTTX_SRC): checkgitversion checksubmodules
|
||||
|
||||
$(UAVCAN_DIR):
|
||||
$(Q) (./Tools/check_submodules.sh)
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(PX4_TARGET_OS),nuttx)
|
||||
# TODO
|
||||
# Move the above nuttx specific rules into $(PX4_BASE)makefiles/firmware_nuttx.mk
|
||||
include $(PX4_BASE)makefiles/nuttx/firmware_nuttx.mk
|
||||
endif
|
||||
ifeq ($(PX4_TARGET_OS),posix)
|
||||
include $(PX4_BASE)makefiles/firmware_posix.mk
|
||||
include $(PX4_BASE)makefiles/posix/firmware_posix.mk
|
||||
endif
|
||||
ifeq ($(PX4_TARGET_OS),posix-arm)
|
||||
include $(PX4_BASE)makefiles/firmware_posix.mk
|
||||
include $(PX4_BASE)makefiles/posix/firmware_posix.mk
|
||||
endif
|
||||
ifeq ($(PX4_TARGET_OS),qurt)
|
||||
include $(PX4_BASE)makefiles/firmware_qurt.mk
|
||||
include $(PX4_BASE)makefiles/qurt/firmware_qurt.mk
|
||||
endif
|
||||
|
||||
#
|
||||
|
@ -409,3 +284,12 @@ endif
|
|||
@$(ECHO) " If V is set, more verbose output is printed during the build. This can"
|
||||
@$(ECHO) " help when diagnosing issues with the build or toolchain."
|
||||
@$(ECHO) ""
|
||||
ifeq ($(PX4_TARGET_OS),nuttx)
|
||||
@$(ECHO) " To see help for a specifix target use 'make <target> help' where target is"
|
||||
@$(ECHO) " one of: "
|
||||
@$(ECHO) " nuttx"
|
||||
@$(ECHO) " posix"
|
||||
@$(ECHO) " qurt"
|
||||
@$(ECHO) ""
|
||||
endif
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
# If PX4_BASE wasn't set previously, work out what it should be
|
||||
# and set it here now.
|
||||
#
|
||||
MK_DIR ?= $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
MK_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
ifeq ($(PX4_BASE),)
|
||||
export PX4_BASE := $(abspath $(MK_DIR)/..)
|
||||
endif
|
||||
|
@ -111,6 +111,7 @@ $(error Cannot build when the PX4_BASE path contains one or more space character
|
|||
endif
|
||||
|
||||
$(info % GIT_DESC = $(GIT_DESC))
|
||||
$(info % MK_DIR = $(MK_DIR))
|
||||
|
||||
#
|
||||
# Set a default target so that included makefiles or errors here don't
|
||||
|
@ -189,7 +190,7 @@ INCLUDE_DIRS += $(PX4_MODULE_SRC)drivers/boards/$(BOARD)
|
|||
# OS specific libraries and paths
|
||||
################################################################################
|
||||
|
||||
include $(PX4_MK_DIR)/$(PX4_TARGET_OS).mk
|
||||
include $(PX4_MK_DIR)/$(PX4_TARGET_OS)/$(PX4_TARGET_OS).mk
|
||||
|
||||
################################################################################
|
||||
# Modules
|
||||
|
@ -311,131 +312,11 @@ $(LIBRARY_CLEANS):
|
|||
LIBRARY_MK=$(mkfile) \
|
||||
clean
|
||||
|
||||
ifeq ($(PX4_TARGET_OS),nuttx)
|
||||
################################################################################
|
||||
# ROMFS generation
|
||||
################################################################################
|
||||
|
||||
ifneq ($(ROMFS_ROOT),)
|
||||
ifeq ($(wildcard $(ROMFS_ROOT)),)
|
||||
$(error ROMFS_ROOT specifies a directory that does not exist)
|
||||
endif
|
||||
|
||||
#
|
||||
# Note that there is no support for more than one root directory or constructing
|
||||
# a root from several templates. That would be a nice feature.
|
||||
#
|
||||
|
||||
# Add dependencies on anything in the ROMFS root directory
|
||||
ROMFS_FILES += $(wildcard \
|
||||
$(ROMFS_ROOT)/* \
|
||||
$(ROMFS_ROOT)/*/* \
|
||||
$(ROMFS_ROOT)/*/*/* \
|
||||
$(ROMFS_ROOT)/*/*/*/* \
|
||||
$(ROMFS_ROOT)/*/*/*/*/* \
|
||||
$(ROMFS_ROOT)/*/*/*/*/*/*)
|
||||
ifeq ($(ROMFS_FILES),)
|
||||
$(error ROMFS_ROOT $(ROMFS_ROOT) specifies a directory containing no files)
|
||||
endif
|
||||
ROMFS_DEPS += $(ROMFS_FILES)
|
||||
|
||||
# Extra files that may be copied into the ROMFS /extras directory
|
||||
# ROMFS_EXTRA_FILES are required, ROMFS_OPTIONAL_FILES are optional
|
||||
ROMFS_EXTRA_FILES += $(wildcard $(ROMFS_OPTIONAL_FILES))
|
||||
ROMFS_DEPS += $(ROMFS_EXTRA_FILES)
|
||||
|
||||
ROMFS_IMG = romfs.img
|
||||
ROMFS_SCRATCH = romfs_scratch
|
||||
ROMFS_CSRC = $(ROMFS_IMG:.img=.c)
|
||||
ROMFS_OBJ = $(ROMFS_CSRC:.c=.o)
|
||||
LIBS += $(ROMFS_OBJ)
|
||||
LINK_DEPS += $(ROMFS_OBJ)
|
||||
|
||||
# Remove all comments from startup and mixer files
|
||||
ROMFS_PRUNER = $(PX4_BASE)/Tools/px_romfs_pruner.py
|
||||
|
||||
# Turn the ROMFS image into an object file
|
||||
$(ROMFS_OBJ): $(ROMFS_IMG) $(GLOBAL_DEPS)
|
||||
$(call BIN_TO_OBJ,$<,$@,romfs_img)
|
||||
|
||||
# Generate the ROMFS image from the root
|
||||
$(ROMFS_IMG): $(ROMFS_SCRATCH) $(ROMFS_DEPS) $(GLOBAL_DEPS)
|
||||
@$(ECHO) "ROMFS: $@"
|
||||
$(Q) $(GENROMFS) -f $@ -d $(ROMFS_SCRATCH) -V "NSHInitVol"
|
||||
|
||||
# Construct the ROMFS scratch root from the canonical root
|
||||
$(ROMFS_SCRATCH): $(ROMFS_DEPS) $(GLOBAL_DEPS)
|
||||
$(Q) $(MKDIR) -p $(ROMFS_SCRATCH)
|
||||
$(Q) $(COPYDIR) $(ROMFS_ROOT)/* $(ROMFS_SCRATCH)
|
||||
# delete all files in ROMFS_SCRATCH which start with a . or end with a ~
|
||||
$(Q) $(RM) $(ROMFS_SCRATCH)/*/.[!.]* $(ROMFS_SCRATCH)/*/*~
|
||||
ifneq ($(ROMFS_EXTRA_FILES),)
|
||||
$(Q) $(MKDIR) -p $(ROMFS_SCRATCH)/extras
|
||||
$(Q) $(COPY) $(ROMFS_EXTRA_FILES) $(ROMFS_SCRATCH)/extras
|
||||
endif
|
||||
$(Q) $(PYTHON) -u $(ROMFS_PRUNER) --folder $(ROMFS_SCRATCH)
|
||||
|
||||
EXTRA_CLEANS += $(ROMGS_OBJ) $(ROMFS_IMG)
|
||||
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
# Builtin command list generation
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# Builtin commands can be generated by the configuration, in which case they
|
||||
# must refer to commands that already exist, or indirectly generated by modules
|
||||
# when they are built.
|
||||
#
|
||||
# The configuration supplies builtin command information in the BUILTIN_COMMANDS
|
||||
# variable. Applications make empty files in $(WORK_DIR)/builtin_commands whose
|
||||
# filename contains the same information.
|
||||
#
|
||||
# In each case, the command information consists of four fields separated with a
|
||||
# period. These fields are the command's name, its thread priority, its stack size
|
||||
# and the name of the function to call when starting the thread.
|
||||
#
|
||||
BUILTIN_CSRC = $(WORK_DIR)builtin_commands.c
|
||||
|
||||
# command definitions from modules (may be empty at Makefile parsing time...)
|
||||
MODULE_COMMANDS = $(subst COMMAND.,,$(notdir $(wildcard $(WORK_DIR)builtin_commands/COMMAND.*)))
|
||||
|
||||
# We must have at least one pre-defined builtin command in order to generate
|
||||
# any of this.
|
||||
#
|
||||
ifneq ($(BUILTIN_COMMANDS),)
|
||||
|
||||
# (BUILTIN_PROTO,<cmdspec>,<outputfile>)
|
||||
define BUILTIN_PROTO
|
||||
$(ECHO) 'extern int $(word 4,$1)(int argc, char *argv[]);' >> $2;
|
||||
endef
|
||||
|
||||
# (BUILTIN_DEF,<cmdspec>,<outputfile>)
|
||||
define BUILTIN_DEF
|
||||
$(ECHO) ' {"$(word 1,$1)", $(word 2,$1), $(word 3,$1), $(word 4,$1)},' >> $2;
|
||||
endef
|
||||
|
||||
# Don't generate until modules have updated their command files
|
||||
$(BUILTIN_CSRC): $(GLOBAL_DEPS) $(MODULE_OBJS) $(MODULE_MKFILES) $(BUILTIN_COMMAND_FILES)
|
||||
@$(ECHO) "CMDS: $@"
|
||||
$(Q) $(ECHO) '/* builtin command list - automatically generated, do not edit */' > $@
|
||||
$(Q) $(ECHO) '#include <nuttx/config.h>' >> $@
|
||||
$(Q) $(ECHO) '#include <nuttx/binfmt/builtin.h>' >> $@
|
||||
$(Q) $(foreach spec,$(BUILTIN_COMMANDS),$(call BUILTIN_PROTO,$(subst ., ,$(spec)),$@))
|
||||
$(Q) $(foreach spec,$(MODULE_COMMANDS),$(call BUILTIN_PROTO,$(subst ., ,$(spec)),$@))
|
||||
$(Q) $(ECHO) 'const struct builtin_s g_builtins[] = {' >> $@
|
||||
$(Q) $(foreach spec,$(BUILTIN_COMMANDS),$(call BUILTIN_DEF,$(subst ., ,$(spec)),$@))
|
||||
$(Q) $(foreach spec,$(MODULE_COMMANDS),$(call BUILTIN_DEF,$(subst ., ,$(spec)),$@))
|
||||
$(Q) $(ECHO) ' {NULL, 0, 0, NULL}' >> $@
|
||||
$(Q) $(ECHO) '};' >> $@
|
||||
$(Q) $(ECHO) 'const int g_builtin_count = $(words $(BUILTIN_COMMANDS) $(MODULE_COMMANDS));' >> $@
|
||||
|
||||
SRCS += $(BUILTIN_CSRC)
|
||||
|
||||
EXTRA_CLEANS += $(BUILTIN_CSRC)
|
||||
|
||||
endif
|
||||
ifeq ($(PX4_TARGET_OS),nuttx)
|
||||
include $(MK_DIR)/nuttx/nuttx_romfs.mk
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
|
@ -458,19 +339,6 @@ endif
|
|||
# Build rules
|
||||
################################################################################
|
||||
|
||||
ifeq ($(PX4_TARGET_OS),nuttx)
|
||||
#
|
||||
# What we're going to build.
|
||||
#
|
||||
PRODUCT_BUNDLE = $(WORK_DIR)firmware.px4
|
||||
PRODUCT_BIN = $(WORK_DIR)firmware.bin
|
||||
PRODUCT_ELF = $(WORK_DIR)firmware.elf
|
||||
PRODUCT_PARAMXML = $(WORK_DIR)/parameters.xml
|
||||
|
||||
.PHONY: firmware
|
||||
firmware: $(PRODUCT_BUNDLE)
|
||||
endif
|
||||
|
||||
#
|
||||
# Object files we will generate from sources
|
||||
#
|
||||
|
@ -491,68 +359,21 @@ $(filter %.cpp.o,$(OBJS)): $(WORK_DIR)%.cpp.o: %.cpp $(GLOBAL_DEPS)
|
|||
$(filter %.S.o,$(OBJS)): $(WORK_DIR)%.S.o: %.S $(GLOBAL_DEPS)
|
||||
$(call ASSEMBLE,$<,$@)
|
||||
|
||||
ifeq ($(PX4_TARGET_OS),nuttx)
|
||||
#
|
||||
# Built product rules
|
||||
#
|
||||
|
||||
$(PRODUCT_BUNDLE): $(PRODUCT_BIN)
|
||||
@$(ECHO) %% Generating $@
|
||||
ifdef GEN_PARAM_XML
|
||||
$(Q) $(PYTHON) $(PX4_BASE)/Tools/px_process_params.py --src-path $(PX4_BASE)/src --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml
|
||||
$(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \
|
||||
--git_identity $(PX4_BASE) \
|
||||
--parameter_xml $(PRODUCT_PARAMXML) \
|
||||
--image $< > $@
|
||||
else
|
||||
$(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \
|
||||
--git_identity $(PX4_BASE) \
|
||||
--image $< > $@
|
||||
endif
|
||||
|
||||
$(PRODUCT_BIN): $(PRODUCT_ELF)
|
||||
$(call SYM_TO_BIN,$<,$@)
|
||||
|
||||
$(PRODUCT_ELF): $(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS) $(GLOBAL_DEPS) $(LINK_DEPS) $(MODULE_MKFILES)
|
||||
$(call LINK,$@,$(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS))
|
||||
|
||||
#
|
||||
# Utility rules
|
||||
#
|
||||
|
||||
.PHONY: upload
|
||||
upload: $(PRODUCT_BUNDLE) $(PRODUCT_BIN)
|
||||
$(Q) $(MAKE) -f $(PX4_MK_DIR)/upload.mk \
|
||||
METHOD=serial \
|
||||
CONFIG=$(CONFIG) \
|
||||
BOARD=$(BOARD) \
|
||||
BUNDLE=$(PRODUCT_BUNDLE) \
|
||||
BIN=$(PRODUCT_BIN)
|
||||
|
||||
.PHONY: clean
|
||||
clean: $(MODULE_CLEANS)
|
||||
@$(ECHO) %% cleaning
|
||||
$(Q) $(REMOVE) $(PRODUCT_BUNDLE) $(PRODUCT_BIN) $(PRODUCT_ELF)
|
||||
$(Q) $(REMOVE) $(OBJS) $(DEP_INCLUDES) $(EXTRA_CLEANS)
|
||||
$(Q) $(RMDIR) $(NUTTX_EXPORT_DIR)
|
||||
endif
|
||||
|
||||
# Include the OS specific build rules
|
||||
# The rules must define the "firmware" make target
|
||||
#
|
||||
|
||||
ifeq ($(PX4_TARGET_OS),nuttx)
|
||||
# TODO
|
||||
# Move above nuttx specific rules to $(MK_DIR)/nuttx_romfs.mk
|
||||
include $(MK_DIR)/nuttx/nuttx_px4.mk
|
||||
endif
|
||||
ifeq ($(PX4_TARGET_OS),posix)
|
||||
include $(MK_DIR)/posix_elf.mk
|
||||
include $(MK_DIR)/posix/posix_elf.mk
|
||||
endif
|
||||
ifeq ($(PX4_TARGET_OS),posix-arm)
|
||||
include $(MK_DIR)/posix_elf.mk
|
||||
include $(MK_DIR)/posix/posix_elf.mk
|
||||
endif
|
||||
ifeq ($(PX4_TARGET_OS),qurt)
|
||||
include $(MK_DIR)/qurt_elf.mk
|
||||
include $(MK_DIR)/qurt/qurt_elf.mk
|
||||
endif
|
||||
|
||||
#
|
||||
|
|
|
@ -1,38 +1,6 @@
|
|||
#
|
||||
# Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# Built products
|
||||
#
|
||||
|
||||
DESIRED_FIRMWARES = $(foreach config,$(CONFIGS),$(IMAGE_DIR)$(config).px4)
|
||||
STAGED_FIRMWARES = $(foreach config,$(KNOWN_CONFIGS),$(IMAGE_DIR)$(config).px4)
|
||||
FIRMWARES = $(foreach config,$(KNOWN_CONFIGS),$(BUILD_DIR)$(config).build/firmware.px4)
|
||||
|
@ -57,7 +25,7 @@ $(STAGED_FIRMWARES): $(IMAGE_DIR)%.px4: $(BUILD_DIR)%.build/firmware.px4
|
|||
.PHONY: $(FIRMWARES)
|
||||
$(BUILD_DIR)%.build/firmware.px4: config = $(patsubst $(BUILD_DIR)%.build/firmware.px4,%,$@)
|
||||
$(BUILD_DIR)%.build/firmware.px4: work_dir = $(BUILD_DIR)$(config).build/
|
||||
$(FIRMWARES): $(BUILD_DIR)%.build/firmware.px4: generateuorbtopicheaders checksubmodules
|
||||
$(FIRMWARES): $(BUILD_DIR)%.build/firmware.px4: checkgitversion generateuorbtopicheaders checksubmodules
|
||||
@$(ECHO) %%%%
|
||||
@$(ECHO) %%%% Building $(config) in $(work_dir)
|
||||
@$(ECHO) %%%%
|
||||
|
@ -134,6 +102,7 @@ menuconfig: $(NUTTX_SRC)
|
|||
$(Q) (cd $(NUTTX_SRC)/configs && $(COPYDIR) $(PX4_BASE)nuttx-configs/$(BOARD) .)
|
||||
$(Q) (cd $(NUTTX_SRC)tools && ./configure.sh $(BOARD)/nsh)
|
||||
@$(ECHO) %% Running menuconfig for $(BOARD)
|
||||
$(Q) $(MAKE) -r -j$(J) -C $(NUTTX_SRC) -r $(MQUIET) oldconfig
|
||||
$(Q) $(MAKE) -r -j$(J) -C $(NUTTX_SRC) -r $(MQUIET) menuconfig
|
||||
@$(ECHO) %% Saving configuration file
|
||||
$(Q)$(COPY) $(NUTTX_SRC).config $(PX4_BASE)nuttx-configs/$(BOARD)/nsh/defconfig
|
||||
|
@ -142,9 +111,10 @@ menuconfig:
|
|||
@$(ECHO) ""
|
||||
@$(ECHO) "The menuconfig goal must be invoked without any other goal being specified"
|
||||
@$(ECHO) ""
|
||||
|
||||
endif
|
||||
|
||||
$(NUTTX_SRC): checksubmodules
|
||||
$(NUTTX_SRC): checkgitversion checksubmodules
|
||||
|
||||
$(UAVCAN_DIR):
|
||||
$(Q) (./Tools/check_submodules.sh)
|
|
@ -0,0 +1,86 @@
|
|||
#
|
||||
# Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# What we're going to build.
|
||||
#
|
||||
PRODUCT_BUNDLE = $(WORK_DIR)firmware.px4
|
||||
PRODUCT_BIN = $(WORK_DIR)firmware.bin
|
||||
PRODUCT_ELF = $(WORK_DIR)firmware.elf
|
||||
PRODUCT_PARAMXML = $(WORK_DIR)/parameters.xml
|
||||
|
||||
.PHONY: firmware
|
||||
firmware: $(PRODUCT_BUNDLE)
|
||||
|
||||
#
|
||||
# Built product rules
|
||||
#
|
||||
|
||||
$(PRODUCT_BUNDLE): $(PRODUCT_BIN)
|
||||
@$(ECHO) %% Generating $@
|
||||
ifdef GEN_PARAM_XML
|
||||
$(Q) $(PYTHON) $(PX4_BASE)/Tools/px_process_params.py --src-path $(PX4_BASE)/src --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml
|
||||
$(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \
|
||||
--git_identity $(PX4_BASE) \
|
||||
--parameter_xml $(PRODUCT_PARAMXML) \
|
||||
--image $< > $@
|
||||
else
|
||||
$(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \
|
||||
--git_identity $(PX4_BASE) \
|
||||
--image $< > $@
|
||||
endif
|
||||
|
||||
$(PRODUCT_BIN): $(PRODUCT_ELF)
|
||||
$(call SYM_TO_BIN,$<,$@)
|
||||
|
||||
$(PRODUCT_ELF): $(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS) $(GLOBAL_DEPS) $(LINK_DEPS) $(MODULE_MKFILES)
|
||||
$(call LINK,$@,$(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS))
|
||||
|
||||
#
|
||||
# Utility rules
|
||||
#
|
||||
|
||||
.PHONY: upload
|
||||
upload: $(PRODUCT_BUNDLE) $(PRODUCT_BIN)
|
||||
$(Q) $(MAKE) -f $(PX4_MK_DIR)/nuttx/upload.mk \
|
||||
METHOD=serial \
|
||||
CONFIG=$(CONFIG) \
|
||||
BOARD=$(BOARD) \
|
||||
BUNDLE=$(PRODUCT_BUNDLE) \
|
||||
BIN=$(PRODUCT_BIN)
|
||||
|
||||
.PHONY: clean
|
||||
clean: $(MODULE_CLEANS)
|
||||
@$(ECHO) %% cleaning
|
||||
$(Q) $(REMOVE) $(PRODUCT_BUNDLE) $(PRODUCT_BIN) $(PRODUCT_ELF)
|
||||
$(Q) $(REMOVE) $(OBJS) $(DEP_INCLUDES) $(EXTRA_CLEANS)
|
||||
$(Q) $(RMDIR) $(NUTTX_EXPORT_DIR)
|
||||
|
|
@ -29,10 +29,6 @@
|
|||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# Makefile for PX4 Nuttx based firmware images.
|
||||
#
|
||||
|
||||
################################################################################
|
||||
# ROMFS generation
|
||||
################################################################################
|
||||
|
@ -158,62 +154,3 @@ EXTRA_CLEANS += $(BUILTIN_CSRC)
|
|||
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
# Build rules
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# What we're going to build.
|
||||
#
|
||||
PRODUCT_BUNDLE = $(WORK_DIR)firmware.px4
|
||||
PRODUCT_BIN = $(WORK_DIR)firmware.bin
|
||||
PRODUCT_ELF = $(WORK_DIR)firmware.elf
|
||||
PRODUCT_PARAMXML = $(WORK_DIR)/parameters.xml
|
||||
|
||||
.PHONY: firmware
|
||||
firmware: $(PRODUCT_BUNDLE)
|
||||
|
||||
#
|
||||
# Built product rules
|
||||
#
|
||||
|
||||
$(PRODUCT_BUNDLE): $(PRODUCT_BIN)
|
||||
@$(ECHO) %% Generating $@
|
||||
ifdef GEN_PARAM_XML
|
||||
python $(PX4_BASE)/Tools/px_process_params.py --src-path $(PX4_BASE)/src --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml
|
||||
$(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \
|
||||
--git_identity $(PX4_BASE) \
|
||||
--parameter_xml $(PRODUCT_PARAMXML) \
|
||||
--image $< > $@
|
||||
else
|
||||
$(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \
|
||||
--git_identity $(PX4_BASE) \
|
||||
--image $< > $@
|
||||
endif
|
||||
|
||||
$(PRODUCT_BIN): $(PRODUCT_ELF)
|
||||
$(call SYM_TO_BIN,$<,$@)
|
||||
|
||||
$(PRODUCT_ELF): $(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS) $(GLOBAL_DEPS) $(LINK_DEPS) $(MODULE_MKFILES)
|
||||
$(call LINK,$@,$(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS))
|
||||
|
||||
#
|
||||
# Utility rules
|
||||
#
|
||||
|
||||
.PHONY: upload
|
||||
upload: $(PRODUCT_BUNDLE) $(PRODUCT_BIN)
|
||||
$(Q) $(MAKE) -f $(PX4_MK_DIR)/upload.mk \
|
||||
METHOD=serial \
|
||||
CONFIG=$(CONFIG) \
|
||||
BOARD=$(BOARD) \
|
||||
BUNDLE=$(PRODUCT_BUNDLE) \
|
||||
BIN=$(PRODUCT_BIN)
|
||||
|
||||
.PHONY: clean
|
||||
clean: $(MODULE_CLEANS)
|
||||
@$(ECHO) %% cleaning
|
||||
$(Q) $(REMOVE) $(PRODUCT_BUNDLE) $(PRODUCT_BIN) $(PRODUCT_ELF)
|
||||
$(Q) $(REMOVE) $(OBJS) $(DEP_INCLUDES) $(EXTRA_CLEANS)
|
||||
$(Q) $(RMDIR) $(NUTTX_EXPORT_DIR)
|
||||
|
|
@ -209,7 +209,7 @@ AFLAGS = $(CFLAGS) -D__ASSEMBLY__ \
|
|||
$(EXTRADEFINES) \
|
||||
$(EXTRAAFLAGS)
|
||||
|
||||
LDSCRIPT = $(PX4_BASE)/posix-configs/posixtest/scripts/ld.script
|
||||
LDSCRIPT = $(PX4_BASE)/makefiles/posix/ld.script
|
||||
# Flags we pass to the linker
|
||||
#
|
||||
LDFLAGS += -g -mv5 -nostdlib -mG0lib -G0 -fpic -shared \
|
||||
|
|
Loading…
Reference in New Issue