diff options
author | px4dev <px4@purgatory.org> | 2013-01-05 21:46:50 -0800 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2013-02-23 22:00:58 -0800 |
commit | b80575fcff926fb819adeb1760632586c19cf719 (patch) | |
tree | d99c471ab5bbf1ee06207c7485bf8c7a78debf6c /makefiles/firmware.mk | |
parent | 085d08ce6c55d3fb979aa9847aea584fb7eb4f7c (diff) | |
download | px4-firmware-b80575fcff926fb819adeb1760632586c19cf719.tar.gz px4-firmware-b80575fcff926fb819adeb1760632586c19cf719.tar.bz2 px4-firmware-b80575fcff926fb819adeb1760632586c19cf719.zip |
Break up the firmware build into a 'make export' phase for NuttX on a per-board basis, and then a separate per-config phase that allows us to avoid re-building NuttX all the time, and ship more than one firmware config for a given board.
This is a first cut; it builds one firmware for each of FMU and IO.
Diffstat (limited to 'makefiles/firmware.mk')
-rw-r--r-- | makefiles/firmware.mk | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/makefiles/firmware.mk b/makefiles/firmware.mk new file mode 100644 index 000000000..34741e79e --- /dev/null +++ b/makefiles/firmware.mk @@ -0,0 +1,71 @@ +# +# Generic Makefile for PX4 firmware. +# +# Currently this assumes that we're just compiling SRCS +# and then linking the whole thing together. +# + +# +# Work out where this file is, so we can find other makefiles in the +# same directory. +# +export PX4_MK_INCLUDE ?= $(dir $(lastword $(MAKEFILE_LIST))) + +# +# Use the linker script from the NuttX export +# +LDSCRIPT = $(WORK_DIR)/nuttx-export/build/ld.script + +# +# Add directories from the NuttX export to the relevant search paths +# +INCLUDE_DIRS += $(WORK_DIR)/nuttx-export/include +LIB_DIRS += $(WORK_DIR)/nuttx-export/libs +LIBS += -lapps -lnuttx + +# +# Things that, if they change, might affect everything +# +GLOBAL_DEPS += $(MAKEFILE_LIST) + +# +# Include the platform configuration +# +include $(PX4_MK_INCLUDE)/$(PLATFORM).mk + +# +# What we're going to build +# +PRODUCT_BIN = $(WORK_DIR)/firmware.bin +PRODUCT_SYM = $(WORK_DIR)/firmware.sym +PRODUCTS = $(PRODUCT_BIN) $(PRODUCT_SYM) + +.PHONY: all +all: $(PRODUCTS) + +# +# Rules for building objects +# +OBJS = $(foreach src,$(SRCS),$(WORK_DIR)/$(src).o) + +$(filter %.c.o,$(OBJS)): $(WORK_DIR)/%.c.o: %.c + @echo compile $< + @mkdir -p $(dir $@) + $(call COMPILE,$<,$@) + +$(filter %.cpp.o,$(OBJS)): $(WORK_DIR)/%.cpp.o: %.cpp + @mkdir -p $(dir $@) + $(call COMPILEXX,$<,$@) + +$(filter %.S.o,$(OBJS)): $(WORK_DIR)/%.S.o: %.S + @mkdir -p $(dir $@) + $(call ASSEMBLE,$<,$@) + +-include $(DEP_INCLUDES) + +$(PRODUCT_BIN): $(PRODUCT_SYM) + $(call SYM_TO_BIN,$<,$@) + +$(PRODUCT_SYM): $(OBJS) $(GLOBAL_DEPS) $(LINK_DEPS) + $(call LINK,$@,$(OBJS)) + |