2012-08-04 19:12:36 -03:00
|
|
|
#
|
|
|
|
# Top-level Makefile for building PX4 firmware images.
|
|
|
|
#
|
2013-01-16 22:23:49 -04:00
|
|
|
|
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-21 01:12:59 -04:00
|
|
|
export PX4_BASE := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
|
|
|
|
include $(PX4_BASE)/makefiles/setup.mk
|
2013-01-16 22:23:49 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# Canned firmware configurations that we build.
|
|
|
|
#
|
|
|
|
CONFIGS ?= px4fmu_default px4io_default
|
2012-08-04 19:12:36 -03:00
|
|
|
|
2013-01-17 02:38:47 -04:00
|
|
|
#
|
|
|
|
# Platforms (boards) that we build NuttX export kits for.
|
|
|
|
#
|
|
|
|
PLATFORMS = px4fmu px4io
|
|
|
|
|
2012-08-04 19:12:36 -03:00
|
|
|
#
|
2013-01-16 22:23:49 -04:00
|
|
|
# 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-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-01-11 06:14:43 -04:00
|
|
|
endif
|
2012-08-04 19:12:36 -03:00
|
|
|
|
2013-01-16 22:23:49 -04:00
|
|
|
#
|
|
|
|
# Built products
|
2012-08-04 19:12:36 -03:00
|
|
|
#
|
2013-01-17 01:03:27 -04:00
|
|
|
STAGED_FIRMWARES = $(foreach config,$(CONFIGS),$(IMAGE_DIR)/$(config).px4)
|
|
|
|
FIRMWARES = $(foreach config,$(CONFIGS),$(BUILD_DIR)/$(config).build/firmware.px4)
|
2012-08-04 19:12:36 -03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Debugging
|
|
|
|
#
|
2013-01-11 06:31:30 -04:00
|
|
|
MQUIET = --no-print-directory
|
|
|
|
#MQUIET = --print-directory
|
2012-08-04 19:12:36 -03:00
|
|
|
|
2013-01-17 01:03:27 -04:00
|
|
|
all: $(STAGED_FIRMWARES)
|
2012-08-04 19:12:36 -03:00
|
|
|
|
|
|
|
#
|
2013-01-17 01:03:27 -04:00
|
|
|
# Copy FIRMWARES into the image directory.
|
2012-08-04 19:12:36 -03:00
|
|
|
#
|
2013-01-17 01:03:27 -04:00
|
|
|
$(STAGED_FIRMWARES): $(IMAGE_DIR)/%.px4: $(BUILD_DIR)/%.build/firmware.px4
|
|
|
|
@echo %% Copying $@
|
|
|
|
$(Q) $(COPY) $< $@
|
2013-01-03 02:13:30 -04:00
|
|
|
|
2012-08-04 19:12:36 -03:00
|
|
|
#
|
2013-01-17 02:38:47 -04:00
|
|
|
# Generate FIRMWARES.
|
2013-01-16 22:23:49 -04:00
|
|
|
#
|
2013-01-17 02:44:27 -04:00
|
|
|
.PHONY: $(FIRMWARES)
|
2013-01-17 01:03:27 -04:00
|
|
|
$(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:
|
|
|
|
@echo %%%% Building $(config) in $(work_dir)
|
|
|
|
$(Q) mkdir -p $(work_dir)
|
2013-01-16 22:23:49 -04:00
|
|
|
$(Q) make -C $(work_dir) \
|
2013-01-17 02:44:27 -04:00
|
|
|
-f $(PX4_BASE)/makefiles/config_$(config).mk \
|
2013-02-21 01:12:59 -04:00
|
|
|
WORK_DIR=$(work_dir) \
|
|
|
|
firmware
|
2012-08-04 19:12:36 -03:00
|
|
|
|
|
|
|
#
|
2013-01-16 22:23:49 -04:00
|
|
|
# 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
|
2013-01-17 01:03:27 -04:00
|
|
|
# archives/build area manually. Likewise, when the 'archives' target is
|
|
|
|
# invoked, all archives are always rebuilt.
|
2013-01-16 22:23:49 -04:00
|
|
|
#
|
|
|
|
# XXX Should support fetching/unpacking from a separate directory to permit
|
|
|
|
# downloads of the prebuilt archives as well...
|
2012-08-04 19:12:36 -03:00
|
|
|
#
|
2013-01-17 02:44:27 -04:00
|
|
|
# XXX PX4IO configuration name is bad - NuttX configs should probably all be "px4"
|
2013-01-16 22:23:49 -04:00
|
|
|
#
|
|
|
|
NUTTX_ARCHIVES = $(foreach platform,$(PLATFORMS),$(ARCHIVE_DIR)/$(platform).export)
|
|
|
|
.PHONY: archives
|
|
|
|
archives: $(NUTTX_ARCHIVES)
|
2012-08-04 19:12:36 -03:00
|
|
|
|
2013-01-16 22:23:49 -04:00
|
|
|
$(ARCHIVE_DIR)/%.export: platform = $(notdir $(basename $@))
|
2013-01-17 02:44:27 -04:00
|
|
|
$(ARCHIVE_DIR)/%.export: configuration = $(if $(filter $(platform),px4io),io,nsh)
|
2013-01-16 22:23:49 -04:00
|
|
|
$(NUTTX_ARCHIVES): $(ARCHIVE_DIR)/%.export: $(NUTTX_SRC) $(NUTTX_APPS)
|
|
|
|
@echo %% Configuring NuttX for $(platform)
|
|
|
|
$(Q) (cd $(NUTTX_SRC) && $(RMDIR) nuttx-export)
|
|
|
|
$(Q) make -C $(NUTTX_SRC) -r $(MQUIET) distclean
|
2013-01-17 02:44:27 -04:00
|
|
|
$(Q) (cd $(NUTTX_SRC)/tools && ./configure.sh $(platform)/$(configuration))
|
2013-01-16 22:23:49 -04:00
|
|
|
@echo %% Exporting NuttX for $(platform)
|
|
|
|
$(Q) make -C $(NUTTX_SRC) -r $(MQUIET) export
|
|
|
|
$(Q) mkdir -p $(dir $@)
|
|
|
|
$(Q) $(COPY) $(NUTTX_SRC)/nuttx-export.zip $@
|
2012-08-04 19:12:36 -03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Cleanup targets. 'clean' should remove all built products and force
|
|
|
|
# a complete re-compilation, 'distclean' should remove everything
|
|
|
|
# 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:
|
2013-01-16 22:23:49 -04:00
|
|
|
$(Q) $(RMDIR) $(BUILD_DIR)/*.build
|
|
|
|
$(Q) $(REMOVE) -f $(IMAGE_DIR)/*.px4
|
2012-08-04 19:12:36 -03:00
|
|
|
|
|
|
|
.PHONY: distclean
|
2013-01-16 22:23:49 -04:00
|
|
|
distclean: clean
|
|
|
|
$(Q) $(REMOVE) -f $(ARCHIVE_DIR)/*.export
|
|
|
|
$(Q) make -C $(NUTTX_SRC) -r $(MQUIET) distclean
|
2012-08-04 19:12:36 -03:00
|
|
|
|