aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile124
1 files changed, 82 insertions, 42 deletions
diff --git a/Makefile b/Makefile
index 7f98ffaf2..778395cee 100644
--- a/Makefile
+++ b/Makefile
@@ -100,7 +100,7 @@ all: $(STAGED_FIRMWARES)
# is taken care of.
#
$(STAGED_FIRMWARES): $(IMAGE_DIR)%.px4: $(BUILD_DIR)%.build/firmware.px4
- @echo %% Copying $@
+ @$(ECHO) %% Copying $@
$(Q) $(COPY) $< $@
$(Q) $(COPY) $(patsubst %.px4,%.bin,$<) $(patsubst %.px4,%.bin,$@)
@@ -111,9 +111,9 @@ $(STAGED_FIRMWARES): $(IMAGE_DIR)%.px4: $(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/
$(FIRMWARES): $(BUILD_DIR)%.build/firmware.px4:
- @echo %%%%
- @echo %%%% Building $(config) in $(work_dir)
- @echo %%%%
+ @$(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 \
@@ -132,8 +132,6 @@ $(FIRMWARES): $(BUILD_DIR)%.build/firmware.px4:
# XXX Should support fetching/unpacking from a separate directory to permit
# downloads of the prebuilt archives as well...
#
-# XXX PX4IO configuration name is bad - NuttX configs should probably all be "px4"
-#
NUTTX_ARCHIVES = $(foreach board,$(BOARDS),$(ARCHIVE_DIR)$(board).export)
.PHONY: archives
archives: $(NUTTX_ARCHIVES)
@@ -146,15 +144,54 @@ endif
$(ARCHIVE_DIR)%.export: board = $(notdir $(basename $@))
$(ARCHIVE_DIR)%.export: configuration = nsh
-$(NUTTX_ARCHIVES): $(ARCHIVE_DIR)%.export: $(NUTTX_SRC) $(NUTTX_APPS)
- @echo %% Configuring NuttX for $(board)
+$(NUTTX_ARCHIVES): $(ARCHIVE_DIR)%.export: $(NUTTX_SRC)
+ @$(ECHO) %% Configuring NuttX for $(board)
$(Q) (cd $(NUTTX_SRC) && $(RMDIR) nuttx-export)
$(Q) make -r -j1 -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 -j1 -C $(NUTTX_SRC) -r $(MQUIET) export
+ @$(ECHO) %% Exporting NuttX for $(board)
+ $(Q) make -r -j1 -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 -j1 -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 -j1 -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):
+ @$(ECHO) ""
+ @$(ECHO) "NuttX sources missing - clone https://github.com/PX4/NuttX.git and try again."
+ @$(ECHO) ""
+
+#
+# Testing targets
+#
+testbuild:
+ $(Q) (cd $(PX4_BASE) && make distclean && make archives && make -j8)
#
# Cleanup targets. 'clean' should remove all built products and force
@@ -176,40 +213,43 @@ distclean: clean
#
.PHONY: help
help:
- @echo ""
- @echo " PX4 firmware builder"
- @echo " ===================="
- @echo ""
- @echo " Available targets:"
- @echo " ------------------"
- @echo ""
- @echo " archives"
- @echo " Build the NuttX RTOS archives that are used by the firmware build."
- @echo ""
- @echo " all"
- @echo " Build all firmware configs: $(CONFIGS)"
- @echo " A limited set of configs can be built with CONFIGS=<list-of-configs>"
- @echo ""
+ @$(ECHO) ""
+ @$(ECHO) " PX4 firmware builder"
+ @$(ECHO) " ===================="
+ @$(ECHO) ""
+ @$(ECHO) " Available targets:"
+ @$(ECHO) " ------------------"
+ @$(ECHO) ""
+ @$(ECHO) " archives"
+ @$(ECHO) " Build the NuttX RTOS archives that are used by the firmware build."
+ @$(ECHO) ""
+ @$(ECHO) " all"
+ @$(ECHO) " Build all firmware configs: $(CONFIGS)"
+ @$(ECHO) " A limited set of configs can be built with CONFIGS=<list-of-configs>"
+ @$(ECHO) ""
@for config in $(CONFIGS); do \
echo " $$config"; \
echo " Build just the $$config firmware configuration."; \
echo ""; \
done
- @echo " clean"
- @echo " Remove all firmware build pieces."
- @echo ""
- @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 ""
- @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 ""
+ @$(ECHO) " clean"
+ @$(ECHO) " Remove all firmware build pieces."
+ @$(ECHO) ""
+ @$(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) ""
+ @$(ECHO) " testbuild"
+ @$(ECHO) " Perform a complete clean build of the entire tree."
+ @$(ECHO) ""
+ @$(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) ""