2010-07-03 23:50:13 +02:00
|
|
|
#####
|
|
|
|
# Project: OpenPilot
|
2011-01-16 16:17:57 +01:00
|
|
|
#
|
|
|
|
#
|
2010-07-03 23:50:13 +02:00
|
|
|
# Makefile for OpenPilot project build PiOS and the AP.
|
|
|
|
#
|
|
|
|
# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009.
|
2011-01-16 16:17:57 +01:00
|
|
|
#
|
2010-07-03 23:50:13 +02:00
|
|
|
#
|
2011-01-16 16:17:57 +01:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2010-07-03 23:50:13 +02:00
|
|
|
# (at your option) any later version.
|
2011-01-16 16:17:57 +01:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
2010-07-03 23:50:13 +02:00
|
|
|
# for more details.
|
2011-01-16 16:17:57 +01:00
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-07-03 23:50:13 +02:00
|
|
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#####
|
|
|
|
|
|
|
|
|
|
|
|
# Set developer code and compile options
|
|
|
|
# Set to YES to compile for debugging
|
|
|
|
DEBUG ?= YES
|
|
|
|
|
|
|
|
# Set to YES to use the Servo output pins for debugging via scope or logic analyser
|
|
|
|
ENABLE_DEBUG_PINS ?= NO
|
|
|
|
|
2011-01-16 16:17:57 +01:00
|
|
|
# Set to Yes to enable the AUX UART which is mapped on the S1 (Tx) and S2 (Rx) servo outputs
|
2010-07-03 23:50:13 +02:00
|
|
|
ENABLE_AUX_UART ?= NO
|
|
|
|
|
|
|
|
#
|
|
|
|
USE_BOOTLOADER ?= NO
|
|
|
|
|
|
|
|
|
|
|
|
# Set to YES when using Code Sourcery toolchain
|
|
|
|
CODE_SOURCERY ?= NO
|
|
|
|
|
|
|
|
# Toolchain prefix (i.e arm-elf- -> arm-elf-gcc.exe)
|
|
|
|
TCHAIN_PREFIX ?= ""
|
|
|
|
|
|
|
|
# Remove command is different for Code Sourcery on Windows
|
|
|
|
REMOVE_CMD ?= rm
|
|
|
|
|
|
|
|
FLASH_TOOL = OPENOCD
|
|
|
|
|
2011-01-16 16:17:57 +01:00
|
|
|
# YES enables -mthumb option to flags for source-files listed
|
2010-07-03 23:50:13 +02:00
|
|
|
# in SRC and CPPSRC
|
|
|
|
USE_THUMB_MODE = YES
|
|
|
|
|
|
|
|
# List of modules to include
|
2010-12-20 17:38:17 +01:00
|
|
|
MODULES = Telemetry Actuator Stabilization Guidance ManualControl
|
|
|
|
#MODULES = Telemetry ManualControl Actuator Attitude Stabilization
|
2010-07-03 23:50:13 +02:00
|
|
|
#MODULES = Telemetry Example
|
|
|
|
#MODULES = Telemetry MK/MKSerial
|
|
|
|
|
|
|
|
#MODULES += Osd/OsdEtStd
|
|
|
|
|
|
|
|
|
|
|
|
# MCU name, submodel and board
|
2010-07-04 11:27:53 +02:00
|
|
|
# - MCU used for compiler-option (-mtune)
|
2010-07-03 23:50:13 +02:00
|
|
|
# - MODEL used for linker-script name (-T) and passed as define
|
|
|
|
# - BOARD just passed as define (optional)
|
|
|
|
MCU = i686
|
|
|
|
#CHIP = STM32F103RET
|
|
|
|
#BOARD = STM3210E_OP
|
2011-01-16 16:17:57 +01:00
|
|
|
MODEL = HD
|
2010-07-03 23:50:13 +02:00
|
|
|
ifeq ($(USE_BOOTLOADER), YES)
|
2011-01-16 16:17:57 +01:00
|
|
|
BOOT_MODEL = $(MODEL)_BL
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
else
|
2011-01-16 16:17:57 +01:00
|
|
|
BOOT_MODEL = $(MODEL)_NB
|
2010-07-03 23:50:13 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.)
|
2011-01-28 12:44:37 +01:00
|
|
|
OUTDIR = ../../build/sitl_posix
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
# Target file name (without extension).
|
|
|
|
TARGET = OpenPilot
|
|
|
|
|
|
|
|
# Paths
|
|
|
|
OPSYSTEM = ./System
|
|
|
|
OPSYSTEMINC = $(OPSYSTEM)/inc
|
2011-01-16 16:17:57 +01:00
|
|
|
OPUAVTALK = ../UAVTalk
|
2010-07-03 23:50:13 +02:00
|
|
|
OPUAVTALKINC = $(OPUAVTALK)/inc
|
2011-01-16 16:17:57 +01:00
|
|
|
OPUAVOBJ = ../UAVObjects
|
2010-07-03 23:50:13 +02:00
|
|
|
OPUAVOBJINC = $(OPUAVOBJ)/inc
|
|
|
|
OPTESTS = ./Tests
|
2011-01-16 16:17:57 +01:00
|
|
|
OPMODULEDIR = ../Modules
|
|
|
|
FLIGHTLIB = ../Libraries
|
|
|
|
FLIGHTLIBINC = $(FLIGHTLIB)/inc
|
2010-07-03 23:50:13 +02:00
|
|
|
PIOS = ../PiOS.posix
|
|
|
|
PIOSINC = $(PIOS)/inc
|
|
|
|
PIOSPOSIX = $(PIOS)/posix
|
|
|
|
APPLIBDIR = $(PIOSPOSIX)/Libraries
|
|
|
|
RTOSDIR = $(APPLIBDIR)/FreeRTOS
|
|
|
|
RTOSSRCDIR = $(RTOSDIR)/Source
|
|
|
|
RTOSINCDIR = $(RTOSSRCDIR)/include
|
|
|
|
DOXYGENDIR = ../Doc/Doxygen
|
2011-01-16 16:17:57 +01:00
|
|
|
AHRSBOOTLOADER = ../Bootloaders/AHRS/
|
|
|
|
AHRSBOOTLOADERINC = $(AHRSBOOTLOADER)/inc
|
|
|
|
PYMITE = $(FLIGHTLIB)/PyMite
|
|
|
|
PYMITELIB = $(PYMITE)/lib
|
2011-01-17 01:04:16 +01:00
|
|
|
PYMITEPLAT = $(PYMITE)/platform/openpilot_sitl
|
2011-01-16 16:17:57 +01:00
|
|
|
PYMITETOOLS = $(PYMITE)/tools
|
|
|
|
PYMITEVM = $(PYMITE)/vm
|
|
|
|
PYMITEINC = $(PYMITEVM)
|
|
|
|
PYMITEINC += $(PYMITEPLAT)
|
|
|
|
PYMITEINC += $(OUTDIR)
|
|
|
|
FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib
|
|
|
|
FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans
|
2010-07-03 23:50:13 +02:00
|
|
|
|
2011-01-28 12:44:37 +01:00
|
|
|
OPUAVSYNTHDIR = $(OUTDIR)/../uavobject-synthetics/flight
|
|
|
|
|
2010-07-03 23:50:13 +02:00
|
|
|
# List C source files here. (C dependencies are automatically generated.)
|
|
|
|
# use file-extension c for "c-only"-files
|
|
|
|
|
2011-01-16 16:17:57 +01:00
|
|
|
MODNAMES = $(notdir ${MODULES})
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
ifndef TESTAPP
|
2011-01-28 12:44:37 +01:00
|
|
|
|
|
|
|
## PyMite files
|
|
|
|
SRC += $(OUTDIR)/pmlib_img.c
|
|
|
|
SRC += $(OUTDIR)/pmlib_nat.c
|
|
|
|
SRC += $(OUTDIR)/pmlibusr_img.c
|
|
|
|
SRC += $(OUTDIR)/pmlibusr_nat.c
|
|
|
|
SRC += $(wildcard ${PYMITEVM}/*.c)
|
|
|
|
SRC += $(wildcard ${PYMITEPLAT}/*.c)
|
|
|
|
|
2010-07-03 23:50:13 +02:00
|
|
|
## MODULES
|
|
|
|
SRC += ${foreach MOD, ${MODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}}
|
|
|
|
SRC += ${OUTDIR}/InitMods.c
|
|
|
|
## OPENPILOT CORE:
|
|
|
|
SRC += ${OPMODULEDIR}/System/systemmod.c
|
|
|
|
SRC += $(OPSYSTEM)/openpilot.c
|
|
|
|
SRC += $(OPSYSTEM)/pios_board_posix.c
|
|
|
|
SRC += $(OPSYSTEM)/alarms.c
|
2011-01-16 16:17:57 +01:00
|
|
|
SRC += $(OPSYSTEM)/taskmonitor.c
|
2010-07-03 23:50:13 +02:00
|
|
|
SRC += $(OPUAVTALK)/uavtalk.c
|
|
|
|
SRC += $(OPUAVOBJ)/uavobjectmanager.c
|
|
|
|
SRC += $(OPUAVOBJ)/eventdispatcher.c
|
2011-02-01 16:46:59 +01:00
|
|
|
SRC += $(OPUAVSYNTHDIR)/init/uavobjectsinit.c
|
2010-07-03 23:50:13 +02:00
|
|
|
else
|
|
|
|
## TESTCODE
|
|
|
|
SRC += $(OPTESTS)/test_common.c
|
|
|
|
SRC += $(OPTESTS)/$(TESTAPP).c
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## UAVOBJECTS
|
|
|
|
ifndef TESTAPP
|
2011-01-28 21:19:53 +01:00
|
|
|
SRC += $(wildcard $(OPUAVSYNTHDIR)/*.c)
|
2010-07-03 23:50:13 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
## PIOS Hardware (posix)
|
|
|
|
SRC += $(PIOSPOSIX)/pios_sys.c
|
|
|
|
SRC += $(PIOSPOSIX)/pios_led.c
|
|
|
|
SRC += $(PIOSPOSIX)/pios_delay.c
|
|
|
|
SRC += $(PIOSPOSIX)/pios_sdcard.c
|
|
|
|
SRC += $(PIOSPOSIX)/pios_udp.c
|
|
|
|
SRC += $(PIOSPOSIX)/pios_com.c
|
2010-12-31 20:31:55 +01:00
|
|
|
SRC += $(PIOSPOSIX)/pios_servo.c
|
2011-01-16 16:17:57 +01:00
|
|
|
SRC += $(PIOSPOSIX)/pios_wdg.c
|
|
|
|
|
|
|
|
## Libraries for flight calculations
|
|
|
|
#SRC += $(FLIGHTLIB)/fifo_buffer.c
|
|
|
|
SRC += $(FLIGHTLIB)/WorldMagModel.c
|
|
|
|
SRC += $(FLIGHTLIB)/CoordinateConversions.c
|
2011-01-28 13:26:45 +01:00
|
|
|
## RTOS and RTOS Portable
|
2011-01-16 16:17:57 +01:00
|
|
|
SRC += $(RTOSSRCDIR)/list.c
|
|
|
|
SRC += $(RTOSSRCDIR)/queue.c
|
2011-01-28 13:26:45 +01:00
|
|
|
UNAME := $(shell uname)
|
|
|
|
ifeq ($(UNAME), Linux)
|
|
|
|
SRC += $(RTOSSRCDIR)/tasks_linux.c
|
|
|
|
SRC += $(RTOSSRCDIR)/portable/GCC/Posix/port_linux.c
|
|
|
|
else
|
|
|
|
SRC += $(RTOSSRCDIR)/tasks_posix.c
|
|
|
|
SRC += $(RTOSSRCDIR)/portable/GCC/Posix/port_posix.c
|
|
|
|
endif
|
2010-07-03 23:50:13 +02:00
|
|
|
SRC += $(RTOSSRCDIR)/portable/MemMang/heap_3.c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# List C source files here which must be compiled in ARM-Mode (no -mthumb).
|
|
|
|
# use file-extension c for "c-only"-files
|
|
|
|
## just for testing, timer.c could be compiled in thumb-mode too
|
2011-01-16 16:17:57 +01:00
|
|
|
SRCARM =
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
# List C++ source files here.
|
|
|
|
# use file-extension .cpp for C++-files (not .C)
|
2011-01-16 16:17:57 +01:00
|
|
|
CPPSRC =
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
# List C++ source files here which must be compiled in ARM-Mode.
|
|
|
|
# use file-extension .cpp for C++-files (not .C)
|
|
|
|
#CPPSRCARM = $(TARGET).cpp
|
2011-01-16 16:17:57 +01:00
|
|
|
CPPSRCARM =
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
# List any extra directories to look for include files here.
|
|
|
|
# Each directory must be seperated by a space.
|
|
|
|
EXTRAINCDIRS = $(OPSYSTEM)
|
|
|
|
EXTRAINCDIRS += $(OPSYSTEMINC)
|
|
|
|
EXTRAINCDIRS += $(OPUAVTALK)
|
|
|
|
EXTRAINCDIRS += $(OPUAVTALKINC)
|
|
|
|
EXTRAINCDIRS += $(OPUAVOBJ)
|
|
|
|
EXTRAINCDIRS += $(OPUAVOBJINC)
|
2011-01-28 12:44:37 +01:00
|
|
|
EXTRAINCDIRS += $(OPUAVSYNTHDIR)
|
2010-07-03 23:50:13 +02:00
|
|
|
EXTRAINCDIRS += $(PIOS)
|
|
|
|
EXTRAINCDIRS += $(PIOSINC)
|
2011-01-16 16:17:57 +01:00
|
|
|
EXTRAINCDIRS += $(FLIGHTLIBINC)
|
2010-07-03 23:50:13 +02:00
|
|
|
EXTRAINCDIRS += $(PIOSPOSIX)
|
|
|
|
EXTRAINCDIRS += $(RTOSINCDIR)
|
|
|
|
EXTRAINCDIRS += $(APPLIBDIR)
|
|
|
|
EXTRAINCDIRS += $(RTOSSRCDIR)/portable/GCC/Posix
|
2011-01-28 12:44:37 +01:00
|
|
|
EXTRAINCDIRS += $(PYMITEINC)
|
2010-07-03 23:50:13 +02:00
|
|
|
|
2011-01-16 16:17:57 +01:00
|
|
|
EXTRAINCDIRS += ${foreach MOD, ${MODULES}, $(OPMODULEDIR)/${MOD}/inc} ${OPMODULEDIR}/System/inc
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
# List any extra directories to look for library files here.
|
|
|
|
# Also add directories where the linker should search for
|
|
|
|
# includes from linker-script to the list
|
|
|
|
# Each directory must be seperated by a space.
|
2011-01-16 16:17:57 +01:00
|
|
|
EXTRA_LIBDIRS =
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
# Extra Libraries
|
|
|
|
# Each library-name must be seperated by a space.
|
2011-01-16 16:17:57 +01:00
|
|
|
# i.e. to link with libxyz.a, libabc.a and libefsl.a:
|
2010-07-03 23:50:13 +02:00
|
|
|
# EXTRA_LIBS = xyz abc efsl
|
|
|
|
# for newlib-lpc (file: libnewlibc-lpc.a):
|
|
|
|
# EXTRA_LIBS = newlib-lpc
|
|
|
|
EXTRA_LIBS =
|
|
|
|
|
|
|
|
# Path to Linker-Scripts
|
|
|
|
LINKERSCRIPTPATH = $(PIOSSTM32F10X)
|
|
|
|
|
2011-01-16 16:17:57 +01:00
|
|
|
# Optimization level, can be [0, 1, 2, 3, s].
|
2010-07-03 23:50:13 +02:00
|
|
|
# 0 = turn off optimization. s = optimize for size.
|
|
|
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
|
|
|
|
|
|
|
ifeq ($(DEBUG),YES)
|
|
|
|
OPT = 0
|
|
|
|
else
|
|
|
|
OPT = s
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Output format. (can be ihex or binary or both)
|
2011-01-16 16:17:57 +01:00
|
|
|
# binary to create a load-image in raw-binary format i.e. for SAM-BA,
|
2010-07-03 23:50:13 +02:00
|
|
|
# ihex to create a load-image in Intel hex format
|
|
|
|
#LOADFORMAT = ihex
|
|
|
|
#LOADFORMAT = binary
|
|
|
|
LOADFORMAT = both
|
|
|
|
|
|
|
|
# Debugging format.
|
|
|
|
#DEBUGF = dwarf-2
|
|
|
|
|
2011-01-16 16:17:57 +01:00
|
|
|
# Place project-specific -D (define) and/or
|
2010-07-03 23:50:13 +02:00
|
|
|
# -U options for C here.
|
|
|
|
ifeq ($(ENABLE_DEBUG_PINS), YES)
|
|
|
|
CDEFS += -DPIOS_ENABLE_DEBUG_PINS
|
|
|
|
endif
|
|
|
|
ifeq ($(ENABLE_AUX_UART), YES)
|
|
|
|
CDEFS += -DPIOS_ENABLE_AUX_UART
|
|
|
|
endif
|
|
|
|
ifeq ($(USE_BOOTLOADER), YES)
|
|
|
|
CDEFS += -DUSE_BOOTLOADER
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Compiler flag to set the C Standard level.
|
|
|
|
# c89 - "ANSI" C
|
|
|
|
# gnu89 - c89 plus GCC extensions
|
|
|
|
# c99 - ISO C99 standard (not yet fully implemented)
|
|
|
|
# gnu99 - c99 plus GCC extensions
|
|
|
|
CSTANDARD = -std=gnu99
|
|
|
|
|
|
|
|
#-----
|
|
|
|
|
|
|
|
# Compiler flags.
|
|
|
|
|
|
|
|
# -g*: generate debugging information
|
|
|
|
# -O*: optimization level
|
|
|
|
# -f...: tuning, see GCC manual and avr-libc documentation
|
|
|
|
# -Wall...: warning level
|
|
|
|
# -Wa,...: tell GCC to pass this to the assembler.
|
|
|
|
# -adhlns...: create assembler listing
|
|
|
|
#
|
|
|
|
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
|
|
|
|
|
|
|
|
ifeq ($(DEBUG),YES)
|
|
|
|
CFLAGS = -g$(DEBUGF) -DDEBUG
|
|
|
|
endif
|
|
|
|
|
|
|
|
CFLAGS += -DARCH_POSIX
|
|
|
|
CFLAGS += -O$(OPT)
|
2010-07-04 11:27:53 +02:00
|
|
|
CFLAGS += -mtune=$(MCU)
|
2010-07-03 23:50:13 +02:00
|
|
|
CFLAGS += $(CDEFS)
|
|
|
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
|
|
|
|
|
|
|
CFLAGS += -fomit-frame-pointer
|
|
|
|
ifeq ($(CODE_SOURCERY), YES)
|
|
|
|
CFLAGS += -fpromote-loop-indices
|
|
|
|
endif
|
|
|
|
|
2011-01-16 16:17:57 +01:00
|
|
|
CFLAGS += -Wall
|
2010-07-03 23:50:13 +02:00
|
|
|
CFLAGS += -Werror
|
|
|
|
# Compiler flags to generate dependency files:
|
|
|
|
CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d
|
|
|
|
|
|
|
|
# flags only for C
|
2011-01-16 16:17:57 +01:00
|
|
|
#CONLYFLAGS += -Wnested-externs
|
2010-07-03 23:50:13 +02:00
|
|
|
CONLYFLAGS += $(CSTANDARD)
|
|
|
|
|
|
|
|
# Assembler flags.
|
|
|
|
# -Wa,...: tell GCC to pass this to the assembler.
|
|
|
|
# -ahlns: create listing
|
2010-07-04 11:27:53 +02:00
|
|
|
ASFLAGS = -mtune=$(MCU) -I. -x assembler-with-cpp
|
2010-07-03 23:50:13 +02:00
|
|
|
ASFLAGS += $(ADEFS)
|
|
|
|
ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
|
|
|
|
ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|
|
|
|
|
|
|
MATH_LIB = -lm
|
|
|
|
|
|
|
|
# Linker flags.
|
|
|
|
# -Wl,...: tell GCC to pass this to linker.
|
|
|
|
# -Map: create map file
|
|
|
|
# --cref: add cross reference to map file
|
|
|
|
LDFLAGS += -lpthread
|
|
|
|
LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS))
|
|
|
|
LDFLAGS += -lc
|
|
|
|
LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS))
|
|
|
|
LDFLAGS += $(MATH_LIB)
|
2011-01-16 16:17:57 +01:00
|
|
|
LDFLAGS += -lc -lgcc
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Define programs and commands.
|
|
|
|
CC = $(TCHAIN_PREFIX)gcc
|
|
|
|
CPP = $(TCHAIN_PREFIX)g++
|
|
|
|
AR = $(TCHAIN_PREFIX)ar
|
|
|
|
OBJCOPY = $(TCHAIN_PREFIX)objcopy
|
|
|
|
OBJDUMP = $(TCHAIN_PREFIX)objdump
|
|
|
|
SIZE = $(TCHAIN_PREFIX)size
|
|
|
|
NM = $(TCHAIN_PREFIX)nm
|
|
|
|
REMOVE = $(REMOVE_CMD) -f
|
2011-01-16 16:17:57 +01:00
|
|
|
PYTHON = python
|
2010-07-03 23:50:13 +02:00
|
|
|
###SHELL = sh
|
|
|
|
###COPY = cp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Define Messages
|
|
|
|
# English
|
|
|
|
MSG_ERRORS_NONE = Errors: none
|
|
|
|
MSG_BEGIN = ${quote}-------- begin (mode: $(RUN_MODE)) --------${quote}
|
|
|
|
MSG_END = ${quote}-------- end --------${quote}
|
|
|
|
MSG_MODINIT = ${quote}**** Generating ModInit.c${quote}
|
2011-01-16 16:17:57 +01:00
|
|
|
MSG_SIZE_BEFORE = ${quote}Size before:${quote}
|
2010-07-03 23:50:13 +02:00
|
|
|
MSG_SIZE_AFTER = ${quote}Size after build:${quote}
|
|
|
|
MSG_LOAD_FILE = ${quote}Creating load file:${quote}
|
|
|
|
MSG_EXTENDED_LISTING = ${quote}Creating Extended Listing/Disassembly:${quote}
|
|
|
|
MSG_SYMBOL_TABLE = ${quote}Creating Symbol Table:${quote}
|
|
|
|
MSG_LINKING = ${quote}**** Linking :${quote}
|
|
|
|
MSG_COMPILING = ${quote}**** Compiling C :${quote}
|
|
|
|
MSG_COMPILING_ARM = ${quote}**** Compiling C (ARM-only):${quote}
|
|
|
|
MSG_COMPILINGCPP = ${quote}Compiling C++ :${quote}
|
|
|
|
MSG_COMPILINGCPP_ARM = ${quote}Compiling C++ (ARM-only):${quote}
|
|
|
|
MSG_ASSEMBLING = ${quote}**** Assembling:${quote}
|
|
|
|
MSG_ASSEMBLING_ARM = ${quote}****Assembling (ARM-only):${quote}
|
|
|
|
MSG_CLEANING = ${quote}Cleaning project:${quote}
|
|
|
|
MSG_FORMATERROR = ${quote}Can not handle output-format${quote}
|
|
|
|
MSG_ASMFROMC = ${quote}Creating asm-File from C-Source:${quote}
|
|
|
|
MSG_ASMFROMC_ARM = ${quote}Creating asm-File from C-Source (ARM-only):${quote}
|
2011-01-16 16:17:57 +01:00
|
|
|
MSG_PYMITEINIT = ${quote}**** Generating PyMite intermediate code${quote}
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
# List of all source files.
|
|
|
|
ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC)
|
|
|
|
# List of all source files without directory and file-extension.
|
|
|
|
ALLSRCBASE = $(notdir $(basename $(ALLSRC)))
|
|
|
|
|
|
|
|
# Define all object files.
|
|
|
|
ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE)))
|
|
|
|
|
|
|
|
# Define all listing files (used for make clean).
|
|
|
|
LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE)))
|
|
|
|
# Define all depedency-files (used for make clean).
|
|
|
|
DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE)))
|
|
|
|
|
2011-01-16 16:17:57 +01:00
|
|
|
elf: $(OUTDIR)/$(TARGET).elf
|
2010-07-03 23:50:13 +02:00
|
|
|
lss: $(OUTDIR)/$(TARGET).lss
|
|
|
|
sym: $(OUTDIR)/$(TARGET).sym
|
|
|
|
hex: $(OUTDIR)/$(TARGET).hex
|
|
|
|
bin: $(OUTDIR)/$(TARGET).bin
|
|
|
|
|
|
|
|
# Default target.
|
|
|
|
#all: begin gccversion sizebefore build sizeafter finished end
|
2011-01-16 16:17:57 +01:00
|
|
|
#all: begin gencode gccversion build sizeafter finished end
|
2010-07-03 23:50:13 +02:00
|
|
|
all: elf
|
|
|
|
|
|
|
|
ifeq ($(LOADFORMAT),ihex)
|
|
|
|
build: elf hex lss sym
|
2011-01-16 16:17:57 +01:00
|
|
|
else
|
2010-07-03 23:50:13 +02:00
|
|
|
ifeq ($(LOADFORMAT),binary)
|
|
|
|
build: elf bin lss sym
|
2011-01-16 16:17:57 +01:00
|
|
|
else
|
2010-07-03 23:50:13 +02:00
|
|
|
ifeq ($(LOADFORMAT),both)
|
|
|
|
build: elf hex bin lss sym
|
2011-01-16 16:17:57 +01:00
|
|
|
else
|
2010-07-03 23:50:13 +02:00
|
|
|
$(error "$(MSG_FORMATERROR) $(FORMAT)")
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Test if quotes are needed for the echo-command
|
|
|
|
result = ${shell echo "test"}
|
|
|
|
ifeq (${result}, test)
|
|
|
|
quote = '
|
|
|
|
else
|
2011-01-16 16:17:57 +01:00
|
|
|
quote =
|
2010-07-03 23:50:13 +02:00
|
|
|
endif
|
|
|
|
|
2011-01-16 16:17:57 +01:00
|
|
|
# Generate intermediate code
|
2011-01-28 12:44:37 +01:00
|
|
|
gencode: ${OUTDIR}/InitMods.c ${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h
|
2011-01-16 16:17:57 +01:00
|
|
|
|
|
|
|
# Generate code for module initialization
|
2010-07-03 23:50:13 +02:00
|
|
|
${OUTDIR}/InitMods.c: Makefile.posix
|
|
|
|
@echo ${MSG_MODINIT}
|
2011-01-16 16:17:57 +01:00
|
|
|
@echo ${quote}// Autogenerated file${quote} > ${OUTDIR}/InitMods.c
|
2010-07-03 23:50:13 +02:00
|
|
|
@echo ${quote}${foreach MOD, ${MODNAMES}, extern unsigned int ${MOD}Initialize(void);}${quote} >> ${OUTDIR}/InitMods.c
|
|
|
|
@echo ${quote}void InitModules() {${quote} >> ${OUTDIR}/InitMods.c
|
|
|
|
@echo ${quote}${foreach MOD, ${MODNAMES}, ${MOD}Initialize();}${quote} >> ${OUTDIR}/InitMods.c
|
|
|
|
@echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c
|
2011-01-16 16:17:57 +01:00
|
|
|
|
|
|
|
# Generate code for PyMite
|
2011-01-28 12:44:37 +01:00
|
|
|
${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h: $(wildcard ${PYMITELIB}/*.py) $(wildcard ${PYMITEPLAT}/*.py) $(wildcard ${FLIGHTPLANLIB}/*.py) $(wildcard ${FLIGHTPLANS}/*.py)
|
|
|
|
@echo ${MSG_PYMITEINIT}
|
|
|
|
@$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -s --memspace=flash -o $(OUTDIR)/pmlib_img.c --native-file=$(OUTDIR)/pmlib_nat.c $(PYMITELIB)/list.py $(PYMITELIB)/dict.py $(PYMITELIB)/__bi.py $(PYMITELIB)/sys.py $(PYMITELIB)/string.py $(wildcard $(FLIGHTPLANLIB)/*.py)
|
|
|
|
@$(PYTHON) $(PYMITETOOLS)/pmGenPmFeatures.py $(PYMITEPLAT)/pmfeatures.py > $(OUTDIR)/pmfeatures.h
|
|
|
|
@$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -u -o $(OUTDIR)/pmlibusr_img.c --native-file=$(OUTDIR)/pmlibusr_nat.c $(FLIGHTPLANS)/test.py
|
2011-01-16 16:17:57 +01:00
|
|
|
|
2010-07-03 23:50:13 +02:00
|
|
|
# Eye candy.
|
|
|
|
begin:
|
|
|
|
## @echo
|
|
|
|
@echo $(MSG_BEGIN)
|
|
|
|
|
|
|
|
finished:
|
|
|
|
## @echo $(MSG_ERRORS_NONE)
|
|
|
|
|
|
|
|
end:
|
|
|
|
@echo $(MSG_END)
|
|
|
|
## @echo
|
|
|
|
|
|
|
|
# Display sizes of sections.
|
|
|
|
ELFSIZE = $(SIZE) -A $(OUTDIR)/$(TARGET).elf
|
|
|
|
##ELFSIZE = $(SIZE) --format=Berkeley --common $(OUTDIR)/$(TARGET).elf
|
|
|
|
sizebefore:
|
|
|
|
# @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
|
|
|
|
|
|
|
|
sizeafter:
|
|
|
|
# @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
|
|
|
@echo $(MSG_SIZE_AFTER)
|
|
|
|
$(ELFSIZE)
|
2011-01-16 16:17:57 +01:00
|
|
|
|
2010-07-03 23:50:13 +02:00
|
|
|
# Display compiler version information.
|
2011-01-16 16:17:57 +01:00
|
|
|
gccversion :
|
2010-07-03 23:50:13 +02:00
|
|
|
@$(CC) --version
|
|
|
|
# @echo $(ALLOBJ)
|
|
|
|
|
|
|
|
# Program the device.
|
2011-01-16 16:17:57 +01:00
|
|
|
ifeq ($(USE_BOOTLOADER), YES)
|
|
|
|
# Program the device with OP Upload Tool".
|
|
|
|
program: $(OUTDIR)/$(TARGET).bin
|
|
|
|
@echo ${quote}Programming with OP Upload Tool${quote}
|
|
|
|
../../ground/src/experimental/upload-build-desktop/debug/OPUploadTool -d 0 -p $(OUTDIR)/$(TARGET).bin
|
|
|
|
else
|
2010-07-03 23:50:13 +02:00
|
|
|
ifeq ($(FLASH_TOOL),OPENOCD)
|
|
|
|
# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script".
|
|
|
|
program: $(OUTDIR)/$(TARGET).elf
|
|
|
|
@echo ${quote}Programming with OPENOCD${quote}
|
|
|
|
$(OOCD_EXE) $(OOCD_CL)
|
|
|
|
endif
|
2011-01-16 16:17:57 +01:00
|
|
|
endif
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
# Create final output file (.hex) from ELF output file.
|
|
|
|
%.hex: %.elf
|
|
|
|
## @echo
|
|
|
|
@echo $(MSG_LOAD_FILE) $@
|
|
|
|
$(OBJCOPY) -O ihex $< $@
|
2011-01-16 16:17:57 +01:00
|
|
|
|
2010-07-03 23:50:13 +02:00
|
|
|
# Create final output file (.bin) from ELF output file.
|
|
|
|
%.bin: %.elf
|
|
|
|
## @echo
|
|
|
|
@echo $(MSG_LOAD_FILE) $@
|
|
|
|
$(OBJCOPY) -O binary $< $@
|
|
|
|
|
|
|
|
# Create extended listing file/disassambly from ELF output file.
|
|
|
|
# using objdump testing: option -C
|
|
|
|
%.lss: %.elf
|
|
|
|
## @echo
|
|
|
|
@echo $(MSG_EXTENDED_LISTING) $@
|
|
|
|
$(OBJDUMP) -h -S -C -r $< > $@
|
|
|
|
# $(OBJDUMP) -x -S $< > $@
|
|
|
|
|
|
|
|
# Create a symbol table from ELF output file.
|
|
|
|
%.sym: %.elf
|
|
|
|
## @echo
|
|
|
|
@echo $(MSG_SYMBOL_TABLE) $@
|
|
|
|
$(NM) -n $< > $@
|
|
|
|
|
|
|
|
# Link: create ELF output file from object files.
|
|
|
|
.SECONDARY : $(TARGET).elf
|
|
|
|
.PRECIOUS : $(ALLOBJ)
|
|
|
|
%.elf: $(ALLOBJ)
|
|
|
|
@echo $(MSG_LINKING) $@
|
|
|
|
# use $(CC) for C-only projects or $(CPP) for C++-projects:
|
|
|
|
$(CC) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS)
|
|
|
|
# $(CPP) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS)
|
|
|
|
|
2011-01-16 16:17:57 +01:00
|
|
|
|
2010-07-03 23:50:13 +02:00
|
|
|
# Assemble: create object files from assembler source files.
|
|
|
|
define ASSEMBLE_TEMPLATE
|
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
|
|
|
## @echo
|
|
|
|
@echo $(MSG_ASSEMBLING) $$< to $$@
|
2011-01-16 16:17:57 +01:00
|
|
|
$(CC) -c $(THUMB) $$(ASFLAGS) $$< -o $$@
|
2010-07-03 23:50:13 +02:00
|
|
|
endef
|
2011-01-16 16:17:57 +01:00
|
|
|
$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src))))
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
# Assemble: create object files from assembler source files. ARM-only
|
|
|
|
define ASSEMBLE_ARM_TEMPLATE
|
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
|
|
|
## @echo
|
|
|
|
@echo $(MSG_ASSEMBLING_ARM) $$< to $$@
|
2011-01-16 16:17:57 +01:00
|
|
|
$(CC) -c $$(ASFLAGS) $$< -o $$@
|
2010-07-03 23:50:13 +02:00
|
|
|
endef
|
2011-01-16 16:17:57 +01:00
|
|
|
$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src))))
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Compile: create object files from C source files.
|
|
|
|
define COMPILE_C_TEMPLATE
|
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
|
|
|
## @echo
|
|
|
|
@echo $(MSG_COMPILING) $$< to $$@
|
2011-01-16 16:17:57 +01:00
|
|
|
$(CC) -c $(THUMB) $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@
|
2010-07-03 23:50:13 +02:00
|
|
|
endef
|
2011-01-16 16:17:57 +01:00
|
|
|
$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src))))
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
# Compile: create object files from C source files. ARM-only
|
|
|
|
define COMPILE_C_ARM_TEMPLATE
|
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
|
|
|
## @echo
|
|
|
|
@echo $(MSG_COMPILING_ARM) $$< to $$@
|
2011-01-16 16:17:57 +01:00
|
|
|
$(CC) -c $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@
|
2010-07-03 23:50:13 +02:00
|
|
|
endef
|
2011-01-16 16:17:57 +01:00
|
|
|
$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src))))
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Compile: create object files from C++ source files.
|
|
|
|
define COMPILE_CPP_TEMPLATE
|
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
|
|
|
## @echo
|
|
|
|
@echo $(MSG_COMPILINGCPP) $$< to $$@
|
2011-01-16 16:17:57 +01:00
|
|
|
$(CC) -c $(THUMB) $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@
|
2010-07-03 23:50:13 +02:00
|
|
|
endef
|
2011-01-16 16:17:57 +01:00
|
|
|
$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src))))
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
# Compile: create object files from C++ source files. ARM-only
|
|
|
|
define COMPILE_CPP_ARM_TEMPLATE
|
|
|
|
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
|
|
|
|
## @echo
|
|
|
|
@echo $(MSG_COMPILINGCPP_ARM) $$< to $$@
|
2011-01-16 16:17:57 +01:00
|
|
|
$(CC) -c $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@
|
2010-07-03 23:50:13 +02:00
|
|
|
endef
|
2011-01-16 16:17:57 +01:00
|
|
|
$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src))))
|
2010-07-03 23:50:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Compile: create assembler files from C source files. ARM/Thumb
|
|
|
|
$(SRC:.c=.s) : %.s : %.c
|
|
|
|
@echo $(MSG_ASMFROMC) $< to $@
|
|
|
|
$(CC) $(THUMB) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@
|
|
|
|
|
|
|
|
# Compile: create assembler files from C source files. ARM only
|
|
|
|
$(SRCARM:.c=.s) : %.s : %.c
|
|
|
|
@echo $(MSG_ASMFROMC_ARM) $< to $@
|
|
|
|
$(CC) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@
|
|
|
|
|
|
|
|
# Generate Doxygen documents
|
|
|
|
docs:
|
|
|
|
doxygen $(DOXYGENDIR)/doxygen.cfg
|
2011-01-16 16:17:57 +01:00
|
|
|
|
2010-07-03 23:50:13 +02:00
|
|
|
# Target: clean project.
|
|
|
|
clean: begin clean_list finished end
|
|
|
|
|
|
|
|
clean_list :
|
|
|
|
## @echo
|
|
|
|
@echo $(MSG_CLEANING)
|
|
|
|
$(REMOVE) $(OUTDIR)/$(TARGET).map
|
|
|
|
$(REMOVE) $(OUTDIR)/$(TARGET).elf
|
|
|
|
$(REMOVE) $(OUTDIR)/$(TARGET).hex
|
|
|
|
$(REMOVE) $(OUTDIR)/$(TARGET).bin
|
|
|
|
$(REMOVE) $(OUTDIR)/$(TARGET).sym
|
|
|
|
$(REMOVE) $(OUTDIR)/$(TARGET).lss
|
2011-01-16 16:17:57 +01:00
|
|
|
$(REMOVE) $(wildcard $(OUTDIR)/*.c)
|
|
|
|
$(REMOVE) $(wildcard $(OUTDIR)/*.h)
|
2010-07-03 23:50:13 +02:00
|
|
|
$(REMOVE) $(ALLOBJ)
|
|
|
|
$(REMOVE) $(LSTFILES)
|
|
|
|
$(REMOVE) $(DEPFILES)
|
|
|
|
$(REMOVE) $(SRC:.c=.s)
|
|
|
|
$(REMOVE) $(SRCARM:.c=.s)
|
|
|
|
$(REMOVE) $(CPPSRC:.cpp=.s)
|
|
|
|
$(REMOVE) $(CPPSRCARM:.cpp=.s)
|
|
|
|
|
|
|
|
|
|
|
|
# Create output files directory
|
|
|
|
# all known MS Windows OS define the ComSpec environment variable
|
|
|
|
ifdef ComSpec
|
|
|
|
$(shell md $(OUTDIR) 2>NUL)
|
|
|
|
else
|
|
|
|
$(shell mkdir $(OUTDIR) 2>/dev/null)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Include the dependency files.
|
|
|
|
ifdef ComSpec
|
|
|
|
-include $(shell md $(OUTDIR)\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*)
|
|
|
|
else
|
|
|
|
-include $(shell mkdir $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*)
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Listing of phony targets.
|
|
|
|
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
2011-01-16 16:17:57 +01:00
|
|
|
build elf hex bin lss sym clean clean_list program gencode
|
2010-07-03 23:50:13 +02:00
|
|
|
|