forked from Archive/PX4-Autopilot
APP -> MODULE
remove as many duplicate slashes, etc. as seems practical
This commit is contained in:
parent
8d7621079a
commit
d24599931a
36
Makefile
36
Makefile
|
@ -5,8 +5,8 @@
|
||||||
#
|
#
|
||||||
# Get path and tool configuration
|
# Get path and tool configuration
|
||||||
#
|
#
|
||||||
export PX4_BASE := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
|
export PX4_BASE := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))/
|
||||||
include $(PX4_BASE)/makefiles/setup.mk
|
include $(PX4_BASE)makefiles/setup.mk
|
||||||
|
|
||||||
#
|
#
|
||||||
# Canned firmware configurations that we build.
|
# Canned firmware configurations that we build.
|
||||||
|
@ -41,15 +41,15 @@ endif
|
||||||
#
|
#
|
||||||
# Built products
|
# Built products
|
||||||
#
|
#
|
||||||
STAGED_FIRMWARES = $(foreach config,$(CONFIGS),$(IMAGE_DIR)/$(config).px4)
|
STAGED_FIRMWARES = $(foreach config,$(CONFIGS),$(IMAGE_DIR)$(config).px4)
|
||||||
FIRMWARES = $(foreach config,$(CONFIGS),$(BUILD_DIR)/$(config).build/firmware.px4)
|
FIRMWARES = $(foreach config,$(CONFIGS),$(BUILD_DIR)$(config).build/firmware.px4)
|
||||||
|
|
||||||
all: $(STAGED_FIRMWARES)
|
all: $(STAGED_FIRMWARES)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copy FIRMWARES into the image directory.
|
# Copy FIRMWARES into the image directory.
|
||||||
#
|
#
|
||||||
$(STAGED_FIRMWARES): $(IMAGE_DIR)/%.px4: $(BUILD_DIR)/%.build/firmware.px4
|
$(STAGED_FIRMWARES): $(IMAGE_DIR)%.px4: $(BUILD_DIR)%.build/firmware.px4
|
||||||
@echo %% Copying $@
|
@echo %% Copying $@
|
||||||
$(Q) $(COPY) $< $@
|
$(Q) $(COPY) $< $@
|
||||||
|
|
||||||
|
@ -57,15 +57,15 @@ $(STAGED_FIRMWARES): $(IMAGE_DIR)/%.px4: $(BUILD_DIR)/%.build/firmware.px4
|
||||||
# Generate FIRMWARES.
|
# Generate FIRMWARES.
|
||||||
#
|
#
|
||||||
.PHONY: $(FIRMWARES)
|
.PHONY: $(FIRMWARES)
|
||||||
$(BUILD_DIR)/%.build/firmware.px4: config = $(patsubst $(BUILD_DIR)/%.build/firmware.px4,%,$@)
|
$(BUILD_DIR)%.build/firmware.px4: config = $(patsubst $(BUILD_DIR)%.build/firmware.px4,%,$@)
|
||||||
$(BUILD_DIR)/%.build/firmware.px4: work_dir = $(BUILD_DIR)/$(config).build
|
$(BUILD_DIR)%.build/firmware.px4: work_dir = $(BUILD_DIR)$(config).build/
|
||||||
$(FIRMWARES): $(BUILD_DIR)/%.build/firmware.px4:
|
$(FIRMWARES): $(BUILD_DIR)%.build/firmware.px4:
|
||||||
@echo %%%%
|
@echo %%%%
|
||||||
@echo %%%% Building $(config) in $(work_dir)
|
@echo %%%% Building $(config) in $(work_dir)
|
||||||
@echo %%%%
|
@echo %%%%
|
||||||
$(Q) mkdir -p $(work_dir)
|
$(Q) mkdir -p $(work_dir)
|
||||||
$(Q) make -C $(work_dir) \
|
$(Q) make -C $(work_dir) \
|
||||||
-f $(PX4_MK_DIR)/firmware.mk \
|
-f $(PX4_MK_DIR)firmware.mk \
|
||||||
CONFIG=$(config) \
|
CONFIG=$(config) \
|
||||||
WORK_DIR=$(work_dir) \
|
WORK_DIR=$(work_dir) \
|
||||||
firmware
|
firmware
|
||||||
|
@ -83,21 +83,21 @@ $(FIRMWARES): $(BUILD_DIR)/%.build/firmware.px4:
|
||||||
#
|
#
|
||||||
# XXX PX4IO configuration name is bad - NuttX configs should probably all be "px4"
|
# XXX PX4IO configuration name is bad - NuttX configs should probably all be "px4"
|
||||||
#
|
#
|
||||||
NUTTX_ARCHIVES = $(foreach board,$(BOARDS),$(ARCHIVE_DIR)/$(board).export)
|
NUTTX_ARCHIVES = $(foreach board,$(BOARDS),$(ARCHIVE_DIR)$(board).export)
|
||||||
.PHONY: archives
|
.PHONY: archives
|
||||||
archives: $(NUTTX_ARCHIVES)
|
archives: $(NUTTX_ARCHIVES)
|
||||||
|
|
||||||
$(ARCHIVE_DIR)/%.export: board = $(notdir $(basename $@))
|
$(ARCHIVE_DIR)%.export: board = $(notdir $(basename $@))
|
||||||
$(ARCHIVE_DIR)/%.export: configuration = $(if $(filter $(board),px4io),io,nsh)
|
$(ARCHIVE_DIR)%.export: configuration = $(if $(filter $(board),px4io),io,nsh)
|
||||||
$(NUTTX_ARCHIVES): $(ARCHIVE_DIR)/%.export: $(NUTTX_SRC) $(NUTTX_APPS)
|
$(NUTTX_ARCHIVES): $(ARCHIVE_DIR)%.export: $(NUTTX_SRC) $(NUTTX_APPS)
|
||||||
@echo %% Configuring NuttX for $(board)
|
@echo %% Configuring NuttX for $(board)
|
||||||
$(Q) (cd $(NUTTX_SRC) && $(RMDIR) nuttx-export)
|
$(Q) (cd $(NUTTX_SRC) && $(RMDIR) nuttx-export)
|
||||||
$(Q) make -C $(NUTTX_SRC) -r $(MQUIET) distclean
|
$(Q) make -C $(NUTTX_SRC) -r $(MQUIET) distclean
|
||||||
$(Q) (cd $(NUTTX_SRC)/tools && ./configure.sh $(board)/$(configuration))
|
$(Q) (cd $(NUTTX_SRC)tools && ./configure.sh $(board)/$(configuration))
|
||||||
@echo %% Exporting NuttX for $(board)
|
@echo %% Exporting NuttX for $(board)
|
||||||
$(Q) make -C $(NUTTX_SRC) -r $(MQUIET) export
|
$(Q) make -C $(NUTTX_SRC) -r $(MQUIET) export
|
||||||
$(Q) mkdir -p $(dir $@)
|
$(Q) mkdir -p $(dir $@)
|
||||||
$(Q) $(COPY) $(NUTTX_SRC)/nuttx-export.zip $@
|
$(Q) $(COPY) $(NUTTX_SRC)nuttx-export.zip $@
|
||||||
|
|
||||||
#
|
#
|
||||||
# Cleanup targets. 'clean' should remove all built products and force
|
# Cleanup targets. 'clean' should remove all built products and force
|
||||||
|
@ -106,11 +106,11 @@ $(NUTTX_ARCHIVES): $(ARCHIVE_DIR)/%.export: $(NUTTX_SRC) $(NUTTX_APPS)
|
||||||
#
|
#
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
$(Q) $(RMDIR) $(BUILD_DIR)/*.build
|
$(Q) $(RMDIR) $(BUILD_DIR)*.build
|
||||||
$(Q) $(REMOVE) -f $(IMAGE_DIR)/*.px4
|
$(Q) $(REMOVE) -f $(IMAGE_DIR)*.px4
|
||||||
|
|
||||||
.PHONY: distclean
|
.PHONY: distclean
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(Q) $(REMOVE) -f $(ARCHIVE_DIR)/*.export
|
$(Q) $(REMOVE) -f $(ARCHIVE_DIR)*.export
|
||||||
$(Q) make -C $(NUTTX_SRC) -r $(MQUIET) distclean
|
$(Q) make -C $(NUTTX_SRC) -r $(MQUIET) distclean
|
||||||
|
|
||||||
|
|
|
@ -1,162 +0,0 @@
|
||||||
#
|
|
||||||
# Framework makefile for PX4 applications
|
|
||||||
#
|
|
||||||
# This makefile is invoked by firmware.mk to build each of the applications
|
|
||||||
# that will subsequently be linked into the firmware image.
|
|
||||||
#
|
|
||||||
# Applications are built as prelinked objects with a limited set of exported
|
|
||||||
# symbols, as the global namespace is shared between all apps. Normally an
|
|
||||||
# application will just export one or more <command>_main functions.
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# Variables that can be set by the application's app.mk:
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# SRCS (required)
|
|
||||||
# Lists the .c, cpp and .S files that should be compiled/assembled to
|
|
||||||
# produce the application.
|
|
||||||
#
|
|
||||||
# APP_NAME (optional)
|
|
||||||
# APP_ENTRYPOINT (optional if APP_NAME is set)
|
|
||||||
# APP_STACKSIZE (optional if APP_NAME is set)
|
|
||||||
# APP_PRIORITY (optional if APP_NAME is set)
|
|
||||||
# Defines a single builtin command exported by the application.
|
|
||||||
# APP_NAME must be unique for any configuration, but need not be the
|
|
||||||
# same as the app directory name.
|
|
||||||
#
|
|
||||||
# If APP_ENTRYPOINT is set, it names the function (which must be exported)
|
|
||||||
# that will be the entrypoint for the builtin command. It defaults to
|
|
||||||
# $(APP_NAME)_main.
|
|
||||||
#
|
|
||||||
# If APP_STACKSIZE is set, it is the size in bytes of the stack to be
|
|
||||||
# allocated for the builtin command. If it is not set, it defaults
|
|
||||||
# to CONFIG_PTHREAD_STACK_DEFAULT.
|
|
||||||
#
|
|
||||||
# If APP_PRIORITY is set, it is the thread priority for the builtin
|
|
||||||
# command. If it is not set, it defaults to SCHED_PRIORITY_DEFAULT.
|
|
||||||
#
|
|
||||||
# APP_COMMANDS (optional)
|
|
||||||
# Defines builtin commands exported by the application. Each word in
|
|
||||||
# the list should be formatted as:
|
|
||||||
# <command>.<priority>.<stacksize>.<entrypoint>
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# Variables visible to the application's app.mk:
|
|
||||||
#
|
|
||||||
# CONFIG
|
|
||||||
# BOARD
|
|
||||||
# APP_WORK_DIR
|
|
||||||
# Anything set in setup.mk, board_$(BOARD).mk and the toolchain file.
|
|
||||||
# Anything exported from config_$(CONFIG).mk
|
|
||||||
#
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# No user-serviceable parts below.
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
ifeq ($(APP_MK),)
|
|
||||||
$(error No application makefile specified)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#
|
|
||||||
# Get path and tool config
|
|
||||||
#
|
|
||||||
include $(PX4_BASE)/makefiles/setup.mk
|
|
||||||
|
|
||||||
#
|
|
||||||
# Get the board/toolchain config
|
|
||||||
#
|
|
||||||
include $(PX4_MK_DIR)/board_$(BOARD).mk
|
|
||||||
|
|
||||||
#
|
|
||||||
# Get the application's config
|
|
||||||
#
|
|
||||||
include $(APP_MK)
|
|
||||||
APP_SRC_DIR := $(dir $(APP_MK))
|
|
||||||
|
|
||||||
#
|
|
||||||
# Things that, if they change, might affect everything
|
|
||||||
#
|
|
||||||
GLOBAL_DEPS += $(MAKEFILE_LIST)
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Builtin command definitions
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
ifneq ($(APP_NAME),)
|
|
||||||
APP_ENTRYPOINT ?= $(APP_NAME)_main
|
|
||||||
APP_STACKSIZE ?= CONFIG_PTHREAD_STACK_DEFAULT
|
|
||||||
APP_PRIORITY ?= SCHED_PRIORITY_DEFAULT
|
|
||||||
APP_COMMANDS += $(APP_NAME).$(APP_PRIORITY).$(APP_STACKSIZE).$(APP_ENTRYPOINT)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(APP_COMMANDS),)
|
|
||||||
APP_COMMAND_FILES := $(addprefix $(WORK_DIR)/builtin_commands/COMMAND.,$(APP_COMMANDS))
|
|
||||||
|
|
||||||
.PHONY: $(APP_COMMAND_FILES)
|
|
||||||
$(APP_COMMAND_FILES): $(GLOBAL_DEPS)
|
|
||||||
@echo %% registering: $(word 2,$(subst ., ,$(notdir $(@))))
|
|
||||||
@mkdir -p $@
|
|
||||||
$(Q) touch $@
|
|
||||||
endif
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Build rules
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
#
|
|
||||||
# What we're going to build
|
|
||||||
#
|
|
||||||
app: $(APP_OBJ) $(APP_COMMAND_FILES)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Locate sources (allows relative source paths in app.mk)
|
|
||||||
#
|
|
||||||
define SRC_SEARCH
|
|
||||||
$(firstword $(wildcard $(APP_SRC_DIR)/$1) MISSING_$1)
|
|
||||||
endef
|
|
||||||
|
|
||||||
ABS_SRCS := $(foreach src,$(SRCS),$(call SRC_SEARCH,$(src)))
|
|
||||||
MISSING_SRCS := $(subst MISSING_,,$(filter MISSING_%,$(ABS_SRCS)))
|
|
||||||
ifneq ($(MISSING_SRCS),)
|
|
||||||
$(error $(APP_MK): missing in SRCS: $(MISSING_SRCS))
|
|
||||||
endif
|
|
||||||
ifeq ($(ABS_SRCS),)
|
|
||||||
$(error $(APP_MK): nothing to compile in SRCS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#
|
|
||||||
# Object files we will generate from sources
|
|
||||||
#
|
|
||||||
OBJS := $(foreach src,$(ABS_SRCS),$(APP_WORK_DIR)/$(src).o)
|
|
||||||
|
|
||||||
#
|
|
||||||
# SRCS -> OBJS rules
|
|
||||||
#
|
|
||||||
|
|
||||||
$(OBJS): $(GLOBAL_DEPS)
|
|
||||||
|
|
||||||
$(filter %.c.o,$(OBJS)): $(APP_WORK_DIR)/%.c.o: %.c
|
|
||||||
$(call COMPILE,$<,$@)
|
|
||||||
|
|
||||||
$(filter %.cpp.o,$(OBJS)): $(APP_WORK_DIR)/%.cpp.o: %.cpp $(GLOBAL_DEPS)
|
|
||||||
$(call COMPILEXX,$<,$@)
|
|
||||||
|
|
||||||
$(filter %.S.o,$(OBJS)): $(APP_WORK_DIR)/%.S.o: %.S $(GLOBAL_DEPS)
|
|
||||||
$(call ASSEMBLE,$<,$@)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Built product rules
|
|
||||||
#
|
|
||||||
|
|
||||||
$(APP_OBJ): $(OBJS) $(GLOBAL_DEPS)
|
|
||||||
$(call PRELINK,$@,$(OBJS))
|
|
||||||
|
|
||||||
#
|
|
||||||
# Utility rules
|
|
||||||
#
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(Q) $(REMOVE) $(APP_PRELINK) $(OBJS)
|
|
|
@ -15,6 +15,6 @@ ROMFS_ROOT = $(PX4_BASE)/ROMFS/$(CONFIG)
|
||||||
BUILTIN_COMMANDS = perf.SCHED_PRIORITY_DEFAULT.CONFIG_PTHREAD_STACK_DEFAULT.perf_main
|
BUILTIN_COMMANDS = perf.SCHED_PRIORITY_DEFAULT.CONFIG_PTHREAD_STACK_DEFAULT.perf_main
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build the test app
|
# Build the test module
|
||||||
#
|
#
|
||||||
APPS = test
|
MODULES = test
|
||||||
|
|
|
@ -9,37 +9,23 @@
|
||||||
#
|
#
|
||||||
# Optional:
|
# Optional:
|
||||||
#
|
#
|
||||||
# APPS
|
# MODULES
|
||||||
# Contains a list of application paths or path fragments used
|
# Contains a list of module paths or path fragments used
|
||||||
# to find applications. The names listed here are searched in
|
# to find modules. The names listed here are searched in
|
||||||
# the following directories:
|
# the following directories:
|
||||||
# <absolute path>
|
# <absolute path>
|
||||||
# $(APP_SEARCH_DIRS)
|
# $(MODULE_SEARCH_DIRS)
|
||||||
# WORK_DIR
|
# WORK_DIR
|
||||||
# APP_SRC
|
# MODULE_SRC
|
||||||
# PX4_APP_SRC
|
# PX4_MODULE_SRC
|
||||||
#
|
#
|
||||||
# Application directories are expected to contain an 'app.mk'
|
# Application directories are expected to contain a module.mk
|
||||||
# file which provides build configuration for the app. See
|
# file which provides build configuration for the module. See
|
||||||
# application.mk for more details.
|
# makefiles/module.mk for more details.
|
||||||
#
|
|
||||||
# LIBS
|
|
||||||
# Contains a list of library paths or path fragments used
|
|
||||||
# to find libraries. The names listed here are searched in the
|
|
||||||
# following directories:
|
|
||||||
# <absolute path>
|
|
||||||
# $(LIB_SEARCH_DIRS)
|
|
||||||
# WORK_DIR
|
|
||||||
# LIB_SRC
|
|
||||||
# PX4_LIB_SRC
|
|
||||||
#
|
|
||||||
# Library directories are expected to contain a 'lib.mk'
|
|
||||||
# file which provides build configuration for the library. See
|
|
||||||
# library.mk for more details.
|
|
||||||
#
|
#
|
||||||
# BUILTIN_COMMANDS
|
# BUILTIN_COMMANDS
|
||||||
# Contains a list of built-in commands not explicitly provided
|
# Contains a list of built-in commands not explicitly provided
|
||||||
# by applications / libraries. Each entry in this list is formatted
|
# by modules / libraries. Each entry in this list is formatted
|
||||||
# as <command>.<priority>.<stacksize>.<entrypoint>
|
# as <command>.<priority>.<stacksize>.<entrypoint>
|
||||||
#
|
#
|
||||||
# PX4_BASE:
|
# PX4_BASE:
|
||||||
|
@ -59,12 +45,8 @@
|
||||||
# containing the files under the directory and linked into the final
|
# containing the files under the directory and linked into the final
|
||||||
# image.
|
# image.
|
||||||
#
|
#
|
||||||
# APP_SEARCH_DIRS:
|
# MODULE_SEARCH_DIRS:
|
||||||
# Extra directories to search first for APPS before looking in the
|
# Extra directories to search first for MODULES before looking in the
|
||||||
# usual places.
|
|
||||||
#
|
|
||||||
# LIB_SEARCH_DIRS:
|
|
||||||
# Extra directories to search first for LIBS before looking in the
|
|
||||||
# usual places.
|
# usual places.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -82,8 +64,8 @@
|
||||||
MK_DIR ?= $(dir $(lastword $(MAKEFILE_LIST)))
|
MK_DIR ?= $(dir $(lastword $(MAKEFILE_LIST)))
|
||||||
ifeq ($(PX4_BASE),)
|
ifeq ($(PX4_BASE),)
|
||||||
export PX4_BASE := $(abspath $(MK_DIR)/..)
|
export PX4_BASE := $(abspath $(MK_DIR)/..)
|
||||||
$(info %% set PX4_BASE to $(PX4_BASE))
|
|
||||||
endif
|
endif
|
||||||
|
$(info PX4_BASE $(PX4_BASE))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Set a default target so that included makefiles or errors here don't
|
# Set a default target so that included makefiles or errors here don't
|
||||||
|
@ -111,7 +93,7 @@ $(error Can't find a config file called $(CONFIG) or $(PX4_MK_DIR)/config_$(CONF
|
||||||
endif
|
endif
|
||||||
export CONFIG
|
export CONFIG
|
||||||
include $(CONFIG_FILE)
|
include $(CONFIG_FILE)
|
||||||
$(info %% CONFIG $(CONFIG))
|
$(info CONFIG $(CONFIG))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Sanity-check the BOARD variable and then get the board config.
|
# Sanity-check the BOARD variable and then get the board config.
|
||||||
|
@ -128,7 +110,7 @@ $(error Config $(CONFIG) references board $(BOARD), but no board definition file
|
||||||
endif
|
endif
|
||||||
export BOARD
|
export BOARD
|
||||||
include $(BOARD_FILE)
|
include $(BOARD_FILE)
|
||||||
$(info %% BOARD $(BOARD))
|
$(info BOARD $(BOARD))
|
||||||
|
|
||||||
#
|
#
|
||||||
# If WORK_DIR is not set, create a 'build' directory next to the
|
# If WORK_DIR is not set, create a 'build' directory next to the
|
||||||
|
@ -136,9 +118,9 @@ $(info %% BOARD $(BOARD))
|
||||||
#
|
#
|
||||||
PARENT_MAKEFILE := $(lastword $(filter-out $(lastword $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
|
PARENT_MAKEFILE := $(lastword $(filter-out $(lastword $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
|
||||||
ifeq ($(WORK_DIR),)
|
ifeq ($(WORK_DIR),)
|
||||||
export WORK_DIR := $(dir $(PARENT_MAKEFILE))/build
|
export WORK_DIR := $(dir $(PARENT_MAKEFILE))build/
|
||||||
endif
|
endif
|
||||||
$(info %% WORK_DIR $(WORK_DIR))
|
$(info WORK_DIR $(WORK_DIR))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Things that, if they change, might affect everything
|
# Things that, if they change, might affect everything
|
||||||
|
@ -146,53 +128,71 @@ $(info %% WORK_DIR $(WORK_DIR))
|
||||||
GLOBAL_DEPS += $(MAKEFILE_LIST)
|
GLOBAL_DEPS += $(MAKEFILE_LIST)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Applications
|
# Modules
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# where to look for applications
|
#
|
||||||
APP_SEARCH_DIRS += $(WORK_DIR) $(APP_SRC) $(PX4_APP_SRC)
|
# We don't actually know what a moldule is called; all we have is a path fragment
|
||||||
|
# that we can search for, and where we expect to find a module.mk file.
|
||||||
|
#
|
||||||
|
# As such, we replicate the successfully-found path inside WORK_DIR for the
|
||||||
|
# module's build products in order to keep modules separated from each other.
|
||||||
|
#
|
||||||
|
# XXX If this becomes unwieldy or breaks for other reasons, we will need to
|
||||||
|
# move to allocating directory names and keeping tabs on makefiles via
|
||||||
|
# the directory name. That will involve arithmetic (it'd probably be time
|
||||||
|
# for GMSL).
|
||||||
|
|
||||||
# sort and unique the apps list
|
# where to look for modules
|
||||||
APPS := $(sort $(APPS))
|
MODULE_SEARCH_DIRS += $(WORK_DIR) $(MODULE_SRC) $(PX4_MODULE_SRC)
|
||||||
|
|
||||||
# locate the first instance of an app by full path or by looking on the
|
# sort and unique the modules list
|
||||||
# application search path
|
MODULES := $(sort $(MODULES))
|
||||||
define APP_SEARCH
|
|
||||||
$(firstword $(wildcard $(1)/app.mk) \
|
# locate the first instance of a module by full path or by looking on the
|
||||||
$(foreach search_dir,$(APP_SEARCH_DIRS),$(wildcard $(search_dir)/$(1)/app.mk)) \
|
# module search path
|
||||||
MISSING_$1)
|
define MODULE_SEARCH
|
||||||
|
$(abspath $(firstword $(wildcard $(1)/module.mk) \
|
||||||
|
$(foreach search_dir,$(MODULE_SEARCH_DIRS),$(wildcard $(search_dir)/$(1)/module.mk)) \
|
||||||
|
MISSING_$1))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
APP_MKFILES := $(foreach app,$(APPS),$(call APP_SEARCH,$(app)))
|
# make a list of module makefiles and check that we found them all
|
||||||
MISSING_APPS := $(subst MISSING_,,$(filter MISSING_%,$(APP_MKFILES)))
|
MODULE_MKFILES := $(foreach module,$(MODULES),$(call MODULE_SEARCH,$(module)))
|
||||||
ifneq ($(MISSING_APPS),)
|
MISSING_MODULES := $(subst MISSING_,,$(filter MISSING_%,$(MODULE_MKFILES)))
|
||||||
$(error Can't find application(s): $(MISSING_APPS))
|
ifneq ($(MISSING_MODULES),)
|
||||||
|
$(error Can't find module(s): $(MISSING_MODULES))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
APP_OBJS := $(foreach path,$(dir $(APP_MKFILES)),$(WORK_DIR)/$(path)/app.pre.o)
|
# make a list of the object files we expect to build from modules
|
||||||
|
MODULE_OBJS := $(foreach path,$(dir $(MODULE_MKFILES)),$(WORK_DIR)$(path)module.pre.o)
|
||||||
|
|
||||||
$(APP_OBJS): relpath = $(patsubst $(WORK_DIR)/%,%,$@)
|
# rules to build module objects
|
||||||
$(APP_OBJS): mkfile = $(patsubst %/app.pre.o,%/app.mk,$(relpath))
|
.PHONY: $(MODULE_OBJS)
|
||||||
$(APP_OBJS): $(GLOBAL_DEPS) $(NUTTX_CONFIG_HEADER)
|
$(MODULE_OBJS): relpath = $(patsubst $(WORK_DIR)%,%,$@)
|
||||||
|
$(MODULE_OBJS): mkfile = $(patsubst %module.pre.o,%module.mk,$(relpath))
|
||||||
|
$(MODULE_OBJS): $(GLOBAL_DEPS) $(NUTTX_CONFIG_HEADER)
|
||||||
@echo %%
|
@echo %%
|
||||||
@echo %% Building app in $(relpath) using $(mkfile)
|
@echo %% Building module using $(mkfile)
|
||||||
@echo %%
|
@echo %%
|
||||||
$(Q) make -f $(PX4_MK_DIR)/application.mk \
|
$(Q) make -f $(PX4_MK_DIR)module.mk \
|
||||||
APP_WORK_DIR=$(dir $@) \
|
MODULE_WORK_DIR=$(dir $@) \
|
||||||
APP_OBJ=$@ \
|
MODULE_OBJ=$@ \
|
||||||
APP_MK=$(mkfile) \
|
MODULE_MK=$(mkfile) \
|
||||||
app
|
module
|
||||||
|
|
||||||
APP_CLEANS := $(foreach path,$(dir $(APP_MKFILES)),$(WORK_DIR)/$(path)/clean)
|
# make a list of phony clean targets for modules
|
||||||
|
MODULE_CLEANS := $(foreach path,$(dir $(MODULE_MKFILES)),$(WORK_DIR)$(path)/clean)
|
||||||
|
|
||||||
.PHONY: $(APP_CLEANS)
|
# rules to clean modules
|
||||||
$(APP_CLEANS): relpath = $(patsubst $(WORK_DIR)/%,%,$@)
|
.PHONY: $(MODULE_CLEANS)
|
||||||
$(APP_CLEANS): mkfile = $(patsubst %/clean,%/app.mk,$(relpath))
|
$(MODULE_CLEANS): relpath = $(patsubst $(WORK_DIR)%,%,$@)
|
||||||
$(APP_CLEANS):
|
$(MODULE_CLEANS): mkfile = $(patsubst %clean,%module.mk,$(relpath))
|
||||||
|
$(MODULE_CLEANS):
|
||||||
@echo %% cleaning using $(mkfile)
|
@echo %% cleaning using $(mkfile)
|
||||||
$(Q) make -f $(PX4_MK_DIR)/application.mk \
|
$(Q) make -f $(PX4_MK_DIR)module.mk \
|
||||||
APP_WORK_DIR=$(dir $@) \
|
MODULE_WORK_DIR=$(dir $@) \
|
||||||
APP_MK=$(mkfile) \
|
MODULE_MK=$(mkfile) \
|
||||||
clean
|
clean
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -217,7 +217,7 @@ ROMFS_DEPS += $(wildcard \
|
||||||
(ROMFS_ROOT)/*/*/*/* \
|
(ROMFS_ROOT)/*/*/*/* \
|
||||||
(ROMFS_ROOT)/*/*/*/*/* \
|
(ROMFS_ROOT)/*/*/*/*/* \
|
||||||
(ROMFS_ROOT)/*/*/*/*/*/*)
|
(ROMFS_ROOT)/*/*/*/*/*/*)
|
||||||
ROMFS_IMG = $(WORK_DIR)/romfs.img
|
ROMFS_IMG = $(WORK_DIR)romfs.img
|
||||||
ROMFS_CSRC = $(ROMFS_IMG:.img=.c)
|
ROMFS_CSRC = $(ROMFS_IMG:.img=.c)
|
||||||
ROMFS_OBJ = $(ROMFS_CSRC:.c=.o)
|
ROMFS_OBJ = $(ROMFS_CSRC:.c=.o)
|
||||||
LIBS += $(ROMFS_OBJ)
|
LIBS += $(ROMFS_OBJ)
|
||||||
|
@ -245,7 +245,7 @@ endif
|
||||||
# NuttX export library. Instead, we have to treat it like a library.
|
# NuttX export library. Instead, we have to treat it like a library.
|
||||||
#
|
#
|
||||||
# Builtin commands can be generated by the configuration, in which case they
|
# Builtin commands can be generated by the configuration, in which case they
|
||||||
# must refer to commands that already exist, or indirectly generated by applications
|
# must refer to commands that already exist, or indirectly generated by modules
|
||||||
# when they are built.
|
# when they are built.
|
||||||
#
|
#
|
||||||
# The configuration supplies builtin command information in the BUILTIN_COMMANDS
|
# The configuration supplies builtin command information in the BUILTIN_COMMANDS
|
||||||
|
@ -257,10 +257,10 @@ endif
|
||||||
# and the name of the function to call when starting the thread.
|
# and the name of the function to call when starting the thread.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
BUILTIN_CSRC = $(WORK_DIR)/builtin_commands.c
|
BUILTIN_CSRC = $(WORK_DIR)builtin_commands.c
|
||||||
|
|
||||||
# add command definitions from apps
|
# add command definitions from modules
|
||||||
BUILTIN_COMMANDS += $(subst COMMAND.,,$(notdir $(wildcard $(WORK_DIR)/builtin_commands/COMMAND.*)))
|
BUILTIN_COMMANDS += $(subst COMMAND.,,$(notdir $(wildcard $(WORK_DIR)builtin_commands/COMMAND.*)))
|
||||||
|
|
||||||
# (BUILTIN_PROTO,<cmdspec>,<outputfile>)
|
# (BUILTIN_PROTO,<cmdspec>,<outputfile>)
|
||||||
define BUILTIN_PROTO
|
define BUILTIN_PROTO
|
||||||
|
@ -300,7 +300,7 @@ $(BUILTIN_OBJ): $(BUILTIN_CSRC)
|
||||||
# source file.
|
# source file.
|
||||||
#
|
#
|
||||||
ifeq ($(SRCS),)
|
ifeq ($(SRCS),)
|
||||||
EMPTY_SRC = $(WORK_DIR)/empty.c
|
EMPTY_SRC = $(WORK_DIR)empty.c
|
||||||
$(EMPTY_SRC):
|
$(EMPTY_SRC):
|
||||||
$(Q) echo '/* this is an empty file */' > $@
|
$(Q) echo '/* this is an empty file */' > $@
|
||||||
|
|
||||||
|
@ -314,9 +314,9 @@ endif
|
||||||
#
|
#
|
||||||
# What we're going to build.
|
# What we're going to build.
|
||||||
#
|
#
|
||||||
PRODUCT_BUNDLE = $(WORK_DIR)/firmware.px4
|
PRODUCT_BUNDLE = $(WORK_DIR)firmware.px4
|
||||||
PRODUCT_BIN = $(WORK_DIR)/firmware.bin
|
PRODUCT_BIN = $(WORK_DIR)firmware.bin
|
||||||
PRODUCT_SYM = $(WORK_DIR)/firmware.sym
|
PRODUCT_SYM = $(WORK_DIR)firmware.sym
|
||||||
|
|
||||||
.PHONY: firmware
|
.PHONY: firmware
|
||||||
firmware: $(PRODUCT_BUNDLE)
|
firmware: $(PRODUCT_BUNDLE)
|
||||||
|
@ -324,7 +324,7 @@ firmware: $(PRODUCT_BUNDLE)
|
||||||
#
|
#
|
||||||
# Object files we will generate from sources
|
# Object files we will generate from sources
|
||||||
#
|
#
|
||||||
OBJS := $(foreach src,$(SRCS),$(WORK_DIR)/$(src).o)
|
OBJS := $(foreach src,$(SRCS),$(WORK_DIR)$(src).o)
|
||||||
|
|
||||||
#
|
#
|
||||||
# SRCS -> OBJS rules
|
# SRCS -> OBJS rules
|
||||||
|
@ -332,13 +332,13 @@ OBJS := $(foreach src,$(SRCS),$(WORK_DIR)/$(src).o)
|
||||||
|
|
||||||
$(OBJS): $(GLOBAL_DEPS)
|
$(OBJS): $(GLOBAL_DEPS)
|
||||||
|
|
||||||
$(filter %.c.o,$(OBJS)): $(WORK_DIR)/%.c.o: %.c
|
$(filter %.c.o,$(OBJS)): $(WORK_DIR)%.c.o: %.c $(GLOBAL_DEPS)
|
||||||
$(call COMPILE,$<,$@)
|
$(call COMPILE,$<,$@)
|
||||||
|
|
||||||
$(filter %.cpp.o,$(OBJS)): $(WORK_DIR)/%.cpp.o: %.cpp $(GLOBAL_DEPS)
|
$(filter %.cpp.o,$(OBJS)): $(WORK_DIR)%.cpp.o: %.cpp $(GLOBAL_DEPS)
|
||||||
$(call COMPILEXX,$<,$@)
|
$(call COMPILEXX,$<,$@)
|
||||||
|
|
||||||
$(filter %.S.o,$(OBJS)): $(WORK_DIR)/%.S.o: %.S $(GLOBAL_DEPS)
|
$(filter %.S.o,$(OBJS)): $(WORK_DIR)%.S.o: %.S $(GLOBAL_DEPS)
|
||||||
$(call ASSEMBLE,$<,$@)
|
$(call ASSEMBLE,$<,$@)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -354,8 +354,8 @@ $(PRODUCT_BUNDLE): $(PRODUCT_BIN)
|
||||||
$(PRODUCT_BIN): $(PRODUCT_SYM)
|
$(PRODUCT_BIN): $(PRODUCT_SYM)
|
||||||
$(call SYM_TO_BIN,$<,$@)
|
$(call SYM_TO_BIN,$<,$@)
|
||||||
|
|
||||||
$(PRODUCT_SYM): $(OBJS) $(APP_OBJS) $(GLOBAL_DEPS) $(LINK_DEPS) $(APP_MKFILES)
|
$(PRODUCT_SYM): $(OBJS) $(MODULE_OBJS) $(GLOBAL_DEPS) $(LINK_DEPS) $(MODULE_MKFILES)
|
||||||
$(call LINK,$@,$(OBJS) $(APP_OBJS))
|
$(call LINK,$@,$(OBJS) $(MODULE_OBJS))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Utility rules
|
# Utility rules
|
||||||
|
@ -370,7 +370,7 @@ upload: $(PRODUCT_BUNDLE) $(PRODUCT_BIN)
|
||||||
BIN=$(PRODUCT_BIN)
|
BIN=$(PRODUCT_BIN)
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: $(APP_CLEANS)
|
clean: $(MODULE_CLEANS)
|
||||||
@echo %% cleaning
|
@echo %% cleaning
|
||||||
$(Q) $(REMOVE) $(PRODUCT_BUNDLE) $(PRODUCT_BIN) $(PRODUCT_SYM)
|
$(Q) $(REMOVE) $(PRODUCT_BUNDLE) $(PRODUCT_BIN) $(PRODUCT_SYM)
|
||||||
$(Q) $(REMOVE) $(OBJS) $(DEP_INCLUDES)
|
$(Q) $(REMOVE) $(OBJS) $(DEP_INCLUDES)
|
||||||
|
|
|
@ -0,0 +1,165 @@
|
||||||
|
#
|
||||||
|
# Framework makefile for PX4 modules
|
||||||
|
#
|
||||||
|
# This makefile is invoked by firmware.mk to build each of the modules
|
||||||
|
# that will subsequently be linked into the firmware image.
|
||||||
|
#
|
||||||
|
# Applications are built as prelinked objects with a limited set of exported
|
||||||
|
# symbols, as the global namespace is shared between all modules. Normally an
|
||||||
|
# module will just export one or more <command>_main functions.
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Variables that can be set by the module's module.mk:
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# SRCS (required)
|
||||||
|
# Lists the .c, cpp and .S files that should be compiled/assembled to
|
||||||
|
# produce the module.
|
||||||
|
#
|
||||||
|
# MODULE_NAME (optional)
|
||||||
|
# MODULE_ENTRYPOINT (optional if MODULE_NAME is set)
|
||||||
|
# MODULE_STACKSIZE (optional if MODULE_NAME is set)
|
||||||
|
# MODULE_PRIORITY (optional if MODULE_NAME is set)
|
||||||
|
# Defines a single builtin command exported by the module.
|
||||||
|
# MODULE_NAME must be unique for any configuration, but need not be the
|
||||||
|
# same as the module directory name.
|
||||||
|
#
|
||||||
|
# If MODULE_ENTRYPOINT is set, it names the function (which must be exported)
|
||||||
|
# that will be the entrypoint for the builtin command. It defaults to
|
||||||
|
# $(MODULE_NAME)_main.
|
||||||
|
#
|
||||||
|
# If MODULE_STACKSIZE is set, it is the size in bytes of the stack to be
|
||||||
|
# allocated for the builtin command. If it is not set, it defaults
|
||||||
|
# to CONFIG_PTHREAD_STACK_DEFAULT.
|
||||||
|
#
|
||||||
|
# If MODULE_PRIORITY is set, it is the thread priority for the builtin
|
||||||
|
# command. If it is not set, it defaults to SCHED_PRIORITY_DEFAULT.
|
||||||
|
#
|
||||||
|
# MODULE_COMMANDS (optional)
|
||||||
|
# Defines builtin commands exported by the module. Each word in
|
||||||
|
# the list should be formatted as:
|
||||||
|
# <command>.<priority>.<stacksize>.<entrypoint>
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Variables visible to the module's module.mk:
|
||||||
|
#
|
||||||
|
# CONFIG
|
||||||
|
# BOARD
|
||||||
|
# MODULE_WORK_DIR
|
||||||
|
# Anything set in setup.mk, board_$(BOARD).mk and the toolchain file.
|
||||||
|
# Anything exported from config_$(CONFIG).mk
|
||||||
|
#
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# No user-serviceable parts below.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
ifeq ($(MODULE_MK),)
|
||||||
|
$(error No module makefile specified)
|
||||||
|
endif
|
||||||
|
$(info MODULE_MK $(MODULE_MK))
|
||||||
|
|
||||||
|
#
|
||||||
|
# Get path and tool config
|
||||||
|
#
|
||||||
|
include $(PX4_BASE)/makefiles/setup.mk
|
||||||
|
|
||||||
|
#
|
||||||
|
# Get the board/toolchain config
|
||||||
|
#
|
||||||
|
include $(PX4_MK_DIR)/board_$(BOARD).mk
|
||||||
|
|
||||||
|
#
|
||||||
|
# Get the module's config
|
||||||
|
#
|
||||||
|
include $(MODULE_MK)
|
||||||
|
MODULE_SRC := $(dir $(MODULE_MK))
|
||||||
|
$(info MODULE_SRC $(MODULE_SRC))
|
||||||
|
$(info MODULE_WORK_DIR $(MODULE_WORK_DIR))
|
||||||
|
|
||||||
|
#
|
||||||
|
# Things that, if they change, might affect everything
|
||||||
|
#
|
||||||
|
GLOBAL_DEPS += $(MAKEFILE_LIST)
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Builtin command definitions
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
ifneq ($(MODULE_NAME),)
|
||||||
|
MODULE_ENTRYPOINT ?= $(MODULE_NAME)_main
|
||||||
|
MODULE_STACKSIZE ?= CONFIG_PTHREAD_STACK_DEFAULT
|
||||||
|
MODULE_PRIORITY ?= SCHED_PRIORITY_DEFAULT
|
||||||
|
MODULE_COMMANDS += $(MODULE_NAME).$(MODULE_PRIORITY).$(MODULE_STACKSIZE).$(MODULE_ENTRYPOINT)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(MODULE_COMMANDS),)
|
||||||
|
MODULE_COMMAND_FILES := $(addprefix $(WORK_DIR)/builtin_commands/COMMAND.,$(MODULE_COMMANDS))
|
||||||
|
|
||||||
|
.PHONY: $(MODULE_COMMAND_FILES)
|
||||||
|
$(MODULE_COMMAND_FILES): $(GLOBAL_DEPS)
|
||||||
|
@echo COMMAND $(word 2,$(subst ., ,$(notdir $(@))))
|
||||||
|
@mkdir -p $@
|
||||||
|
$(Q) touch $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Build rules
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
#
|
||||||
|
# What we're going to build
|
||||||
|
#
|
||||||
|
module: $(MODULE_OBJ) $(MODULE_COMMAND_FILES)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Locate sources (allows relative source paths in module.mk)
|
||||||
|
#
|
||||||
|
define SRC_SEARCH
|
||||||
|
$(abspath $(firstword $(wildcard $(MODULE_SRC)/$1) MISSING_$1))
|
||||||
|
endef
|
||||||
|
|
||||||
|
ABS_SRCS := $(foreach src,$(SRCS),$(call SRC_SEARCH,$(src)))
|
||||||
|
MISSING_SRCS := $(subst MISSING_,,$(filter MISSING_%,$(ABS_SRCS)))
|
||||||
|
ifneq ($(MISSING_SRCS),)
|
||||||
|
$(error $(MODULE_MK): missing in SRCS: $(MISSING_SRCS))
|
||||||
|
endif
|
||||||
|
ifeq ($(ABS_SRCS),)
|
||||||
|
$(error $(MODULE_MK): nothing to compile in SRCS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Object files we will generate from sources
|
||||||
|
#
|
||||||
|
OBJS := $(foreach src,$(ABS_SRCS),$(MODULE_WORK_DIR)$(src).o)
|
||||||
|
|
||||||
|
#
|
||||||
|
# SRCS -> OBJS rules
|
||||||
|
#
|
||||||
|
|
||||||
|
$(OBJS): $(GLOBAL_DEPS)
|
||||||
|
|
||||||
|
$(filter %.c.o,$(OBJS)): $(MODULE_WORK_DIR)%.c.o: %.c $(GLOBAL_DEPS)
|
||||||
|
$(call COMPILE,$<,$@)
|
||||||
|
|
||||||
|
$(filter %.cpp.o,$(OBJS)): $(MODULE_WORK_DIR)%.cpp.o: %.cpp $(GLOBAL_DEPS)
|
||||||
|
$(call COMPILEXX,$<,$@)
|
||||||
|
|
||||||
|
$(filter %.S.o,$(OBJS)): $(MODULE_WORK_DIR)%.S.o: %.S $(GLOBAL_DEPS)
|
||||||
|
$(call ASSEMBLE,$<,$@)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Built product rules
|
||||||
|
#
|
||||||
|
|
||||||
|
$(MODULE_OBJ): $(OBJS) $(GLOBAL_DEPS)
|
||||||
|
$(call PRELINK,$@,$(OBJS))
|
||||||
|
|
||||||
|
#
|
||||||
|
# Utility rules
|
||||||
|
#
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(Q) $(REMOVE) $(MODULE_PRELINK) $(OBJS)
|
|
@ -6,7 +6,7 @@
|
||||||
#
|
#
|
||||||
# Check that the NuttX archive for the selected board is available.
|
# Check that the NuttX archive for the selected board is available.
|
||||||
#
|
#
|
||||||
NUTTX_ARCHIVE := $(wildcard $(ARCHIVE_DIR)/$(BOARD).export)
|
NUTTX_ARCHIVE := $(wildcard $(ARCHIVE_DIR)$(BOARD).export)
|
||||||
ifeq ($(NUTTX_ARCHIVE),)
|
ifeq ($(NUTTX_ARCHIVE),)
|
||||||
$(error The NuttX export archive for $(BOARD) is missing from $(ARCHIVE_DIR) - try 'make archives' in $(PX4_BASE))
|
$(error The NuttX export archive for $(BOARD) is missing from $(ARCHIVE_DIR) - try 'make archives' in $(PX4_BASE))
|
||||||
endif
|
endif
|
||||||
|
@ -16,23 +16,27 @@ endif
|
||||||
# if it changes, everything should be rebuilt. So, use it as the trigger to
|
# if it changes, everything should be rebuilt. So, use it as the trigger to
|
||||||
# unpack the NuttX archive.
|
# unpack the NuttX archive.
|
||||||
#
|
#
|
||||||
NUTTX_EXPORT_DIR = $(WORK_DIR)/nuttx-export
|
NUTTX_EXPORT_DIR = $(WORK_DIR)nuttx-export/
|
||||||
NUTTX_CONFIG_HEADER = $(NUTTX_EXPORT_DIR)/include/nuttx/config.h
|
NUTTX_CONFIG_HEADER = $(NUTTX_EXPORT_DIR)include/nuttx/config.h
|
||||||
|
$(info NUTTX_EXPORT_DIR $(NUTTX_EXPORT_DIR))
|
||||||
|
$(info NUTTX_CONFIG_HEADER $(NUTTX_CONFIG_HEADER))
|
||||||
|
|
||||||
|
|
||||||
GLOBAL_DEPS += $(NUTTX_CONFIG_HEADER)
|
GLOBAL_DEPS += $(NUTTX_CONFIG_HEADER)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Use the linker script from the NuttX export
|
# Use the linker script from the NuttX export
|
||||||
#
|
#
|
||||||
LDSCRIPT = $(NUTTX_EXPORT_DIR)/build/ld.script
|
LDSCRIPT = $(NUTTX_EXPORT_DIR)build/ld.script
|
||||||
|
|
||||||
#
|
#
|
||||||
# Add directories from the NuttX export to the relevant search paths
|
# Add directories from the NuttX export to the relevant search paths
|
||||||
#
|
#
|
||||||
INCLUDE_DIRS += $(NUTTX_EXPORT_DIR)/include
|
INCLUDE_DIRS += $(NUTTX_EXPORT_DIR)include
|
||||||
LIB_DIRS += $(NUTTX_EXPORT_DIR)/libs
|
LIB_DIRS += $(NUTTX_EXPORT_DIR)libs
|
||||||
LIBS += -lapps -lnuttx
|
LIBS += -lapps -lnuttx
|
||||||
LINK_DEPS += $(NUTTX_EXPORT_DIR)/libs/libapps.a \
|
LINK_DEPS += $(NUTTX_EXPORT_DIR)libs/libapps.a \
|
||||||
$(NUTTX_EXPORT_DIR)/libs/libnuttx.a
|
$(NUTTX_EXPORT_DIR)libs/libnuttx.a
|
||||||
|
|
||||||
$(NUTTX_CONFIG_HEADER): $(NUTTX_ARCHIVE)
|
$(NUTTX_CONFIG_HEADER): $(NUTTX_ARCHIVE)
|
||||||
@echo %% Unpacking $(NUTTX_ARCHIVE)
|
@echo %% Unpacking $(NUTTX_ARCHIVE)
|
||||||
|
|
|
@ -5,16 +5,20 @@
|
||||||
#
|
#
|
||||||
# Some useful paths.
|
# Some useful paths.
|
||||||
#
|
#
|
||||||
export PX4_APP_SRC = $(PX4_BASE)/src/apps
|
# Note that in general we always keep directory paths with the separator
|
||||||
export PX4_LIB_SRC = $(PX4_BASE)/src/libs
|
# at the end, and join paths without explicit separators. This reduces
|
||||||
export PX4_MK_DIR = $(PX4_BASE)/makefiles
|
# the number of duplicate slashes we have lying around in paths,
|
||||||
export NUTTX_SRC = $(PX4_BASE)/nuttx
|
# and is consistent with joining the results of $(dir) and $(notdir).
|
||||||
export NUTTX_APP_SRC = $(PX4_BASE)/apps
|
#
|
||||||
export MAVLINK_SRC = $(PX4_BASE)/mavlink
|
export PX4_MODULE_SRC = $(abspath $(PX4_BASE)/src/modules)/
|
||||||
export ROMFS_SRC = $(PX4_BASE)/ROMFS
|
export PX4_MK_DIR = $(abspath $(PX4_BASE)/makefiles)/
|
||||||
export IMAGE_DIR = $(PX4_BASE)/Images
|
export NUTTX_SRC = $(abspath $(PX4_BASE)/nuttx)/
|
||||||
export BUILD_DIR = $(PX4_BASE)/Build
|
export NUTTX_APP_SRC = $(abspath $(PX4_BASE)/apps)/
|
||||||
export ARCHIVE_DIR = $(PX4_BASE)/Archives
|
export MAVLINK_SRC = $(abspath $(PX4_BASE)/mavlink)/
|
||||||
|
export ROMFS_SRC = $(abspath $(PX4_BASE)/ROMFS)/
|
||||||
|
export IMAGE_DIR = $(abspath $(PX4_BASE)/Images)/
|
||||||
|
export BUILD_DIR = $(abspath $(PX4_BASE)/Build)/
|
||||||
|
export ARCHIVE_DIR = $(abspath $(PX4_BASE)/Archives)/
|
||||||
|
|
||||||
#
|
#
|
||||||
# Tools
|
# Tools
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Definitions for a generic GNU ARM-EABI toolchain
|
# Definitions for a generic GNU ARM-EABI toolchain
|
||||||
#
|
#
|
||||||
|
|
||||||
$(info %% TOOLCHAIN gnu-arm-eabi)
|
#$(info TOOLCHAIN gnu-arm-eabi)
|
||||||
|
|
||||||
CROSSDEV = arm-none-eabi-
|
CROSSDEV = arm-none-eabi-
|
||||||
|
|
||||||
|
@ -134,7 +134,8 @@ DEP_INCLUDES = $(subst .o,.d,$(OBJS))
|
||||||
# compile C source $1 to object $2
|
# compile C source $1 to object $2
|
||||||
# as a side-effect, generate a dependency file
|
# as a side-effect, generate a dependency file
|
||||||
define COMPILE
|
define COMPILE
|
||||||
@echo "CC: $1"
|
@echo "CC <- $1"
|
||||||
|
@echo "CC -> $2"
|
||||||
@mkdir -p $(dir $2)
|
@mkdir -p $(dir $2)
|
||||||
$(Q) $(CC) -MD -c $(CFLAGS) $(abspath $1) -o $2
|
$(Q) $(CC) -MD -c $(CFLAGS) $(abspath $1) -o $2
|
||||||
endef
|
endef
|
||||||
|
@ -172,7 +173,7 @@ endef
|
||||||
define LINK
|
define LINK
|
||||||
@echo "LINK: $1"
|
@echo "LINK: $1"
|
||||||
@mkdir -p $(dir $1)
|
@mkdir -p $(dir $1)
|
||||||
$(Q) $(LD) $(LDFLAGS) -o $1 $2 --start-group $(LIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group
|
$(Q) $(LD) $(LDFLAGS) -o $1 --start-group $2 $(LIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# convert $1 from a linked object to a raw binary
|
# convert $1 from a linked object to a raw binary
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
|
|
||||||
APP_NAME = test
|
|
||||||
SRCS = foo.c
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
MODULE_NAME = test
|
||||||
|
SRCS = foo.c
|
||||||
|
|
Loading…
Reference in New Issue