2010-09-03 01:55:24 +02:00
|
|
|
# Set up some macros for common directories within the tree
|
|
|
|
ROOT_DIR=$(CURDIR)
|
|
|
|
TOOLS_DIR=$(ROOT_DIR)/tools
|
|
|
|
BUILD_DIR=$(ROOT_DIR)/build
|
|
|
|
DL_DIR=$(ROOT_DIR)/downloads
|
|
|
|
|
|
|
|
# We almost need to consider autoconf/automake instead of this
|
|
|
|
# I don't know if windows supports uname :-(
|
2010-09-14 18:15:21 +02:00
|
|
|
QT_SPEC=win32-g++
|
2010-12-19 17:31:44 +01:00
|
|
|
UAVOBJGENERATOR="$(BUILD_DIR)/uavobjgenerator/debug/uavobjgenerator.exe"
|
2010-09-03 01:55:24 +02:00
|
|
|
UNAME := $(shell uname)
|
|
|
|
ifeq ($(UNAME), Linux)
|
|
|
|
QT_SPEC=linux-g++
|
2010-12-19 17:31:44 +01:00
|
|
|
UAVOBJGENERATOR="$(BUILD_DIR)/uavobjgenerator/uavobjgenerator"
|
2010-09-03 01:55:24 +02:00
|
|
|
endif
|
|
|
|
ifeq ($(UNAME), Darwin)
|
|
|
|
QT_SPEC=macx-g++
|
2010-12-19 17:31:44 +01:00
|
|
|
UAVOBJGENERATOR="$(BUILD_DIR)/uavobjgenerator/uavobjgenerator"
|
2010-09-03 01:55:24 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Set up misc host tools
|
|
|
|
RM=rm
|
|
|
|
|
|
|
|
.PHONY: areyousureyoushouldberunningthis
|
|
|
|
areyousureyoushouldberunningthis:
|
|
|
|
@echo
|
|
|
|
@echo " This Makefile is somewhat experimental and will probably only work on Linux right now."
|
|
|
|
@echo " If you're sure you want to be using this, you may wish to try the following targets:"
|
|
|
|
@echo
|
|
|
|
@echo " [Tool Installers]"
|
|
|
|
@echo " qt_sdk_install - Install the QT v4.6.2 tools"
|
|
|
|
@echo " arm_sdk_install - Install the Code Sourcery ARM gcc toolchain"
|
|
|
|
@echo " openocd_install - Install the OpenOCD JTAG daemon"
|
|
|
|
@echo
|
|
|
|
@echo " [Big Hammer]"
|
|
|
|
@echo " all - Generate UAVObjects, build openpilot firmware and gcs"
|
|
|
|
@echo " all_clean - Remove your build directory ($(BUILD_DIR))"
|
|
|
|
@echo
|
|
|
|
@echo " [Firmware]"
|
|
|
|
@echo " openpilot - Build firmware for the OpenPilot board"
|
|
|
|
@echo " openpilot_clean - Delete all build output for the OpenPilot firmware"
|
|
|
|
@echo " openpilot_program - Program the firmware onto the OpenPilot board"
|
|
|
|
@echo " ahrs - Build firmware for the AHRS board"
|
|
|
|
@echo " ahrs_clean - Delete all build output for the AHRS firmware"
|
|
|
|
@echo
|
|
|
|
@echo " [Simulation]"
|
|
|
|
@echo " sim_posix - Build OpenPilot simulation firmware for"
|
|
|
|
@echo " a POSIX compatible system (Linux, Mac OS X, ...)"
|
|
|
|
@echo " sim_posix_clean - Delete all build output for the POSIX simulation"
|
2010-12-18 19:41:37 +01:00
|
|
|
@echo " sim_win32 - Build OpenPilot simulation firmware for"
|
|
|
|
@echo " Windows using mingw and msys"
|
|
|
|
@echo " sim_win32_clean - Delete all build output for the win32 simulation"
|
2010-09-03 01:55:24 +02:00
|
|
|
@echo
|
|
|
|
@echo " [GCS and UAVObjects]"
|
|
|
|
@echo " gcs - Build the Ground Control System application"
|
2011-01-13 03:26:00 +01:00
|
|
|
@echo " uavobjects - Generate source files from the UAVObject definition XML files"
|
2011-01-16 02:45:42 +01:00
|
|
|
@echo " uavobjects_test - parse xml-files - check for valid, duplicate ObjId's, ... "
|
2011-01-13 03:26:00 +01:00
|
|
|
@echo " uavobjects_gcs - Generate groundstation source files from the UAVObject definition XML files"
|
|
|
|
@echo " uavobjects_flight - Generate flight source files from the UAVObject definition XML files"
|
2010-09-03 01:55:24 +02:00
|
|
|
@echo
|
|
|
|
@echo " Note: All tools will be installed into $(TOOLS_DIR)"
|
|
|
|
@echo " All build output will be placed in $(BUILD_DIR)"
|
|
|
|
@echo
|
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: uavobjects all_ground all_flight
|
|
|
|
|
|
|
|
.PHONY: all_clean
|
|
|
|
all_clean:
|
|
|
|
[ ! -d "$(BUILD_DIR)" ] || $(RM) -r "$(BUILD_DIR)"
|
|
|
|
|
|
|
|
$(DL_DIR):
|
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
$(TOOLS_DIR):
|
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
$(BUILD_DIR):
|
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
###############################################################
|
|
|
|
#
|
|
|
|
# Installers for tools required by the ground and flight builds
|
|
|
|
#
|
|
|
|
# NOTE: These are not tied to the default goals
|
|
|
|
# and must be invoked manually
|
|
|
|
#
|
|
|
|
###############################################################
|
|
|
|
|
|
|
|
# Set up QT toolchain
|
|
|
|
QT_SDK_DIR := $(TOOLS_DIR)/qtsdk-2010.02
|
|
|
|
|
|
|
|
.PHONY: qt_sdk_install
|
|
|
|
qt_sdk_install: QT_SDK_URL := http://get.qt.nokia.com/qtsdk/qt-sdk-linux-x86-opensource-2010.02.bin
|
|
|
|
qt_sdk_install: QT_SDK_FILE := $(notdir $(QT_SDK_URL))
|
|
|
|
qt_sdk_install: qt_sdk_clean $(TOOLS_DIR)
|
|
|
|
# download the source only if it's newer than what we already have
|
|
|
|
wget -N -P "$(DL_DIR)" "$(QT_SDK_URL)"
|
|
|
|
|
|
|
|
#installer is an executable, make it executable and run it
|
|
|
|
chmod u+x "$(DL_DIR)/$(QT_SDK_FILE)"
|
|
|
|
"$(DL_DIR)/$(QT_SDK_FILE)" --installdir "$(QT_SDK_DIR)"
|
|
|
|
|
|
|
|
.PHONY: qt_sdk_clean
|
|
|
|
qt_sdk_clean:
|
|
|
|
[ ! -d "$(QT_SDK_DIR)" ] || $(RM) -rf $(QT_SDK_DIR)
|
|
|
|
|
|
|
|
# Set up ARM (STM32) SDK
|
|
|
|
ARM_SDK_DIR := $(TOOLS_DIR)/arm-2009q3
|
|
|
|
|
|
|
|
.PHONY: arm_sdk_install
|
|
|
|
arm_sdk_install: ARM_SDK_URL := http://www.codesourcery.com/sgpp/lite/arm/portal/package5353/public/arm-none-eabi/arm-2009q3-68-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
|
|
|
|
arm_sdk_install: ARM_SDK_FILE := $(notdir $(ARM_SDK_URL))
|
|
|
|
arm_sdk_install: arm_sdk_clean $(TOOLS_DIR)
|
|
|
|
# download the source only if it's newer than what we already have
|
|
|
|
wget -N -P "$(DL_DIR)" "$(ARM_SDK_URL)"
|
|
|
|
|
|
|
|
# binary only release so just extract it
|
|
|
|
tar -C $(TOOLS_DIR) -xjf "$(DL_DIR)/$(ARM_SDK_FILE)"
|
|
|
|
|
|
|
|
.PHONY: arm_sdk_clean
|
|
|
|
arm_sdk_clean:
|
|
|
|
[ ! -d "$(ARM_SDK_DIR)" ] || $(RM) -r $(ARM_SDK_DIR)
|
|
|
|
|
|
|
|
# Set up openocd tools
|
|
|
|
OPENOCD_DIR := $(TOOLS_DIR)/openocd
|
|
|
|
|
|
|
|
.PHONY: openocd_install
|
|
|
|
openocd_install: OPENOCD_URL := http://sourceforge.net/projects/openocd/files/openocd/0.4.0/openocd-0.4.0.tar.bz2/download
|
|
|
|
openocd_install: OPENOCD_FILE := openocd-0.4.0.tar.bz2
|
|
|
|
openocd_install: openocd_clean $(TOOLS_DIR)
|
|
|
|
# download the source only if it's newer than what we already have
|
2011-01-20 03:57:40 +01:00
|
|
|
wget -N -P "$(DL_DIR)" --trust-server-name "$(OPENOCD_URL)"
|
2010-09-03 01:55:24 +02:00
|
|
|
|
|
|
|
# extract the source
|
|
|
|
[ ! -d "$(DL_DIR)/openocd-build" ] || $(RM) -r "$(DL_DIR)/openocd-build"
|
|
|
|
mkdir -p "$(DL_DIR)/openocd-build"
|
|
|
|
tar -C $(DL_DIR)/openocd-build -xjf "$(DL_DIR)/$(OPENOCD_FILE)"
|
|
|
|
|
|
|
|
# build and install
|
|
|
|
mkdir -p "$(OPENOCD_DIR)"
|
|
|
|
( \
|
|
|
|
cd $(DL_DIR)/openocd-build/openocd-0.4.0 ; \
|
|
|
|
./configure --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi ; \
|
2010-11-05 03:01:14 +01:00
|
|
|
$(MAKE) ; \
|
|
|
|
$(MAKE) install ; \
|
2010-09-03 01:55:24 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# delete the extracted source when we're done
|
|
|
|
[ ! -d "$(DL_DIR)/openocd-build" ] || $(RM) -r "$(DL_DIR)/openocd-build"
|
|
|
|
|
|
|
|
.PHONY: openocd_clean
|
|
|
|
openocd_clean:
|
|
|
|
[ ! -d "$(OPENOCD_DIR)" ] || $(RM) -r "$(OPENOCD_DIR)"
|
|
|
|
|
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Set up paths to tools
|
|
|
|
#
|
|
|
|
##############################
|
|
|
|
|
|
|
|
ifeq ($(shell [ -d "$(QT_SDK_DIR)" ] && echo "exists"), exists)
|
|
|
|
QMAKE=$(QT_SDK_DIR)/qt/bin/qmake
|
|
|
|
else
|
|
|
|
# not installed, hope it's in the path...
|
|
|
|
QMAKE=qmake
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(shell [ -d "$(ARM_SDK_DIR)" ] && echo "exists"), exists)
|
|
|
|
ARM_SDK_PREFIX := $(ARM_SDK_DIR)/bin/arm-none-eabi-
|
|
|
|
else
|
|
|
|
# not installed, hope it's in the path...
|
|
|
|
ARM_SDK_PREFIX ?= arm-none-eabi-
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(shell [ -d "$(OPENOCD_DIR)" ] && echo "exists"), exists)
|
|
|
|
OPENOCD := $(OPENOCD_DIR)/bin/openocd
|
|
|
|
else
|
|
|
|
# not installed, hope it's in the path...
|
|
|
|
OPENOCD ?= openocd
|
|
|
|
endif
|
|
|
|
|
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# GCS related components
|
|
|
|
#
|
|
|
|
##############################
|
|
|
|
|
|
|
|
.PHONY: all_ground
|
|
|
|
all_ground: uavobjgenerator openpilotgcs
|
|
|
|
|
|
|
|
# Convenience target for the GCS
|
|
|
|
.PHONY: gcs
|
|
|
|
gcs: openpilotgcs
|
|
|
|
|
|
|
|
.PHONY: openpilotgcs
|
2011-01-13 03:26:00 +01:00
|
|
|
openpilotgcs: uavobjects_gcs
|
2010-09-03 01:55:24 +02:00
|
|
|
mkdir -p $(BUILD_DIR)/$@
|
|
|
|
( cd $(BUILD_DIR)/$@ ; \
|
|
|
|
$(QMAKE) $(ROOT_DIR)/ground/openpilotgcs.pro -spec $(QT_SPEC) -r CONFIG+=debug ; \
|
2010-11-05 03:01:14 +01:00
|
|
|
$(MAKE) -w ; \
|
2010-09-03 01:55:24 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
.PHONY: uavobjgenerator
|
|
|
|
uavobjgenerator:
|
|
|
|
mkdir -p $(BUILD_DIR)/$@
|
|
|
|
( cd $(BUILD_DIR)/$@ ; \
|
|
|
|
$(QMAKE) $(ROOT_DIR)/ground/src/libs/uavobjgenerator/uavobjgenerator.pro -spec $(QT_SPEC) -r CONFIG+=debug ; \
|
2010-11-05 03:01:14 +01:00
|
|
|
$(MAKE) -w ; \
|
2010-09-03 01:55:24 +02:00
|
|
|
)
|
|
|
|
|
2011-01-13 03:26:00 +01:00
|
|
|
.PHONY: build_dir
|
|
|
|
bzild_dir:
|
2010-09-03 01:55:24 +02:00
|
|
|
mkdir -p $(BUILD_DIR)/$@
|
2011-01-13 03:26:00 +01:00
|
|
|
|
|
|
|
.PHONY:uavobjects
|
|
|
|
uavobjects: build_dir uavobjgenerator
|
2010-12-19 17:31:44 +01:00
|
|
|
$(UAVOBJGENERATOR) "$(ROOT_DIR)/"
|
2010-09-03 01:55:24 +02:00
|
|
|
|
2011-01-13 03:26:00 +01:00
|
|
|
uavobjects_gcs: build_dir uavobjgenerator
|
|
|
|
$(UAVOBJGENERATOR) -gcs "$(ROOT_DIR)/"
|
|
|
|
|
|
|
|
uavobjects_flight: build_dir uavobjgenerator
|
|
|
|
$(UAVOBJGENERATOR) -flight "$(ROOT_DIR)/"
|
|
|
|
|
2011-01-16 02:45:42 +01:00
|
|
|
uavobjects_test: build_dir uavobjgenerator
|
|
|
|
$(UAVOBJGENERATOR) -v -none "$(ROOT_DIR)/"
|
|
|
|
|
2010-09-03 01:55:24 +02:00
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Flight related components
|
|
|
|
#
|
|
|
|
##############################
|
|
|
|
|
|
|
|
.PHONY: all_flight
|
|
|
|
all_flight: openpilot_elf ahrs_elf
|
|
|
|
|
|
|
|
.PHONY: openpilot
|
|
|
|
openpilot: openpilot_elf
|
|
|
|
|
2011-01-13 03:26:00 +01:00
|
|
|
openpilot_%: uavobjects_flight
|
2010-09-03 01:55:24 +02:00
|
|
|
mkdir -p $(BUILD_DIR)/openpilot
|
2010-11-05 03:01:14 +01:00
|
|
|
$(MAKE) OUTDIR="$(BUILD_DIR)/openpilot" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" -C $(ROOT_DIR)/flight/OpenPilot $*
|
2010-09-03 01:55:24 +02:00
|
|
|
|
|
|
|
.PHONY: ahrs
|
|
|
|
ahrs: ahrs_elf
|
|
|
|
|
|
|
|
ahrs_%:
|
|
|
|
mkdir -p $(BUILD_DIR)/ahrs
|
2010-11-05 03:01:14 +01:00
|
|
|
$(MAKE) OUTDIR="$(BUILD_DIR)/ahrs" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" -C $(ROOT_DIR)/flight/AHRS $*
|
2010-09-03 01:55:24 +02:00
|
|
|
|
2011-01-14 02:38:24 +01:00
|
|
|
.PHONY: coptercontrol
|
|
|
|
coptercontrol: coptercontrol_elf
|
|
|
|
|
|
|
|
coptercontrol_%: uavobjects
|
|
|
|
mkdir -p $(BUILD_DIR)/coptercontrol
|
|
|
|
$(MAKE) OUTDIR="$(BUILD_DIR)/coptercontrol" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" -C $(ROOT_DIR)/flight/CopterControl $*
|
|
|
|
|
2011-01-14 02:48:50 +01:00
|
|
|
.PHONY: pipxtreme
|
|
|
|
pipxtreme: pipxtreme_elf
|
|
|
|
|
|
|
|
pipxtreme_%: uavobjects_flight
|
|
|
|
mkdir -p $(BUILD_DIR)/pipxtreme
|
|
|
|
$(MAKE) OUTDIR="$(BUILD_DIR)/pipxtreme" TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" -C $(ROOT_DIR)/flight/PipXtreme $*
|
|
|
|
|
2010-09-03 01:55:24 +02:00
|
|
|
.PHONY: sim_posix
|
|
|
|
sim_posix: sim_posix_elf
|
|
|
|
|
2011-01-13 03:26:00 +01:00
|
|
|
sim_posix_%: uavobjects_flight
|
2010-09-03 01:55:24 +02:00
|
|
|
mkdir -p $(BUILD_DIR)/simulation
|
2010-11-05 03:01:14 +01:00
|
|
|
$(MAKE) OUTDIR="$(BUILD_DIR)/simulation" -C $(ROOT_DIR)/flight/OpenPilot --file=$(ROOT_DIR)/flight/OpenPilot/Makefile.posix $*
|
2010-09-03 01:55:24 +02:00
|
|
|
|
2010-12-18 19:41:37 +01:00
|
|
|
.PHONY: sim_win32
|
|
|
|
sim_win32: sim_win32_exe
|
|
|
|
|
2011-01-13 03:26:00 +01:00
|
|
|
sim_win32_%: uavobjects_flight
|
2010-12-18 19:41:37 +01:00
|
|
|
mkdir -p $(BUILD_DIR)/simulation
|
|
|
|
$(MAKE) OUTDIR="$(BUILD_DIR)/simulation" -C $(ROOT_DIR)/flight/OpenPilot --file=$(ROOT_DIR)/flight/OpenPilot/Makefile.win32 $*
|