2013-02-23 20:05:59 -04:00
|
|
|
#
|
2015-02-03 15:27:51 -04:00
|
|
|
# Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
|
2013-02-23 20:05:59 -04:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2012-08-04 19:12:36 -03:00
|
|
|
#
|
|
|
|
# Top-level Makefile for building PX4 firmware images.
|
|
|
|
#
|
2013-01-16 22:23:49 -04:00
|
|
|
|
2015-06-07 18:40:54 -03:00
|
|
|
TARGETS := nuttx posix posix-arm qurt
|
2015-05-20 23:19:08 -03:00
|
|
|
EXPLICIT_TARGET := $(filter $(TARGETS),$(MAKECMDGOALS))
|
|
|
|
ifneq ($(EXPLICIT_TARGET),)
|
|
|
|
export PX4_TARGET_OS=$(EXPLICIT_TARGET)
|
2015-05-21 17:45:53 -03:00
|
|
|
export GOALS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
2015-05-20 23:19:08 -03:00
|
|
|
endif
|
|
|
|
|
2012-08-04 19:12:36 -03:00
|
|
|
#
|
2013-02-21 01:12:59 -04:00
|
|
|
# Get path and tool configuration
|
2012-08-04 19:12:36 -03:00
|
|
|
#
|
2013-02-23 16:23:34 -04:00
|
|
|
export PX4_BASE := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))/
|
|
|
|
include $(PX4_BASE)makefiles/setup.mk
|
2013-01-16 22:23:49 -04:00
|
|
|
|
2013-09-06 14:18:08 -03:00
|
|
|
#
|
|
|
|
# Get a version string provided by git
|
|
|
|
# This assumes that git command is available and that
|
|
|
|
# the directory holding this file also contains .git directory
|
|
|
|
#
|
|
|
|
GIT_DESC := $(shell git log -1 --pretty=format:%H)
|
|
|
|
ifneq ($(words $(GIT_DESC)),1)
|
|
|
|
GIT_DESC := "unknown_git_version"
|
|
|
|
endif
|
2015-05-22 17:22:12 -03:00
|
|
|
|
2015-05-23 06:04:19 -03:00
|
|
|
GIT_DESC_SHORT := $(shell echo $(GIT_DESC) | cut -c1-16)
|
|
|
|
|
2013-01-16 22:23:49 -04:00
|
|
|
#
|
2013-08-26 02:26:47 -03:00
|
|
|
# Canned firmware configurations that we (know how to) build.
|
2013-01-16 22:23:49 -04:00
|
|
|
#
|
2015-03-10 19:13:22 -03:00
|
|
|
KNOWN_CONFIGS := $(subst config_,,$(basename $(notdir $(wildcard $(PX4_MK_DIR)/$(PX4_TARGET_OS)/config_*.mk))))
|
2013-08-26 02:26:47 -03:00
|
|
|
CONFIGS ?= $(KNOWN_CONFIGS)
|
2012-08-04 19:12:36 -03:00
|
|
|
|
2013-01-17 02:38:47 -04:00
|
|
|
#
|
2013-08-26 02:26:47 -03:00
|
|
|
# Boards that we (know how to) build NuttX export kits for.
|
2013-01-17 02:38:47 -04:00
|
|
|
#
|
2015-03-10 19:13:22 -03:00
|
|
|
KNOWN_BOARDS := $(subst board_,,$(basename $(notdir $(wildcard $(PX4_MK_DIR)/$(PX4_TARGET_OS)/board_*.mk))))
|
2013-08-26 02:26:47 -03:00
|
|
|
BOARDS ?= $(KNOWN_BOARDS)
|
2013-01-17 02:38:47 -04:00
|
|
|
|
2012-08-04 19:12:36 -03:00
|
|
|
#
|
2013-02-21 01:25:04 -04:00
|
|
|
# Debugging
|
|
|
|
#
|
|
|
|
MQUIET = --no-print-directory
|
|
|
|
#MQUIET = --print-directory
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# No user-serviceable parts below
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# If the user has listed a config as a target, strip it out and override CONFIGS.
|
2012-08-04 19:12:36 -03:00
|
|
|
#
|
2013-04-26 20:14:32 -03:00
|
|
|
FIRMWARE_GOAL = firmware
|
2013-01-16 22:23:49 -04:00
|
|
|
EXPLICIT_CONFIGS := $(filter $(CONFIGS),$(MAKECMDGOALS))
|
|
|
|
ifneq ($(EXPLICIT_CONFIGS),)
|
|
|
|
CONFIGS := $(EXPLICIT_CONFIGS)
|
|
|
|
.PHONY: $(EXPLICIT_CONFIGS)
|
|
|
|
$(EXPLICIT_CONFIGS): all
|
2013-04-26 20:14:32 -03:00
|
|
|
|
|
|
|
#
|
|
|
|
# If the user has asked to upload, they must have also specified exactly one
|
|
|
|
# config.
|
|
|
|
#
|
|
|
|
ifneq ($(filter upload,$(MAKECMDGOALS)),)
|
|
|
|
ifneq ($(words $(EXPLICIT_CONFIGS)),1)
|
|
|
|
$(error In order to upload, exactly one board config must be specified)
|
|
|
|
endif
|
|
|
|
FIRMWARE_GOAL = upload
|
|
|
|
.PHONY: upload
|
|
|
|
upload:
|
|
|
|
@:
|
|
|
|
endif
|
2013-01-11 06:14:43 -04:00
|
|
|
endif
|
2012-08-04 19:12:36 -03:00
|
|
|
|
2015-03-10 19:13:22 -03:00
|
|
|
ifeq ($(PX4_TARGET_OS),nuttx)
|
2015-06-15 21:23:04 -03:00
|
|
|
include $(PX4_BASE)makefiles/nuttx/firmware_nuttx.mk
|
2013-08-10 16:39:58 -03:00
|
|
|
endif
|
2015-04-21 13:53:09 -03:00
|
|
|
ifeq ($(PX4_TARGET_OS),posix)
|
2015-06-15 21:23:04 -03:00
|
|
|
include $(PX4_BASE)makefiles/posix/firmware_posix.mk
|
2013-08-10 16:39:58 -03:00
|
|
|
endif
|
2015-06-07 18:40:54 -03:00
|
|
|
ifeq ($(PX4_TARGET_OS),posix-arm)
|
2015-06-15 21:23:04 -03:00
|
|
|
include $(PX4_BASE)makefiles/posix/firmware_posix.mk
|
2015-06-07 18:40:54 -03:00
|
|
|
endif
|
2015-04-17 22:38:30 -03:00
|
|
|
ifeq ($(PX4_TARGET_OS),qurt)
|
2015-06-15 21:23:04 -03:00
|
|
|
include $(PX4_BASE)makefiles/qurt/firmware_qurt.mk
|
2015-04-17 22:38:30 -03:00
|
|
|
endif
|
2013-08-10 16:39:58 -03:00
|
|
|
|
2015-08-26 01:59:01 -03:00
|
|
|
qurt_fixup:
|
|
|
|
makefiles/qurt/setup.sh $(PX4_BASE)
|
|
|
|
|
|
|
|
restore:
|
|
|
|
cd src/lib/eigen && git checkout .
|
|
|
|
git submodule update
|
|
|
|
|
2015-06-12 13:49:15 -03:00
|
|
|
#
|
|
|
|
# Versioning
|
|
|
|
#
|
|
|
|
|
|
|
|
GIT_VER_FILE = $(PX4_VERSIONING_DIR).build_git_ver
|
|
|
|
GIT_HEADER_FILE = $(PX4_VERSIONING_DIR)build_git_version.h
|
|
|
|
|
|
|
|
$(GIT_VER_FILE) :
|
|
|
|
$(Q) if [ ! -f $(GIT_VER_FILE) ]; then \
|
|
|
|
$(MKDIR) -p $(PX4_VERSIONING_DIR); \
|
|
|
|
$(ECHO) "" > $(GIT_VER_FILE); \
|
|
|
|
fi
|
|
|
|
|
|
|
|
.PHONY: checkgitversion
|
|
|
|
checkgitversion: $(GIT_VER_FILE)
|
|
|
|
$(Q) if [ "$(GIT_DESC)" != "$(shell cat $(GIT_VER_FILE))" ]; then \
|
|
|
|
$(ECHO) "/* Auto Magically Generated file */" > $(GIT_HEADER_FILE); \
|
|
|
|
$(ECHO) "/* Do not edit! */" >> $(GIT_HEADER_FILE); \
|
|
|
|
$(ECHO) "#define PX4_GIT_VERSION_STR \"$(GIT_DESC)\"" >> $(GIT_HEADER_FILE); \
|
|
|
|
$(ECHO) "#define PX4_GIT_VERSION_BINARY 0x$(GIT_DESC_SHORT)" >> $(GIT_HEADER_FILE); \
|
|
|
|
$(ECHO) $(GIT_DESC) > $(GIT_VER_FILE); \
|
|
|
|
fi
|
2015-06-13 13:07:57 -03:00
|
|
|
#
|
|
|
|
# Sizes
|
|
|
|
#
|
|
|
|
|
|
|
|
.PHONY: size
|
|
|
|
size:
|
|
|
|
$(Q) for elfs in Build/*; do if [ -f $$elfs/firmware.elf ]; then $(SIZE) $$elfs/firmware.elf; fi done
|
|
|
|
|
2015-06-12 13:49:15 -03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Submodule Checks
|
|
|
|
#
|
2014-12-01 11:39:27 -04:00
|
|
|
|
2015-03-11 14:56:06 -03:00
|
|
|
.PHONY: checksubmodules
|
|
|
|
checksubmodules:
|
2015-08-26 01:59:01 -03:00
|
|
|
$(Q) ($(PX4_BASE)/Tools/check_submodules.sh $(PX4_TARGET_OS))
|
2015-03-11 14:56:06 -03:00
|
|
|
|
|
|
|
.PHONY: updatesubmodules
|
|
|
|
updatesubmodules:
|
|
|
|
$(Q) (git submodule init)
|
|
|
|
$(Q) (git submodule update)
|
2015-03-10 19:13:22 -03:00
|
|
|
|
2015-05-15 16:56:18 -03:00
|
|
|
MSG_DIR = $(PX4_BASE)msg
|
|
|
|
UORB_TEMPLATE_DIR = $(PX4_BASE)msg/templates/uorb
|
|
|
|
MULTIPLATFORM_TEMPLATE_DIR = $(PX4_BASE)msg/templates/px4/uorb
|
|
|
|
TOPICS_DIR = $(PX4_BASE)src/modules/uORB/topics
|
|
|
|
MULTIPLATFORM_HEADER_DIR = $(PX4_BASE)src/platforms/$(PX4_TARGET_OS)/px4_messages
|
|
|
|
MULTIPLATFORM_PREFIX = px4_
|
|
|
|
TOPICHEADER_TEMP_DIR = $(BUILD_DIR)topics_temporary
|
2015-07-12 10:51:43 -03:00
|
|
|
MULTI_TOPICHEADER_TEMP_DIR = $(BUILD_DIR)multi_topics_temporary
|
2015-05-15 16:56:18 -03:00
|
|
|
GENMSG_PYTHONPATH = $(PX4_BASE)Tools/genmsg/src
|
|
|
|
GENCPP_PYTHONPATH = $(PX4_BASE)Tools/gencpp/src
|
|
|
|
|
2014-12-01 11:39:27 -04:00
|
|
|
.PHONY: generateuorbtopicheaders
|
2015-03-11 14:56:06 -03:00
|
|
|
generateuorbtopicheaders: checksubmodules
|
2014-12-01 11:39:27 -04:00
|
|
|
@$(ECHO) "Generating uORB topic headers"
|
2015-02-13 06:38:21 -04:00
|
|
|
$(Q) (PYTHONPATH=$(GENMSG_PYTHONPATH):$(GENCPP_PYTHONPATH):$(PYTHONPATH) $(PYTHON) \
|
2014-12-04 11:40:46 -04:00
|
|
|
$(PX4_BASE)Tools/px_generate_uorb_topic_headers.py \
|
2015-01-23 05:34:04 -04:00
|
|
|
-d $(MSG_DIR) -o $(TOPICS_DIR) -e $(UORB_TEMPLATE_DIR) -t $(TOPICHEADER_TEMP_DIR))
|
|
|
|
@$(ECHO) "Generating multiplatform uORB topic wrapper headers"
|
2015-02-13 06:38:21 -04:00
|
|
|
$(Q) (PYTHONPATH=$(GENMSG_PYTHONPATH):$(GENCPP_PYTHONPATH):$(PYTHONPATH) $(PYTHON) \
|
2015-01-23 05:34:04 -04:00
|
|
|
$(PX4_BASE)Tools/px_generate_uorb_topic_headers.py \
|
2015-07-12 10:51:43 -03:00
|
|
|
-d $(MSG_DIR) -o $(MULTIPLATFORM_HEADER_DIR) -e $(MULTIPLATFORM_TEMPLATE_DIR) -t $(MULTI_TOPICHEADER_TEMP_DIR) -p $(MULTIPLATFORM_PREFIX))
|
2014-12-01 11:39:27 -04:00
|
|
|
|
2013-08-04 19:01:11 -03:00
|
|
|
#
|
|
|
|
# Testing targets
|
|
|
|
#
|
|
|
|
testbuild:
|
2013-08-23 03:47:55 -03:00
|
|
|
$(Q) (cd $(PX4_BASE) && $(MAKE) distclean && $(MAKE) archives && $(MAKE) -j8)
|
2014-12-21 07:09:16 -04:00
|
|
|
$(Q) (zip -r Firmware.zip $(PX4_BASE)/Images)
|
2013-08-04 19:01:11 -03:00
|
|
|
|
2015-06-07 18:40:54 -03:00
|
|
|
nuttx posix posix-arm qurt:
|
2015-05-21 17:45:53 -03:00
|
|
|
ifeq ($(GOALS),)
|
2015-07-05 07:06:45 -03:00
|
|
|
$(MAKE) PX4_TARGET_OS=$@ $(GOALS)
|
2015-05-21 17:45:53 -03:00
|
|
|
else
|
|
|
|
export PX4_TARGET_OS=$@
|
|
|
|
endif
|
2015-04-22 12:48:48 -03:00
|
|
|
|
2015-07-02 20:52:20 -03:00
|
|
|
sitl_quad:
|
|
|
|
$(Q) Tools/sitl_run.sh posix-configs/SITL/init/rcS
|
2015-07-23 10:45:59 -03:00
|
|
|
sitl_quad_gazebo:
|
|
|
|
$(Q) Tools/sitl_run.sh posix-configs/SITL/init/rc_iris_ros
|
2015-07-02 20:52:20 -03:00
|
|
|
sitl_plane:
|
|
|
|
$(Q) Tools/sitl_run.sh posix-configs/SITL/init/rc.fixed_wing
|
2015-03-24 20:30:45 -03:00
|
|
|
|
2015-04-22 12:48:48 -03:00
|
|
|
qurtrun:
|
2015-07-05 07:06:45 -03:00
|
|
|
$(MAKE) PX4_TARGET_OS=qurt sim
|
2015-04-22 12:48:48 -03:00
|
|
|
|
2014-12-20 13:50:51 -04:00
|
|
|
#
|
|
|
|
# Unittest targets. Builds and runs the host-level
|
|
|
|
# unit tests.
|
|
|
|
.PHONY: tests
|
2015-01-07 12:28:56 -04:00
|
|
|
tests: generateuorbtopicheaders
|
2015-08-29 21:01:07 -03:00
|
|
|
$(Q) (mkdir -p $(PX4_BASE)/unittests/build && cd $(PX4_BASE)/unittests/build && cmake .. && $(MAKE) --no-print-directory unittests)
|
2013-08-04 19:01:11 -03:00
|
|
|
|
2015-08-22 17:25:47 -03:00
|
|
|
.PHONY: check_format
|
2015-01-06 00:16:30 -04:00
|
|
|
check_format:
|
2015-08-22 17:25:47 -03:00
|
|
|
$(Q) (./Tools/check_code_style.sh)
|
2015-01-06 00:16:30 -04:00
|
|
|
|
2012-08-04 19:12:36 -03:00
|
|
|
#
|
|
|
|
# Cleanup targets. 'clean' should remove all built products and force
|
2014-12-01 11:39:27 -04:00
|
|
|
# a complete re-compilation, 'distclean' should remove everything
|
2012-08-04 19:12:36 -03:00
|
|
|
# that's generated leaving only files that are in source control.
|
|
|
|
#
|
2013-01-16 22:23:49 -04:00
|
|
|
.PHONY: clean
|
2012-08-04 19:12:36 -03:00
|
|
|
clean:
|
2014-12-26 12:37:36 -04:00
|
|
|
@echo > /dev/null
|
|
|
|
$(Q) $(RMDIR) $(BUILD_DIR)*.build
|
2015-06-12 13:49:15 -03:00
|
|
|
$(Q) $(RMDIR) $(PX4_VERSIONING_DIR)
|
2014-12-26 12:37:36 -04:00
|
|
|
$(Q) $(REMOVE) $(IMAGE_DIR)*.px4
|
2015-07-12 10:51:43 -03:00
|
|
|
$(Q) $(RMDIR) $(TOPICHEADER_TEMP_DIR)
|
|
|
|
$(Q) $(RMDIR) $(MULTI_TOPICHEADER_TEMP_DIR)
|
2012-08-04 19:12:36 -03:00
|
|
|
|
|
|
|
.PHONY: distclean
|
2013-01-16 22:23:49 -04:00
|
|
|
distclean: clean
|
2014-12-26 12:37:36 -04:00
|
|
|
@echo > /dev/null
|
|
|
|
$(Q) $(REMOVE) $(ARCHIVE_DIR)*.export
|
|
|
|
$(Q) $(MAKE) -C $(NUTTX_SRC) -r $(MQUIET) distclean
|
|
|
|
$(Q) (cd $(NUTTX_SRC)/configs && $(FIND) . -maxdepth 1 -type l -delete)
|
2012-08-04 19:12:36 -03:00
|
|
|
|
2013-03-31 19:46:07 -03:00
|
|
|
#
|
|
|
|
# Print some help text
|
|
|
|
#
|
|
|
|
.PHONY: help
|
|
|
|
help:
|
2013-07-07 21:53:55 -03:00
|
|
|
@$(ECHO) ""
|
|
|
|
@$(ECHO) " PX4 firmware builder"
|
|
|
|
@$(ECHO) " ===================="
|
|
|
|
@$(ECHO) ""
|
|
|
|
@$(ECHO) " Available targets:"
|
|
|
|
@$(ECHO) " ------------------"
|
|
|
|
@$(ECHO) ""
|
2015-05-20 23:19:08 -03:00
|
|
|
ifeq ($(PX4_TARGET_OS),nuttx)
|
2013-07-07 21:53:55 -03:00
|
|
|
@$(ECHO) " archives"
|
|
|
|
@$(ECHO) " Build the NuttX RTOS archives that are used by the firmware build."
|
|
|
|
@$(ECHO) ""
|
2015-05-20 23:19:08 -03:00
|
|
|
endif
|
2013-07-07 21:53:55 -03:00
|
|
|
@$(ECHO) " all"
|
|
|
|
@$(ECHO) " Build all firmware configs: $(CONFIGS)"
|
|
|
|
@$(ECHO) " A limited set of configs can be built with CONFIGS=<list-of-configs>"
|
|
|
|
@$(ECHO) ""
|
2013-03-31 19:46:07 -03:00
|
|
|
@for config in $(CONFIGS); do \
|
2013-08-23 03:47:55 -03:00
|
|
|
$(ECHO) " $$config"; \
|
|
|
|
$(ECHO) " Build just the $$config firmware configuration."; \
|
|
|
|
$(ECHO) ""; \
|
2013-03-31 19:46:07 -03:00
|
|
|
done
|
2013-07-07 21:53:55 -03:00
|
|
|
@$(ECHO) " clean"
|
|
|
|
@$(ECHO) " Remove all firmware build pieces."
|
|
|
|
@$(ECHO) ""
|
2015-05-20 23:19:08 -03:00
|
|
|
ifeq ($(PX4_TARGET_OS),nuttx)
|
2013-07-07 21:53:55 -03:00
|
|
|
@$(ECHO) " distclean"
|
|
|
|
@$(ECHO) " Remove all compilation products, including NuttX RTOS archives."
|
|
|
|
@$(ECHO) ""
|
|
|
|
@$(ECHO) " upload"
|
|
|
|
@$(ECHO) " When exactly one config is being built, add this target to upload the"
|
|
|
|
@$(ECHO) " firmware to the board when the build is complete. Not supported for"
|
|
|
|
@$(ECHO) " all configurations."
|
|
|
|
@$(ECHO) ""
|
2015-05-20 23:19:08 -03:00
|
|
|
endif
|
2013-08-04 19:01:11 -03:00
|
|
|
@$(ECHO) " testbuild"
|
|
|
|
@$(ECHO) " Perform a complete clean build of the entire tree."
|
|
|
|
@$(ECHO) ""
|
2013-07-07 21:53:55 -03:00
|
|
|
@$(ECHO) " Common options:"
|
|
|
|
@$(ECHO) " ---------------"
|
|
|
|
@$(ECHO) ""
|
|
|
|
@$(ECHO) " V=1"
|
|
|
|
@$(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) ""
|
2015-06-15 21:23:04 -03:00
|
|
|
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
|
|
|
|
|