2013-02-23 20:05:59 -04:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2013-01-06 01:46:50 -04:00
|
|
|
#
|
2013-02-23 03:27:24 -04:00
|
|
|
# Generic Makefile for PX4 firmware images.
|
2013-01-06 01:46:50 -04:00
|
|
|
#
|
2013-01-17 01:03:27 -04:00
|
|
|
# Requires:
|
|
|
|
#
|
2013-02-21 01:25:04 -04:00
|
|
|
# BOARD
|
|
|
|
# Must be set to a board name known to the PX4 distribution (as
|
2013-02-21 01:12:59 -04:00
|
|
|
# we need a corresponding NuttX export archive to link with).
|
2013-01-17 01:03:27 -04:00
|
|
|
#
|
|
|
|
# Optional:
|
|
|
|
#
|
2013-02-23 16:23:34 -04:00
|
|
|
# MODULES
|
|
|
|
# Contains a list of module paths or path fragments used
|
|
|
|
# to find modules. The names listed here are searched in
|
2013-02-23 03:27:24 -04:00
|
|
|
# the following directories:
|
|
|
|
# <absolute path>
|
2013-02-23 16:23:34 -04:00
|
|
|
# $(MODULE_SEARCH_DIRS)
|
2013-02-23 03:27:24 -04:00
|
|
|
# WORK_DIR
|
2013-02-23 16:23:34 -04:00
|
|
|
# MODULE_SRC
|
|
|
|
# PX4_MODULE_SRC
|
2013-02-23 03:27:24 -04:00
|
|
|
#
|
2013-02-23 16:23:34 -04:00
|
|
|
# Application directories are expected to contain a module.mk
|
|
|
|
# file which provides build configuration for the module. See
|
|
|
|
# makefiles/module.mk for more details.
|
2013-02-23 03:27:24 -04:00
|
|
|
#
|
|
|
|
# BUILTIN_COMMANDS
|
|
|
|
# Contains a list of built-in commands not explicitly provided
|
2013-02-23 16:23:34 -04:00
|
|
|
# by modules / libraries. Each entry in this list is formatted
|
2013-02-23 03:27:24 -04:00
|
|
|
# as <command>.<priority>.<stacksize>.<entrypoint>
|
|
|
|
#
|
2013-01-17 01:03:27 -04:00
|
|
|
# PX4_BASE:
|
|
|
|
# Points to a PX4 distribution. Normally determined based on the
|
|
|
|
# path to this file.
|
|
|
|
#
|
|
|
|
# CONFIG:
|
2013-04-26 20:14:32 -03:00
|
|
|
# Used when searching for the configuration file, and available
|
|
|
|
# to module Makefiles to select optional features.
|
|
|
|
# If not set, CONFIG_FILE must be set and CONFIG will be derived
|
|
|
|
# automatically from it.
|
|
|
|
#
|
|
|
|
# CONFIG_FILE:
|
|
|
|
# If set, overrides the configuration file search logic. Sets
|
|
|
|
# CONFIG to the name of the configuration file, strips any
|
|
|
|
# leading config_ prefix and any suffix. e.g. config_board_foo.mk
|
|
|
|
# results in CONFIG being set to 'board_foo'.
|
2013-01-17 01:03:27 -04:00
|
|
|
#
|
|
|
|
# WORK_DIR:
|
|
|
|
# Sets the directory in which the firmware will be built. Defaults
|
|
|
|
# to the directory 'build' under the directory containing the
|
|
|
|
# parent Makefile.
|
|
|
|
#
|
2013-01-17 03:40:40 -04:00
|
|
|
# ROMFS_ROOT:
|
|
|
|
# If set to the path to a directory, a ROMFS image will be generated
|
|
|
|
# containing the files under the directory and linked into the final
|
|
|
|
# image.
|
|
|
|
#
|
2013-02-23 16:23:34 -04:00
|
|
|
# MODULE_SEARCH_DIRS:
|
|
|
|
# Extra directories to search first for MODULES before looking in the
|
2013-02-23 03:27:24 -04:00
|
|
|
# usual places.
|
|
|
|
#
|
2013-01-17 01:03:27 -04:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Paths and configuration
|
|
|
|
################################################################################
|
2013-01-06 01:46:50 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# Work out where this file is, so we can find other makefiles in the
|
|
|
|
# same directory.
|
|
|
|
#
|
2013-01-17 01:03:27 -04:00
|
|
|
# If PX4_BASE wasn't set previously, work out what it should be
|
|
|
|
# and set it here now.
|
2013-01-16 22:23:49 -04:00
|
|
|
#
|
2013-04-26 20:14:32 -03:00
|
|
|
MK_DIR ?= $(dir $(lastword $(MAKEFILE_LIST)))
|
2013-01-16 22:23:49 -04:00
|
|
|
ifeq ($(PX4_BASE),)
|
2013-02-21 01:25:04 -04:00
|
|
|
export PX4_BASE := $(abspath $(MK_DIR)/..)
|
2013-01-16 22:23:49 -04:00
|
|
|
endif
|
2013-02-23 19:11:57 -04:00
|
|
|
$(info % PX4_BASE = $(PX4_BASE))
|
2013-04-26 20:14:32 -03:00
|
|
|
ifneq ($(words $(PX4_BASE)),1)
|
|
|
|
$(error Cannot build when the PX4_BASE path contains one or more space characters.)
|
|
|
|
endif
|
2013-02-21 01:12:59 -04:00
|
|
|
|
2013-09-06 14:18:08 -03:00
|
|
|
$(info % GIT_DESC = $(GIT_DESC))
|
|
|
|
|
2013-02-23 03:27:24 -04:00
|
|
|
#
|
|
|
|
# Set a default target so that included makefiles or errors here don't
|
|
|
|
# cause confusion.
|
|
|
|
#
|
|
|
|
# XXX We could do something cute here with $(DEFAULT_GOAL) if it's not one
|
|
|
|
# of the maintenance targets and set CONFIG based on it.
|
|
|
|
#
|
|
|
|
all: firmware
|
|
|
|
|
2013-02-21 01:12:59 -04:00
|
|
|
#
|
|
|
|
# Get path and tool config
|
|
|
|
#
|
2013-02-21 01:25:04 -04:00
|
|
|
include $(MK_DIR)/setup.mk
|
2013-01-06 01:46:50 -04:00
|
|
|
|
|
|
|
#
|
2013-02-23 03:27:24 -04:00
|
|
|
# Locate the configuration file
|
2013-01-06 01:46:50 -04:00
|
|
|
#
|
2013-04-26 20:14:32 -03:00
|
|
|
ifneq ($(CONFIG_FILE),)
|
|
|
|
CONFIG := $(subst config_,,$(basename $(notdir $(CONFIG_FILE))))
|
|
|
|
else
|
|
|
|
CONFIG_FILE := $(wildcard $(PX4_MK_DIR)/config_$(CONFIG).mk)
|
|
|
|
endif
|
2013-02-23 03:27:24 -04:00
|
|
|
ifeq ($(CONFIG),)
|
|
|
|
$(error Missing configuration name or file (specify with CONFIG=<config>))
|
2013-01-17 01:03:27 -04:00
|
|
|
endif
|
2013-02-23 03:27:24 -04:00
|
|
|
export CONFIG
|
|
|
|
include $(CONFIG_FILE)
|
2013-02-23 19:11:57 -04:00
|
|
|
$(info % CONFIG = $(CONFIG))
|
2013-01-06 01:46:50 -04:00
|
|
|
|
|
|
|
#
|
2013-02-21 01:25:04 -04:00
|
|
|
# Sanity-check the BOARD variable and then get the board config.
|
2013-02-23 03:27:24 -04:00
|
|
|
# If BOARD was not set by the configuration, extract it automatically.
|
2013-01-17 01:03:27 -04:00
|
|
|
#
|
2013-02-21 01:25:04 -04:00
|
|
|
# The board config in turn will fetch the toolchain configuration.
|
2013-01-06 01:46:50 -04:00
|
|
|
#
|
2013-02-21 01:25:04 -04:00
|
|
|
ifeq ($(BOARD),)
|
2013-02-23 03:27:24 -04:00
|
|
|
BOARD := $(firstword $(subst _, ,$(CONFIG)))
|
2013-01-17 02:38:47 -04:00
|
|
|
endif
|
2013-02-23 03:27:24 -04:00
|
|
|
BOARD_FILE := $(wildcard $(PX4_MK_DIR)/board_$(BOARD).mk)
|
|
|
|
ifeq ($(BOARD_FILE),)
|
|
|
|
$(error Config $(CONFIG) references board $(BOARD), but no board definition file found)
|
2013-01-17 01:03:27 -04:00
|
|
|
endif
|
2013-02-23 03:27:24 -04:00
|
|
|
export BOARD
|
2013-08-13 04:34:11 -03:00
|
|
|
export BOARD_FILE
|
2013-02-23 03:27:24 -04:00
|
|
|
include $(BOARD_FILE)
|
2013-02-23 19:11:57 -04:00
|
|
|
$(info % BOARD = $(BOARD))
|
2013-02-23 03:27:24 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# If WORK_DIR is not set, create a 'build' directory next to the
|
|
|
|
# parent Makefile.
|
|
|
|
#
|
|
|
|
PARENT_MAKEFILE := $(lastword $(filter-out $(lastword $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
|
|
|
|
ifeq ($(WORK_DIR),)
|
2013-02-23 16:23:34 -04:00
|
|
|
export WORK_DIR := $(dir $(PARENT_MAKEFILE))build/
|
2013-02-23 03:27:24 -04:00
|
|
|
endif
|
2013-02-23 19:11:57 -04:00
|
|
|
$(info % WORK_DIR = $(WORK_DIR))
|
2013-01-06 01:46:50 -04:00
|
|
|
|
|
|
|
#
|
2013-02-21 01:12:59 -04:00
|
|
|
# Things that, if they change, might affect everything
|
2013-01-17 01:03:27 -04:00
|
|
|
#
|
2013-02-21 01:12:59 -04:00
|
|
|
GLOBAL_DEPS += $(MAKEFILE_LIST)
|
2013-01-17 01:03:27 -04:00
|
|
|
|
2013-03-21 03:22:48 -03:00
|
|
|
#
|
|
|
|
# Extra things we should clean
|
|
|
|
#
|
|
|
|
EXTRA_CLEANS =
|
|
|
|
|
2013-09-06 14:18:08 -03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Extra defines for compilation
|
|
|
|
#
|
|
|
|
export EXTRADEFINES := -DGIT_VERSION=$(GIT_DESC)
|
|
|
|
|
2013-08-03 02:34:55 -03:00
|
|
|
#
|
|
|
|
# Append the per-board driver directory to the header search path.
|
|
|
|
#
|
|
|
|
INCLUDE_DIRS += $(PX4_MODULE_SRC)drivers/boards/$(BOARD)
|
|
|
|
|
2013-06-07 02:49:49 -03:00
|
|
|
################################################################################
|
|
|
|
# NuttX libraries and paths
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
include $(PX4_MK_DIR)/nuttx.mk
|
|
|
|
|
2013-01-17 01:03:27 -04:00
|
|
|
################################################################################
|
2013-02-23 16:23:34 -04:00
|
|
|
# Modules
|
2013-01-17 01:03:27 -04:00
|
|
|
################################################################################
|
|
|
|
|
2013-02-23 16:23:34 -04:00
|
|
|
# where to look for modules
|
2013-05-09 02:50:18 -03:00
|
|
|
MODULE_SEARCH_DIRS += $(WORK_DIR) $(MODULE_SRC) $(PX4_MODULE_SRC)
|
2013-01-17 01:03:27 -04:00
|
|
|
|
2013-02-23 16:23:34 -04:00
|
|
|
# sort and unique the modules list
|
|
|
|
MODULES := $(sort $(MODULES))
|
2013-01-17 01:03:27 -04:00
|
|
|
|
2013-02-23 16:23:34 -04:00
|
|
|
# locate the first instance of a module by full path or by looking on the
|
|
|
|
# module search path
|
|
|
|
define MODULE_SEARCH
|
2013-05-14 02:20:08 -03:00
|
|
|
$(firstword $(abspath $(wildcard $(1)/module.mk)) \
|
|
|
|
$(abspath $(foreach search_dir,$(MODULE_SEARCH_DIRS),$(wildcard $(search_dir)/$(1)/module.mk))) \
|
|
|
|
MISSING_$1)
|
2013-02-23 03:27:24 -04:00
|
|
|
endef
|
2013-01-17 01:03:27 -04:00
|
|
|
|
2013-02-23 16:23:34 -04:00
|
|
|
# make a list of module makefiles and check that we found them all
|
|
|
|
MODULE_MKFILES := $(foreach module,$(MODULES),$(call MODULE_SEARCH,$(module)))
|
|
|
|
MISSING_MODULES := $(subst MISSING_,,$(filter MISSING_%,$(MODULE_MKFILES)))
|
|
|
|
ifneq ($(MISSING_MODULES),)
|
|
|
|
$(error Can't find module(s): $(MISSING_MODULES))
|
2013-02-23 03:27:24 -04:00
|
|
|
endif
|
|
|
|
|
2013-02-23 19:11:57 -04:00
|
|
|
# Make a list of the object files we expect to build from modules
|
|
|
|
# Note that this path will typically contain a double-slash at the WORK_DIR boundary; this must be
|
|
|
|
# preserved as it is used below to get the absolute path for the module.mk file correct.
|
|
|
|
#
|
2013-02-23 16:23:34 -04:00
|
|
|
MODULE_OBJS := $(foreach path,$(dir $(MODULE_MKFILES)),$(WORK_DIR)$(path)module.pre.o)
|
2013-02-23 03:27:24 -04:00
|
|
|
|
2013-02-23 16:23:34 -04:00
|
|
|
# rules to build module objects
|
|
|
|
.PHONY: $(MODULE_OBJS)
|
|
|
|
$(MODULE_OBJS): relpath = $(patsubst $(WORK_DIR)%,%,$@)
|
|
|
|
$(MODULE_OBJS): mkfile = $(patsubst %module.pre.o,%module.mk,$(relpath))
|
2013-05-11 15:32:05 -03:00
|
|
|
$(MODULE_OBJS): workdir = $(@D)
|
2013-02-23 16:23:34 -04:00
|
|
|
$(MODULE_OBJS): $(GLOBAL_DEPS) $(NUTTX_CONFIG_HEADER)
|
2013-05-11 15:32:05 -03:00
|
|
|
$(Q) $(MKDIR) -p $(workdir)
|
2013-04-26 20:14:32 -03:00
|
|
|
$(Q) $(MAKE) -r -f $(PX4_MK_DIR)module.mk \
|
2013-05-11 15:32:05 -03:00
|
|
|
-C $(workdir) \
|
|
|
|
MODULE_WORK_DIR=$(workdir) \
|
2013-02-23 16:23:34 -04:00
|
|
|
MODULE_OBJ=$@ \
|
|
|
|
MODULE_MK=$(mkfile) \
|
2013-05-11 15:32:05 -03:00
|
|
|
MODULE_NAME=$(lastword $(subst /, ,$(workdir))) \
|
2013-02-23 16:23:34 -04:00
|
|
|
module
|
|
|
|
|
|
|
|
# make a list of phony clean targets for modules
|
|
|
|
MODULE_CLEANS := $(foreach path,$(dir $(MODULE_MKFILES)),$(WORK_DIR)$(path)/clean)
|
|
|
|
|
|
|
|
# rules to clean modules
|
|
|
|
.PHONY: $(MODULE_CLEANS)
|
|
|
|
$(MODULE_CLEANS): relpath = $(patsubst $(WORK_DIR)%,%,$@)
|
|
|
|
$(MODULE_CLEANS): mkfile = $(patsubst %clean,%module.mk,$(relpath))
|
|
|
|
$(MODULE_CLEANS):
|
2013-02-23 18:33:53 -04:00
|
|
|
@$(ECHO) %% cleaning using $(mkfile)
|
2013-04-26 20:14:32 -03:00
|
|
|
$(Q) $(MAKE) -r -f $(PX4_MK_DIR)module.mk \
|
2013-02-23 16:23:34 -04:00
|
|
|
MODULE_WORK_DIR=$(dir $@) \
|
|
|
|
MODULE_MK=$(mkfile) \
|
2013-02-23 03:27:24 -04:00
|
|
|
clean
|
2013-01-17 01:03:27 -04:00
|
|
|
|
2013-05-19 19:26:41 -03:00
|
|
|
################################################################################
|
|
|
|
# Libraries
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# where to look for libraries
|
|
|
|
LIBRARY_SEARCH_DIRS += $(WORK_DIR) $(MODULE_SRC) $(PX4_MODULE_SRC)
|
|
|
|
|
|
|
|
# sort and unique the library list
|
|
|
|
LIBRARIES := $(sort $(LIBRARIES))
|
|
|
|
|
|
|
|
# locate the first instance of a library by full path or by looking on the
|
|
|
|
# library search path
|
|
|
|
define LIBRARY_SEARCH
|
|
|
|
$(firstword $(abspath $(wildcard $(1)/library.mk)) \
|
|
|
|
$(abspath $(foreach search_dir,$(LIBRARY_SEARCH_DIRS),$(wildcard $(search_dir)/$(1)/library.mk))) \
|
|
|
|
MISSING_$1)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# make a list of library makefiles and check that we found them all
|
|
|
|
LIBRARY_MKFILES := $(foreach library,$(LIBRARIES),$(call LIBRARY_SEARCH,$(library)))
|
|
|
|
MISSING_LIBRARIES := $(subst MISSING_,,$(filter MISSING_%,$(LIBRARY_MKFILES)))
|
|
|
|
ifneq ($(MISSING_LIBRARIES),)
|
|
|
|
$(error Can't find library(s): $(MISSING_LIBRARIES))
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Make a list of the archive files we expect to build from libraries
|
|
|
|
# Note that this path will typically contain a double-slash at the WORK_DIR boundary; this must be
|
|
|
|
# preserved as it is used below to get the absolute path for the library.mk file correct.
|
|
|
|
#
|
|
|
|
LIBRARY_LIBS := $(foreach path,$(dir $(LIBRARY_MKFILES)),$(WORK_DIR)$(path)library.a)
|
|
|
|
|
|
|
|
# rules to build module objects
|
|
|
|
.PHONY: $(LIBRARY_LIBS)
|
|
|
|
$(LIBRARY_LIBS): relpath = $(patsubst $(WORK_DIR)%,%,$@)
|
|
|
|
$(LIBRARY_LIBS): mkfile = $(patsubst %library.a,%library.mk,$(relpath))
|
|
|
|
$(LIBRARY_LIBS): workdir = $(@D)
|
|
|
|
$(LIBRARY_LIBS): $(GLOBAL_DEPS) $(NUTTX_CONFIG_HEADER)
|
|
|
|
$(Q) $(MKDIR) -p $(workdir)
|
|
|
|
$(Q) $(MAKE) -r -f $(PX4_MK_DIR)library.mk \
|
|
|
|
-C $(workdir) \
|
|
|
|
LIBRARY_WORK_DIR=$(workdir) \
|
|
|
|
LIBRARY_LIB=$@ \
|
|
|
|
LIBRARY_MK=$(mkfile) \
|
|
|
|
LIBRARY_NAME=$(lastword $(subst /, ,$(workdir))) \
|
|
|
|
library
|
|
|
|
|
|
|
|
# make a list of phony clean targets for modules
|
|
|
|
LIBRARY_CLEANS := $(foreach path,$(dir $(LIBRARY_MKFILES)),$(WORK_DIR)$(path)/clean)
|
|
|
|
|
|
|
|
# rules to clean modules
|
|
|
|
.PHONY: $(LIBRARY_CLEANS)
|
|
|
|
$(LIBRARY_CLEANS): relpath = $(patsubst $(WORK_DIR)%,%,$@)
|
|
|
|
$(LIBRARY_CLEANS): mkfile = $(patsubst %clean,%library.mk,$(relpath))
|
|
|
|
$(LIBRARY_CLEANS):
|
|
|
|
@$(ECHO) %% cleaning using $(mkfile)
|
|
|
|
$(Q) $(MAKE) -r -f $(PX4_MK_DIR)library.mk \
|
|
|
|
LIBRARY_WORK_DIR=$(dir $@) \
|
|
|
|
LIBRARY_MK=$(mkfile) \
|
|
|
|
clean
|
|
|
|
|
2013-01-17 03:40:40 -04:00
|
|
|
################################################################################
|
|
|
|
# ROMFS generation
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
ifneq ($(ROMFS_ROOT),)
|
2013-04-26 20:14:32 -03:00
|
|
|
ifeq ($(wildcard $(ROMFS_ROOT)),)
|
|
|
|
$(error ROMFS_ROOT specifies a directory that does not exist)
|
|
|
|
endif
|
2013-02-23 18:33:53 -04:00
|
|
|
|
2013-03-21 03:05:19 -03:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2013-08-23 03:47:55 -03:00
|
|
|
# Add dependencies on anything in the ROMFS root directory
|
2013-05-12 14:51:25 -03:00
|
|
|
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)
|
2013-08-23 03:47:55 -03:00
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
2013-05-12 18:04:57 -03:00
|
|
|
ROMFS_IMG = romfs.img
|
2013-08-23 03:47:55 -03:00
|
|
|
ROMFS_SCRATCH = romfs_scratch
|
2013-01-17 03:40:40 -04:00
|
|
|
ROMFS_CSRC = $(ROMFS_IMG:.img=.c)
|
|
|
|
ROMFS_OBJ = $(ROMFS_CSRC:.c=.o)
|
|
|
|
LIBS += $(ROMFS_OBJ)
|
|
|
|
LINK_DEPS += $(ROMFS_OBJ)
|
2013-02-21 01:12:59 -04:00
|
|
|
|
2014-02-16 19:25:30 -04:00
|
|
|
# Remove all comments from startup and mixer files
|
|
|
|
ROMFS_PRUNER = $(PX4_BASE)/Tools/px_romfs_pruner.py
|
|
|
|
|
2013-02-23 18:33:53 -04:00
|
|
|
# Turn the ROMFS image into an object file
|
|
|
|
$(ROMFS_OBJ): $(ROMFS_IMG) $(GLOBAL_DEPS)
|
|
|
|
$(call BIN_TO_OBJ,$<,$@,romfs_img)
|
2013-02-21 01:12:59 -04:00
|
|
|
|
2013-02-23 18:33:53 -04:00
|
|
|
# Generate the ROMFS image from the root
|
2013-08-23 03:47:55 -03:00
|
|
|
$(ROMFS_IMG): $(ROMFS_SCRATCH) $(ROMFS_DEPS) $(GLOBAL_DEPS)
|
2013-04-26 20:14:32 -03:00
|
|
|
@$(ECHO) "ROMFS: $@"
|
2013-08-23 03:47:55 -03:00
|
|
|
$(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)
|
|
|
|
ifneq ($(ROMFS_EXTRA_FILES),)
|
|
|
|
$(Q) $(MKDIR) -p $(ROMFS_SCRATCH)/extras
|
|
|
|
$(Q) $(COPY) $(ROMFS_EXTRA_FILES) $(ROMFS_SCRATCH)/extras
|
|
|
|
endif
|
2014-02-16 19:25:30 -04:00
|
|
|
$(Q) $(PYTHON) -u $(ROMFS_PRUNER) --folder $(ROMFS_SCRATCH)
|
2013-02-21 01:12:59 -04:00
|
|
|
|
2013-03-21 03:22:48 -03:00
|
|
|
EXTRA_CLEANS += $(ROMGS_OBJ) $(ROMFS_IMG)
|
|
|
|
|
2013-01-17 03:40:40 -04:00
|
|
|
endif
|
|
|
|
|
2013-01-17 01:03:27 -04:00
|
|
|
################################################################################
|
2013-02-21 01:12:59 -04:00
|
|
|
# Builtin command list generation
|
2013-01-17 01:03:27 -04:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
#
|
2013-02-21 02:07:18 -04:00
|
|
|
# Builtin commands can be generated by the configuration, in which case they
|
2013-02-23 16:23:34 -04:00
|
|
|
# must refer to commands that already exist, or indirectly generated by modules
|
2013-02-21 02:07:18 -04:00
|
|
|
# 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.
|
|
|
|
#
|
2013-02-23 16:23:34 -04:00
|
|
|
BUILTIN_CSRC = $(WORK_DIR)builtin_commands.c
|
2013-02-21 01:12:59 -04:00
|
|
|
|
2013-04-26 20:14:32 -03:00
|
|
|
# command definitions from modules (may be empty at Makefile parsing time...)
|
|
|
|
MODULE_COMMANDS = $(subst COMMAND.,,$(notdir $(wildcard $(WORK_DIR)builtin_commands/COMMAND.*)))
|
2013-02-21 02:07:18 -04:00
|
|
|
|
2013-04-26 20:14:32 -03:00
|
|
|
# We must have at least one pre-defined builtin command in order to generate
|
|
|
|
# any of this.
|
|
|
|
#
|
2013-02-23 18:43:12 -04:00
|
|
|
ifneq ($(BUILTIN_COMMANDS),)
|
|
|
|
|
2013-02-21 02:07:18 -04:00
|
|
|
# (BUILTIN_PROTO,<cmdspec>,<outputfile>)
|
|
|
|
define BUILTIN_PROTO
|
2013-02-23 18:33:53 -04:00
|
|
|
$(ECHO) 'extern int $(word 4,$1)(int argc, char *argv[]);' >> $2;
|
2013-02-21 02:07:18 -04:00
|
|
|
endef
|
|
|
|
|
|
|
|
# (BUILTIN_DEF,<cmdspec>,<outputfile>)
|
|
|
|
define BUILTIN_DEF
|
2013-02-23 18:33:53 -04:00
|
|
|
$(ECHO) ' {"$(word 1,$1)", $(word 2,$1), $(word 3,$1), $(word 4,$1)},' >> $2;
|
2013-02-21 02:07:18 -04:00
|
|
|
endef
|
|
|
|
|
2013-02-23 19:11:57 -04:00
|
|
|
# Don't generate until modules have updated their command files
|
2013-07-12 03:23:58 -03:00
|
|
|
$(BUILTIN_CSRC): $(GLOBAL_DEPS) $(MODULE_OBJS) $(MODULE_MKFILES) $(BUILTIN_COMMAND_FILES)
|
2013-04-26 20:14:32 -03:00
|
|
|
@$(ECHO) "CMDS: $@"
|
2013-02-23 18:33:53 -04:00
|
|
|
$(Q) $(ECHO) '/* builtin command list - automatically generated, do not edit */' > $@
|
|
|
|
$(Q) $(ECHO) '#include <nuttx/config.h>' >> $@
|
|
|
|
$(Q) $(ECHO) '#include <nuttx/binfmt/builtin.h>' >> $@
|
2013-02-21 02:07:18 -04:00
|
|
|
$(Q) $(foreach spec,$(BUILTIN_COMMANDS),$(call BUILTIN_PROTO,$(subst ., ,$(spec)),$@))
|
2013-04-26 20:14:32 -03:00
|
|
|
$(Q) $(foreach spec,$(MODULE_COMMANDS),$(call BUILTIN_PROTO,$(subst ., ,$(spec)),$@))
|
2013-02-23 18:33:53 -04:00
|
|
|
$(Q) $(ECHO) 'const struct builtin_s g_builtins[] = {' >> $@
|
2013-02-21 02:07:18 -04:00
|
|
|
$(Q) $(foreach spec,$(BUILTIN_COMMANDS),$(call BUILTIN_DEF,$(subst ., ,$(spec)),$@))
|
2013-04-26 20:14:32 -03:00
|
|
|
$(Q) $(foreach spec,$(MODULE_COMMANDS),$(call BUILTIN_DEF,$(subst ., ,$(spec)),$@))
|
2013-02-23 18:33:53 -04:00
|
|
|
$(Q) $(ECHO) ' {NULL, 0, 0, NULL}' >> $@
|
|
|
|
$(Q) $(ECHO) '};' >> $@
|
2013-04-26 20:14:32 -03:00
|
|
|
$(Q) $(ECHO) 'const int g_builtin_count = $(words $(BUILTIN_COMMANDS) $(MODULE_COMMANDS));' >> $@
|
2013-02-21 01:12:59 -04:00
|
|
|
|
2013-02-23 18:43:12 -04:00
|
|
|
SRCS += $(BUILTIN_CSRC)
|
2013-02-21 01:12:59 -04:00
|
|
|
|
2013-03-21 03:22:48 -03:00
|
|
|
EXTRA_CLEANS += $(BUILTIN_CSRC)
|
|
|
|
|
2013-02-23 18:43:12 -04:00
|
|
|
endif
|
2013-02-21 01:12:59 -04:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Default SRCS generation
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# If there are no SRCS, the build will fail; in that case, generate an empty
|
|
|
|
# source file.
|
|
|
|
#
|
|
|
|
ifeq ($(SRCS),)
|
2013-02-23 16:23:34 -04:00
|
|
|
EMPTY_SRC = $(WORK_DIR)empty.c
|
2013-02-21 01:12:59 -04:00
|
|
|
$(EMPTY_SRC):
|
2013-02-23 18:33:53 -04:00
|
|
|
$(Q) $(ECHO) '/* this is an empty file */' > $@
|
2013-02-21 01:12:59 -04:00
|
|
|
|
|
|
|
SRCS += $(EMPTY_SRC)
|
|
|
|
endif
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Build rules
|
|
|
|
################################################################################
|
2013-01-17 01:03:27 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# What we're going to build.
|
2013-01-06 01:46:50 -04:00
|
|
|
#
|
2013-02-23 16:23:34 -04:00
|
|
|
PRODUCT_BUNDLE = $(WORK_DIR)firmware.px4
|
|
|
|
PRODUCT_BIN = $(WORK_DIR)firmware.bin
|
2013-04-26 20:14:32 -03:00
|
|
|
PRODUCT_ELF = $(WORK_DIR)firmware.elf
|
2013-01-06 01:46:50 -04:00
|
|
|
|
2013-02-23 03:27:24 -04:00
|
|
|
.PHONY: firmware
|
2013-02-21 01:12:59 -04:00
|
|
|
firmware: $(PRODUCT_BUNDLE)
|
2013-01-06 01:46:50 -04:00
|
|
|
|
|
|
|
#
|
2013-01-17 01:03:27 -04:00
|
|
|
# Object files we will generate from sources
|
2013-01-06 01:46:50 -04:00
|
|
|
#
|
2013-02-23 16:23:34 -04:00
|
|
|
OBJS := $(foreach src,$(SRCS),$(WORK_DIR)$(src).o)
|
2013-01-06 01:46:50 -04:00
|
|
|
|
2013-01-17 01:03:27 -04:00
|
|
|
#
|
2013-01-17 03:40:40 -04:00
|
|
|
# SRCS -> OBJS rules
|
2013-01-17 01:03:27 -04:00
|
|
|
#
|
|
|
|
|
2013-02-21 01:12:59 -04:00
|
|
|
$(OBJS): $(GLOBAL_DEPS)
|
|
|
|
|
2013-02-23 16:23:34 -04:00
|
|
|
$(filter %.c.o,$(OBJS)): $(WORK_DIR)%.c.o: %.c $(GLOBAL_DEPS)
|
2013-01-06 01:46:50 -04:00
|
|
|
$(call COMPILE,$<,$@)
|
|
|
|
|
2013-02-23 16:23:34 -04:00
|
|
|
$(filter %.cpp.o,$(OBJS)): $(WORK_DIR)%.cpp.o: %.cpp $(GLOBAL_DEPS)
|
2013-01-06 01:46:50 -04:00
|
|
|
$(call COMPILEXX,$<,$@)
|
|
|
|
|
2013-02-23 16:23:34 -04:00
|
|
|
$(filter %.S.o,$(OBJS)): $(WORK_DIR)%.S.o: %.S $(GLOBAL_DEPS)
|
2013-01-06 01:46:50 -04:00
|
|
|
$(call ASSEMBLE,$<,$@)
|
|
|
|
|
2013-01-17 03:40:40 -04:00
|
|
|
#
|
|
|
|
# Built product rules
|
|
|
|
#
|
|
|
|
|
2013-01-17 01:03:27 -04:00
|
|
|
$(PRODUCT_BUNDLE): $(PRODUCT_BIN)
|
2013-02-23 18:33:53 -04:00
|
|
|
@$(ECHO) %% Generating $@
|
2013-02-21 01:25:04 -04:00
|
|
|
$(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \
|
2013-01-17 01:03:27 -04:00
|
|
|
--git_identity $(PX4_BASE) \
|
|
|
|
--image $< > $@
|
2013-01-06 01:46:50 -04:00
|
|
|
|
2013-04-26 20:14:32 -03:00
|
|
|
$(PRODUCT_BIN): $(PRODUCT_ELF)
|
2013-01-06 01:46:50 -04:00
|
|
|
$(call SYM_TO_BIN,$<,$@)
|
|
|
|
|
2013-05-19 19:26:41 -03:00
|
|
|
$(PRODUCT_ELF): $(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS) $(GLOBAL_DEPS) $(LINK_DEPS) $(MODULE_MKFILES)
|
|
|
|
$(call LINK,$@,$(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS))
|
2013-01-06 01:46:50 -04:00
|
|
|
|
2013-01-17 03:40:40 -04:00
|
|
|
#
|
|
|
|
# Utility rules
|
|
|
|
#
|
|
|
|
|
2013-02-23 03:27:24 -04:00
|
|
|
.PHONY: upload
|
2013-01-17 01:12:15 -04:00
|
|
|
upload: $(PRODUCT_BUNDLE) $(PRODUCT_BIN)
|
2013-02-23 18:33:53 -04:00
|
|
|
$(Q) $(MAKE) -f $(PX4_MK_DIR)/upload.mk \
|
2013-01-17 01:12:15 -04:00
|
|
|
METHOD=serial \
|
2013-04-26 20:14:32 -03:00
|
|
|
CONFIG=$(CONFIG) \
|
|
|
|
BOARD=$(BOARD) \
|
2013-01-17 01:12:15 -04:00
|
|
|
BUNDLE=$(PRODUCT_BUNDLE) \
|
|
|
|
BIN=$(PRODUCT_BIN)
|
2013-01-17 01:03:27 -04:00
|
|
|
|
2013-02-23 03:27:24 -04:00
|
|
|
.PHONY: clean
|
2013-02-23 16:23:34 -04:00
|
|
|
clean: $(MODULE_CLEANS)
|
2013-02-23 18:33:53 -04:00
|
|
|
@$(ECHO) %% cleaning
|
2013-04-26 20:14:32 -03:00
|
|
|
$(Q) $(REMOVE) $(PRODUCT_BUNDLE) $(PRODUCT_BIN) $(PRODUCT_ELF)
|
2013-03-21 03:22:48 -03:00
|
|
|
$(Q) $(REMOVE) $(OBJS) $(DEP_INCLUDES) $(EXTRA_CLEANS)
|
2013-01-17 01:03:27 -04:00
|
|
|
$(Q) $(RMDIR) $(NUTTX_EXPORT_DIR)
|
|
|
|
|
2013-04-26 20:14:32 -03:00
|
|
|
|
2013-01-17 01:03:27 -04:00
|
|
|
#
|
|
|
|
# DEP_INCLUDES is defined by the toolchain include in terms of $(OBJS)
|
|
|
|
#
|
|
|
|
-include $(DEP_INCLUDES)
|