2011-05-13 16:40:28 +02:00
|
|
|
# Set up a default goal
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
|
|
|
|
# Tried the best to support parallel (-j) builds. But since this Makefile
|
|
|
|
# uses other Makefiles to build few targets which in turn have similar
|
|
|
|
# dependencies on uavobjects and other generated files, it is difficult
|
2011-05-15 13:54:24 +02:00
|
|
|
# to support parallel builds perfectly. But at least it was tested with
|
|
|
|
# -j (unlimited job number) on Windows and Linux.
|
2011-05-13 16:40:28 +02:00
|
|
|
|
|
|
|
# Locate the root of the tree
|
|
|
|
WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST)))
|
|
|
|
ROOT_DIR := $(realpath $(WHEREAMI)/../)
|
|
|
|
|
|
|
|
# Set up some macros
|
|
|
|
BUILD_DIR := $(ROOT_DIR)/build
|
2011-05-19 00:05:12 +02:00
|
|
|
VERSION_CMD := python $(ROOT_DIR)/make/scripts/version-info.py --path="$(ROOT_DIR)"
|
2011-05-28 02:14:51 +02:00
|
|
|
PACKAGE_LBL := $(shell $(VERSION_CMD) --format=\$${DATE}-\$${TAG_OR_HASH8}\$${DIRTY})
|
|
|
|
PACKAGE_DIR := $(BUILD_DIR)/package-$(PACKAGE_LBL)
|
|
|
|
FW_DIR := $(PACKAGE_DIR)/firmware-$(PACKAGE_LBL)
|
2011-05-13 16:40:28 +02:00
|
|
|
BL_DIR := $(FW_DIR)/bootloaders
|
2011-05-24 23:44:45 +02:00
|
|
|
BU_DIR := $(FW_DIR)/bootloader-updaters
|
|
|
|
FE_DIR := $(FW_DIR)/flash-erase-tools
|
2011-05-13 16:40:28 +02:00
|
|
|
|
2011-05-22 12:35:34 +02:00
|
|
|
# Clean build options (recommended for package testing only)
|
|
|
|
ifeq ($(CLEAN_BUILD), NO)
|
|
|
|
CLEAN_GROUND := NO
|
|
|
|
CLEAN_FLIGHT := YES
|
|
|
|
else ifeq ($(CLEAN_BUILD), NEVER)
|
|
|
|
CLEAN_GROUND := NO
|
|
|
|
CLEAN_FLIGHT := NO
|
|
|
|
else
|
|
|
|
CLEAN_GROUND := YES
|
|
|
|
CLEAN_FLIGHT := YES
|
|
|
|
endif
|
|
|
|
|
2011-06-19 15:26:14 +02:00
|
|
|
# Set up targets (PPM target seems to be broken at the moment)
|
|
|
|
FW_TARGETS_COMMON := $(addprefix fw_, ahrs pipxtreme)
|
|
|
|
FW_TARGETS_PWM := $(addprefix fw_, coptercontrol openpilot)
|
|
|
|
FW_TARGETS_DSM2 := $(addprefix fw_, coptercontrol openpilot)
|
|
|
|
FW_TARGETS_SBUS := $(addprefix fw_, coptercontrol)
|
|
|
|
FW_TARGETS_PPM := $(addprefix fw_, openpilot)
|
|
|
|
FW_TARGETS_TOOLS := $(addprefix fw_, coptercontrol)
|
|
|
|
BL_TARGETS := $(addprefix bl_, coptercontrol openpilot ahrs pipxtreme)
|
|
|
|
BU_TARGETS := $(addprefix bu_, coptercontrol openpilot ahrs pipxtreme)
|
2011-05-13 16:40:28 +02:00
|
|
|
|
|
|
|
help:
|
|
|
|
@echo
|
|
|
|
@echo " This Makefile is known to work on Linux and Mac in a standard shell environment."
|
|
|
|
@echo " It also works on Windows by following the instructions in ../make/winx86/README.txt."
|
|
|
|
@echo
|
|
|
|
@echo " Here is a summary of the available targets:"
|
|
|
|
@echo
|
2011-05-22 12:35:34 +02:00
|
|
|
@echo " [Packaging]"
|
2011-05-28 02:14:51 +02:00
|
|
|
@echo " package - Build and package the OpenPilot distributable"
|
|
|
|
@echo " package_flight - Build and package the OpenPilot flight firmware only"
|
2011-05-13 16:40:28 +02:00
|
|
|
@echo
|
|
|
|
@echo " Notes:"
|
2011-05-28 02:14:51 +02:00
|
|
|
@echo " - package will be placed in $(PACKAGE_DIR)"
|
2011-05-22 12:35:34 +02:00
|
|
|
@echo
|
|
|
|
@echo " - the build directory will be removed first on every run unless one"
|
|
|
|
@echo " of CLEAN_BUILD=NO or CLEAN_BUILD=NEVER options is defined."
|
|
|
|
@echo
|
|
|
|
@echo " CLEAN_BUILD=NO means no clean before build except for multi-input"
|
|
|
|
@echo " firmware binaries like CopterControl or OpenPilot. This usually is"
|
|
|
|
@echo " safe."
|
|
|
|
@echo
|
|
|
|
@echo " CLEAN_BUILD=NEVER means no clean will be done at all. This will,"
|
|
|
|
@echo " probably, give invalid multi-input firmware and is recommended"
|
|
|
|
@echo " for package testing only. Do not use for release builds."
|
2011-05-13 16:40:28 +02:00
|
|
|
@echo
|
|
|
|
|
|
|
|
# Clean and build uavobjects since all parts depend on them
|
|
|
|
uavobjects: all_clean
|
|
|
|
$(V1) $(MAKE) -C $(ROOT_DIR) $@
|
|
|
|
|
|
|
|
all_clean:
|
2011-05-22 12:35:34 +02:00
|
|
|
ifneq ($(CLEAN_GROUND), NO)
|
2011-05-13 16:40:28 +02:00
|
|
|
$(V1) $(MAKE) -C $(ROOT_DIR) $@
|
2011-05-15 13:54:24 +02:00
|
|
|
endif
|
2011-05-13 16:40:28 +02:00
|
|
|
|
|
|
|
# Install template:
|
|
|
|
# $1 = target
|
|
|
|
# $2 = dependencies
|
|
|
|
# $3 = install directory (must be defined)
|
|
|
|
# $4 = installed file name prefix (optional)
|
|
|
|
# $5 = installed file name suffix (optional)
|
|
|
|
# $6 = extra make options (for instance, USE_SPEKTRUM=YES)
|
2011-05-22 12:35:34 +02:00
|
|
|
# $7 = optional 'clean' string to clean target before rebuild
|
2011-05-13 16:40:28 +02:00
|
|
|
# $8 = list of targets to install (without _install suffix)
|
|
|
|
# $9 = inner make target (usually install, but can be other to just build)
|
|
|
|
define INSTALL_TEMPLATE
|
|
|
|
$(1): $(2)
|
2011-05-22 12:35:34 +02:00
|
|
|
ifeq ($(7),clean)
|
|
|
|
ifneq ($$(CLEAN_FLIGHT), NO)
|
2011-05-13 16:40:28 +02:00
|
|
|
$$(V1) +$(MAKE) -C $(ROOT_DIR) $(6) $(addsuffix _$(7), $(8))
|
2011-05-22 12:35:34 +02:00
|
|
|
endif
|
2011-05-13 16:40:28 +02:00
|
|
|
endif
|
|
|
|
$$(V1) +$(MAKE) -C $(ROOT_DIR) INSTALL_DIR=$(3) INSTALL_PFX=$(4) INSTALL_SFX=$(5) $(6) $(addsuffix _$(9), $(8))
|
|
|
|
.PHONY: $(1)
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Firmware for different input drivers
|
2011-05-28 02:14:51 +02:00
|
|
|
$(eval $(call INSTALL_TEMPLATE,fw_common,uavobjects,$(FW_DIR),,-$(PACKAGE_LBL),,,$(FW_TARGETS_COMMON),install))
|
2011-06-19 15:26:14 +02:00
|
|
|
$(eval $(call INSTALL_TEMPLATE,fw_pwm,uavobjects,$(FW_DIR),,-pwm-$(PACKAGE_LBL),,clean,$(FW_TARGETS_PWM),install))
|
|
|
|
$(eval $(call INSTALL_TEMPLATE,fw_dsm2,uavobjects,$(FW_DIR),,-dsm2sat-$(PACKAGE_LBL),USE_SPEKTRUM=YES,clean,$(FW_TARGETS_DSM2),install))
|
|
|
|
$(eval $(call INSTALL_TEMPLATE,fw_sbus,uavobjects,$(FW_DIR),,-sbus-$(PACKAGE_LBL),USE_SBUS=YES USE_TELEMETRY=3,clean,$(FW_TARGETS_SBUS),install))
|
|
|
|
$(eval $(call INSTALL_TEMPLATE,fw_ppm,uavobjects,$(FW_DIR),,-ppm-$(PACKAGE_LBL),USE_PPM=YES,clean,$(FW_TARGETS_PPM),install))
|
2011-05-13 16:40:28 +02:00
|
|
|
|
2011-05-24 23:44:45 +02:00
|
|
|
# Bootloaders (change 'install' to 'bin' if you don't want to install bootloaders)
|
2011-05-28 02:14:51 +02:00
|
|
|
$(eval $(call INSTALL_TEMPLATE,all_bl,uavobjects,$(BL_DIR),,-$(PACKAGE_LBL),,,$(BL_TARGETS),install))
|
2011-05-13 16:40:28 +02:00
|
|
|
|
2011-05-24 23:44:45 +02:00
|
|
|
# Bootloader updaters
|
2011-05-28 02:14:51 +02:00
|
|
|
$(eval $(call INSTALL_TEMPLATE,all_bu,all_bl,$(BU_DIR),,-$(PACKAGE_LBL),,,$(BU_TARGETS),install))
|
2011-05-13 16:40:28 +02:00
|
|
|
|
2011-05-17 20:29:22 +02:00
|
|
|
# CopterControl flash eraser tool
|
2011-05-28 02:14:51 +02:00
|
|
|
$(eval $(call INSTALL_TEMPLATE,fw_tools,uavobjects,$(FE_DIR),,-flash-erase-$(PACKAGE_LBL),ERASE_FLASH=YES,clean,$(FW_TARGETS_TOOLS),install))
|
2011-05-15 18:46:31 +02:00
|
|
|
|
2011-05-13 16:40:28 +02:00
|
|
|
# Order-only dependencies
|
2011-05-18 20:48:55 +02:00
|
|
|
# They are bit complicated to support parallel (-j) builds and to create
|
|
|
|
# the pwm/ppm/spektrum and CC flash eraser targets in some fixed order
|
2011-05-13 16:40:28 +02:00
|
|
|
|
2011-06-19 15:26:14 +02:00
|
|
|
fw_pwm: | # default dependencies, will be built first
|
2011-05-15 18:46:31 +02:00
|
|
|
|
2011-06-19 15:26:14 +02:00
|
|
|
fw_dsm2: | fw_pwm # ordered build
|
2011-05-15 18:46:31 +02:00
|
|
|
|
2011-06-19 15:26:14 +02:00
|
|
|
fw_sbus: | fw_dsm2 # ordered build
|
2011-05-13 16:40:28 +02:00
|
|
|
|
2011-06-19 15:26:14 +02:00
|
|
|
fw_ppm: | fw_sbus # ordered build
|
2011-05-13 16:40:28 +02:00
|
|
|
|
2011-06-19 15:26:14 +02:00
|
|
|
fw_tools: | fw_ppm # ordered build
|
|
|
|
|
|
|
|
package_fw: | fw_common fw_pwm fw_dsm2 fw_sbus fw_ppm
|
2011-05-13 16:40:28 +02:00
|
|
|
|
2011-05-28 02:14:51 +02:00
|
|
|
package_bu: | all_bu
|
2011-05-13 16:40:28 +02:00
|
|
|
|
2011-05-28 02:14:51 +02:00
|
|
|
package_flight: | package_fw package_bu fw_tools
|
2011-05-15 18:46:31 +02:00
|
|
|
|
2011-05-28 02:14:51 +02:00
|
|
|
package_ground: | ground_package
|
2011-05-13 16:40:28 +02:00
|
|
|
|
2011-05-28 02:14:51 +02:00
|
|
|
package: | package_flight package_ground
|
2011-05-15 18:46:31 +02:00
|
|
|
|
2011-05-28 02:14:51 +02:00
|
|
|
.PHONY: help uavobjects all_clean package package_flight package_fw package_bu package_ground
|
2011-05-13 16:40:28 +02:00
|
|
|
|
|
|
|
# Decide on a verbosity level based on the V= parameter
|
|
|
|
export AT := @
|
|
|
|
|
|
|
|
ifndef V
|
|
|
|
export V0 :=
|
|
|
|
export V1 := $(AT)
|
|
|
|
else ifeq ($(V), 0)
|
|
|
|
export V0 := $(AT)
|
|
|
|
export V1 := $(AT)
|
|
|
|
else ifeq ($(V), 1)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(V),1)
|
|
|
|
MAKEFLAGS += --no-print-directory
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Platform-dependent stuff
|
2011-05-18 21:03:10 +02:00
|
|
|
PLATFORM := winx86
|
2011-05-13 16:40:28 +02:00
|
|
|
UNAME := $(shell uname)
|
|
|
|
ifeq ($(UNAME), Linux)
|
|
|
|
PLATFORM := linux
|
|
|
|
endif
|
|
|
|
ifeq ($(UNAME), Darwin)
|
|
|
|
PLATFORM := osx
|
|
|
|
endif
|
|
|
|
|
|
|
|
include $(WHEREAMI)/Makefile.$(PLATFORM)
|