1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-21 11:54:15 +01:00

line-end changes only

This commit is contained in:
Stacey Sheldon 2011-03-25 19:25:03 +00:00
parent d1fb254a41
commit 58a2c71532

View File

@ -1,619 +1,619 @@
##### #####
# Project: OpenPilot # Project: OpenPilot
# #
# #
# Makefile for OpenPilot project build PiOS and the AP. # Makefile for OpenPilot project build PiOS and the AP.
# #
# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009.
# #
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or # the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, but # This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details. # for more details.
# #
# You should have received a copy of the GNU General Public License along # 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., # with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##### #####
# Set developer code and compile options # Set developer code and compile options
# Set to YES to compile for debugging # Set to YES to compile for debugging
DEBUG ?= NO DEBUG ?= NO
# Set to YES to use the Servo output pins for debugging via scope or logic analyser # Set to YES to use the Servo output pins for debugging via scope or logic analyser
ENABLE_DEBUG_PINS ?= NO ENABLE_DEBUG_PINS ?= NO
# Set to Yes to enable the AUX UART which is mapped on the S1 (Tx) and S2 (Rx) servo outputs # Set to Yes to enable the AUX UART which is mapped on the S1 (Tx) and S2 (Rx) servo outputs
ENABLE_AUX_UART ?= NO ENABLE_AUX_UART ?= NO
# #
USE_BOOTLOADER ?= YES USE_BOOTLOADER ?= YES
# Set to the source bootloader binary # Set to the source bootloader binary
SOURCE_BL ?= NULL SOURCE_BL ?= NULL
# Set to YES when using Code Sourcery toolchain # Set to YES when using Code Sourcery toolchain
CODE_SOURCERY ?= NO CODE_SOURCERY ?= NO
# Toolchain prefix (i.e arm-elf- -> arm-elf-gcc.exe) # Toolchain prefix (i.e arm-elf- -> arm-elf-gcc.exe)
TCHAIN_PREFIX ?= arm-none-eabi- TCHAIN_PREFIX ?= arm-none-eabi-
# Remove command is different for Code Sourcery on Windows # Remove command is different for Code Sourcery on Windows
ifeq ($(CODE_SOURCERY), YES) ifeq ($(CODE_SOURCERY), YES)
REMOVE_CMD = cs-rm REMOVE_CMD = cs-rm
else else
REMOVE_CMD = rm REMOVE_CMD = rm
endif endif
FLASH_TOOL = OPENOCD FLASH_TOOL = OPENOCD
# YES enables -mthumb option to flags for source-files listed # YES enables -mthumb option to flags for source-files listed
# in SRC and CPPSRC # in SRC and CPPSRC
USE_THUMB_MODE = YES USE_THUMB_MODE = YES
# MCU name, submodel and board # MCU name, submodel and board
# - MCU used for compiler-option (-mcpu) # - MCU used for compiler-option (-mcpu)
# - MODEL used for linker-script name (-T) and passed as define # - MODEL used for linker-script name (-T) and passed as define
# - BOARD just passed as define (optional) # - BOARD just passed as define (optional)
MCU = cortex-m3 MCU = cortex-m3
CHIP = STM32F103CBT CHIP = STM32F103CBT
BOARD ?= NULL BOARD ?= NULL
MODEL ?= NULL MODEL ?= NULL
ifeq ($(USE_BOOTLOADER), YES) ifeq ($(USE_BOOTLOADER), YES)
BOOT_MODEL = $(MODEL)_BL BOOT_MODEL = $(MODEL)_BL
else else
BOOT_MODEL = $(MODEL)_NB BOOT_MODEL = $(MODEL)_NB
endif endif
# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) # Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.)
OUTDIR = ../../../build/bootloaders/BootloaderUpdater OUTDIR = ../../../build/bootloaders/BootloaderUpdater
# Target file name (without extension). # Target file name (without extension).
TARGET = BL_Updater TARGET = BL_Updater
# Paths # Paths
OPSYSTEM = . OPSYSTEM = .
OPSYSTEMINC = $(OPSYSTEM)/inc OPSYSTEMINC = $(OPSYSTEM)/inc
OPUAVTALK = ./UAVTalk OPUAVTALK = ./UAVTalk
OPUAVTALKINC = $(OPUAVTALK)/inc OPUAVTALKINC = $(OPUAVTALK)/inc
OPUAVOBJ = ./UAVObjects OPUAVOBJ = ./UAVObjects
OPUAVOBJINC = $(OPUAVOBJ)/inc OPUAVOBJINC = $(OPUAVOBJ)/inc
OPTESTS = ./Tests OPTESTS = ./Tests
OPMODULEDIR = ./Modules OPMODULEDIR = ./Modules
FLIGHTLIB = ../../Libraries FLIGHTLIB = ../../Libraries
FLIGHTLIBINC = ../../Libraries/inc FLIGHTLIBINC = ../../Libraries/inc
PIOS = ../../PiOS PIOS = ../../PiOS
PIOSINC = $(PIOS)/inc PIOSINC = $(PIOS)/inc
PIOSSTM32F10X = $(PIOS)/STM32F10x PIOSSTM32F10X = $(PIOS)/STM32F10x
PIOSCOMMON = $(PIOS)/Common PIOSCOMMON = $(PIOS)/Common
PIOSBOARDS = $(PIOS)/Boards PIOSBOARDS = $(PIOS)/Boards
APPLIBDIR = $(PIOSSTM32F10X)/Libraries APPLIBDIR = $(PIOSSTM32F10X)/Libraries
STMLIBDIR = $(APPLIBDIR) STMLIBDIR = $(APPLIBDIR)
STMSPDDIR = $(STMLIBDIR)/STM32F10x_StdPeriph_Driver STMSPDDIR = $(STMLIBDIR)/STM32F10x_StdPeriph_Driver
STMUSBDIR = $(STMLIBDIR)/STM32_USB-FS-Device_Driver STMUSBDIR = $(STMLIBDIR)/STM32_USB-FS-Device_Driver
STMSPDSRCDIR = $(STMSPDDIR)/src STMSPDSRCDIR = $(STMSPDDIR)/src
STMSPDINCDIR = $(STMSPDDIR)/inc STMSPDINCDIR = $(STMSPDDIR)/inc
STMUSBSRCDIR = $(STMUSBDIR)/src STMUSBSRCDIR = $(STMUSBDIR)/src
STMUSBINCDIR = $(STMUSBDIR)/inc STMUSBINCDIR = $(STMUSBDIR)/inc
CMSISDIR = $(STMLIBDIR)/CMSIS/Core/CM3 CMSISDIR = $(STMLIBDIR)/CMSIS/Core/CM3
DOSFSDIR = $(APPLIBDIR)/dosfs DOSFSDIR = $(APPLIBDIR)/dosfs
MSDDIR = $(APPLIBDIR)/msd MSDDIR = $(APPLIBDIR)/msd
RTOSDIR = $(APPLIBDIR)/FreeRTOS RTOSDIR = $(APPLIBDIR)/FreeRTOS
RTOSSRCDIR = $(RTOSDIR)/Source RTOSSRCDIR = $(RTOSDIR)/Source
RTOSINCDIR = $(RTOSSRCDIR)/include RTOSINCDIR = $(RTOSSRCDIR)/include
DOXYGENDIR = ../Doc/Doxygen DOXYGENDIR = ../Doc/Doxygen
# List C source files here. (C dependencies are automatically generated.) # List C source files here. (C dependencies are automatically generated.)
# use file-extension c for "c-only"-files # use file-extension c for "c-only"-files
## CORE: ## CORE:
SRC += $(OPSYSTEM)/main.c SRC += $(OPSYSTEM)/main.c
SRC += $(OPSYSTEM)/pios_board.c SRC += $(OPSYSTEM)/pios_board.c
## PIOS Hardware (STM32F10x) ## PIOS Hardware (STM32F10x)
SRC += $(PIOSSTM32F10X)/pios_sys.c SRC += $(PIOSSTM32F10X)/pios_sys.c
SRC += $(PIOSSTM32F10X)/pios_led.c SRC += $(PIOSSTM32F10X)/pios_led.c
SRC += $(PIOSSTM32F10X)/pios_delay.c SRC += $(PIOSSTM32F10X)/pios_delay.c
SRC += $(PIOSSTM32F10X)/pios_irq.c SRC += $(PIOSSTM32F10X)/pios_irq.c
SRC += $(PIOSSTM32F10X)/pios_gpio.c SRC += $(PIOSSTM32F10X)/pios_gpio.c
## CMSIS for STM32 ## CMSIS for STM32
SRC += $(CMSISDIR)/core_cm3.c SRC += $(CMSISDIR)/core_cm3.c
SRC += $(CMSISDIR)/system_stm32f10x.c SRC += $(CMSISDIR)/system_stm32f10x.c
## Used parts of the STM-Library ## Used parts of the STM-Library
SRC += $(STMSPDSRCDIR)/stm32f10x_flash.c SRC += $(STMSPDSRCDIR)/stm32f10x_flash.c
SRC += $(STMSPDSRCDIR)/stm32f10x_gpio.c SRC += $(STMSPDSRCDIR)/stm32f10x_gpio.c
SRC += $(STMSPDSRCDIR)/stm32f10x_rcc.c SRC += $(STMSPDSRCDIR)/stm32f10x_rcc.c
SRC += $(STMSPDSRCDIR)/stm32f10x_rtc.c SRC += $(STMSPDSRCDIR)/stm32f10x_rtc.c
SRC += $(STMSPDSRCDIR)/stm32f10x_tim.c SRC += $(STMSPDSRCDIR)/stm32f10x_tim.c
SRC += $(STMSPDSRCDIR)/misc.c SRC += $(STMSPDSRCDIR)/misc.c
# List C source files here which must be compiled in ARM-Mode (no -mthumb). # List C source files here which must be compiled in ARM-Mode (no -mthumb).
# use file-extension c for "c-only"-files # use file-extension c for "c-only"-files
## just for testing, timer.c could be compiled in thumb-mode too ## just for testing, timer.c could be compiled in thumb-mode too
SRCARM = SRCARM =
# List C++ source files here. # List C++ source files here.
# use file-extension .cpp for C++-files (not .C) # use file-extension .cpp for C++-files (not .C)
CPPSRC = CPPSRC =
# List C++ source files here which must be compiled in ARM-Mode. # List C++ source files here which must be compiled in ARM-Mode.
# use file-extension .cpp for C++-files (not .C) # use file-extension .cpp for C++-files (not .C)
#CPPSRCARM = $(TARGET).cpp #CPPSRCARM = $(TARGET).cpp
CPPSRCARM = CPPSRCARM =
# List Assembler source files here. # List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s # Make them always end in a capital .S. Files ending in a lowercase .s
# will not be considered source files but generated files (assembler # will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"! # output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same, # Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does # it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line. # care about how the name is spelled on its command-line.
ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL).S ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL).S
# List Assembler source files here which must be assembled in ARM-Mode.. # List Assembler source files here which must be assembled in ARM-Mode..
ASRCARM = ASRCARM =
# List any extra directories to look for include files here. # List any extra directories to look for include files here.
# Each directory must be seperated by a space. # Each directory must be seperated by a space.
EXTRAINCDIRS = $(OPSYSTEM) EXTRAINCDIRS = $(OPSYSTEM)
EXTRAINCDIRS += $(OPSYSTEMINC) EXTRAINCDIRS += $(OPSYSTEMINC)
EXTRAINCDIRS += $(OPUAVTALK) EXTRAINCDIRS += $(OPUAVTALK)
EXTRAINCDIRS += $(OPUAVTALKINC) EXTRAINCDIRS += $(OPUAVTALKINC)
EXTRAINCDIRS += $(OPUAVOBJ) EXTRAINCDIRS += $(OPUAVOBJ)
EXTRAINCDIRS += $(OPUAVOBJINC) EXTRAINCDIRS += $(OPUAVOBJINC)
EXTRAINCDIRS += $(PIOS) EXTRAINCDIRS += $(PIOS)
EXTRAINCDIRS += $(PIOSINC) EXTRAINCDIRS += $(PIOSINC)
EXTRAINCDIRS += $(FLIGHTLIBINC) EXTRAINCDIRS += $(FLIGHTLIBINC)
EXTRAINCDIRS += $(PIOSSTM32F10X) EXTRAINCDIRS += $(PIOSSTM32F10X)
EXTRAINCDIRS += $(PIOSCOMMON) EXTRAINCDIRS += $(PIOSCOMMON)
EXTRAINCDIRS += $(PIOSBOARDS) EXTRAINCDIRS += $(PIOSBOARDS)
EXTRAINCDIRS += $(STMSPDINCDIR) EXTRAINCDIRS += $(STMSPDINCDIR)
EXTRAINCDIRS += $(STMUSBINCDIR) EXTRAINCDIRS += $(STMUSBINCDIR)
EXTRAINCDIRS += $(CMSISDIR) EXTRAINCDIRS += $(CMSISDIR)
EXTRAINCDIRS += $(DOSFSDIR) EXTRAINCDIRS += $(DOSFSDIR)
EXTRAINCDIRS += $(MSDDIR) EXTRAINCDIRS += $(MSDDIR)
EXTRAINCDIRS += $(RTOSINCDIR) EXTRAINCDIRS += $(RTOSINCDIR)
EXTRAINCDIRS += $(APPLIBDIR) EXTRAINCDIRS += $(APPLIBDIR)
EXTRAINCDIRS += $(RTOSSRCDIR)/portable/GCC/ARM_CM3 EXTRAINCDIRS += $(RTOSSRCDIR)/portable/GCC/ARM_CM3
# List any extra directories to look for library files here. # List any extra directories to look for library files here.
# Also add directories where the linker should search for # Also add directories where the linker should search for
# includes from linker-script to the list # includes from linker-script to the list
# Each directory must be seperated by a space. # Each directory must be seperated by a space.
EXTRA_LIBDIRS = EXTRA_LIBDIRS =
# Extra Libraries # Extra Libraries
# Each library-name must be seperated by a space. # Each library-name must be seperated by a space.
# i.e. to link with libxyz.a, libabc.a and libefsl.a: # i.e. to link with libxyz.a, libabc.a and libefsl.a:
# EXTRA_LIBS = xyz abc efsl # EXTRA_LIBS = xyz abc efsl
# for newlib-lpc (file: libnewlibc-lpc.a): # for newlib-lpc (file: libnewlibc-lpc.a):
# EXTRA_LIBS = newlib-lpc # EXTRA_LIBS = newlib-lpc
EXTRA_LIBS = EXTRA_LIBS =
# Path to Linker-Scripts # Path to Linker-Scripts
LINKERSCRIPTPATH = $(PIOSSTM32F10X) LINKERSCRIPTPATH = $(PIOSSTM32F10X)
# Optimization level, can be [0, 1, 2, 3, s]. # Optimization level, can be [0, 1, 2, 3, s].
# 0 = turn off optimization. s = optimize for size. # 0 = turn off optimization. s = optimize for size.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
ifeq ($(DEBUG),YES) ifeq ($(DEBUG),YES)
OPT = 0 OPT = 0
else else
OPT = s OPT = s
endif endif
# Output format. (can be ihex or binary or both) # Output format. (can be ihex or binary or both)
# binary to create a load-image in raw-binary format i.e. for SAM-BA, # binary to create a load-image in raw-binary format i.e. for SAM-BA,
# ihex to create a load-image in Intel hex format # ihex to create a load-image in Intel hex format
#LOADFORMAT = ihex #LOADFORMAT = ihex
#LOADFORMAT = binary #LOADFORMAT = binary
LOADFORMAT = both LOADFORMAT = both
# Debugging format. # Debugging format.
DEBUGF = dwarf-2 DEBUGF = dwarf-2
# Place project-specific -D (define) and/or # Place project-specific -D (define) and/or
# -U options for C here. # -U options for C here.
CDEFS = -DSTM32F10X_$(MODEL) CDEFS = -DSTM32F10X_$(MODEL)
CDEFS += -DUSE_STDPERIPH_DRIVER CDEFS += -DUSE_STDPERIPH_DRIVER
CDEFS += -DUSE_$(BOARD) CDEFS += -DUSE_$(BOARD)
ifeq ($(ENABLE_DEBUG_PINS), YES) ifeq ($(ENABLE_DEBUG_PINS), YES)
CDEFS += -DPIOS_ENABLE_DEBUG_PINS CDEFS += -DPIOS_ENABLE_DEBUG_PINS
endif endif
ifeq ($(ENABLE_AUX_UART), YES) ifeq ($(ENABLE_AUX_UART), YES)
CDEFS += -DPIOS_ENABLE_AUX_UART CDEFS += -DPIOS_ENABLE_AUX_UART
endif endif
ifeq ($(USE_BOOTLOADER), YES) ifeq ($(USE_BOOTLOADER), YES)
CDEFS += -DUSE_BOOTLOADER CDEFS += -DUSE_BOOTLOADER
endif endif
# Place project-specific -D and/or -U options for # Place project-specific -D and/or -U options for
# Assembler with preprocessor here. # Assembler with preprocessor here.
#ADEFS = -DUSE_IRQ_ASM_WRAPPER #ADEFS = -DUSE_IRQ_ASM_WRAPPER
ADEFS = -D__ASSEMBLY__ ADEFS = -D__ASSEMBLY__
# Compiler flag to set the C Standard level. # Compiler flag to set the C Standard level.
# c89 - "ANSI" C # c89 - "ANSI" C
# gnu89 - c89 plus GCC extensions # gnu89 - c89 plus GCC extensions
# c99 - ISO C99 standard (not yet fully implemented) # c99 - ISO C99 standard (not yet fully implemented)
# gnu99 - c99 plus GCC extensions # gnu99 - c99 plus GCC extensions
CSTANDARD = -std=gnu99 CSTANDARD = -std=gnu99
#----- #-----
# Compiler flags. # Compiler flags.
# -g*: generate debugging information # -g*: generate debugging information
# -O*: optimization level # -O*: optimization level
# -f...: tuning, see GCC manual and avr-libc documentation # -f...: tuning, see GCC manual and avr-libc documentation
# -Wall...: warning level # -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler. # -Wa,...: tell GCC to pass this to the assembler.
# -adhlns...: create assembler listing # -adhlns...: create assembler listing
# #
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) # Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
ifeq ($(DEBUG),YES) ifeq ($(DEBUG),YES)
CFLAGS = -g$(DEBUGF) -DDEBUG CFLAGS = -g$(DEBUGF) -DDEBUG
endif endif
CFLAGS += -O$(OPT) CFLAGS += -O$(OPT)
ifeq ($(DEBUG),NO) ifeq ($(DEBUG),NO)
CFLAGS += -ffunction-sections CFLAGS += -ffunction-sections
endif endif
CFLAGS += -mcpu=$(MCU) -mthumb CFLAGS += -mcpu=$(MCU) -mthumb
CFLAGS += $(CDEFS) CFLAGS += $(CDEFS)
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
CFLAGS += -mapcs-frame CFLAGS += -mapcs-frame
CFLAGS += -fomit-frame-pointer CFLAGS += -fomit-frame-pointer
CFLAGS += -fpromote-loop-indices CFLAGS += -fpromote-loop-indices
CFLAGS += -Wall CFLAGS += -Wall
CFLAGS += -Werror CFLAGS += -Werror
CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
# Compiler flags to generate dependency files: # Compiler flags to generate dependency files:
CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d
# flags only for C # flags only for C
#CONLYFLAGS += -Wnested-externs #CONLYFLAGS += -Wnested-externs
CONLYFLAGS += $(CSTANDARD) CONLYFLAGS += $(CSTANDARD)
# Assembler flags. # Assembler flags.
# -Wa,...: tell GCC to pass this to the assembler. # -Wa,...: tell GCC to pass this to the assembler.
# -ahlns: create listing # -ahlns: create listing
ASFLAGS = -mcpu=$(MCU) -mthumb -I. -x assembler-with-cpp ASFLAGS = -mcpu=$(MCU) -mthumb -I. -x assembler-with-cpp
ASFLAGS += $(ADEFS) ASFLAGS += $(ADEFS)
ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
MATH_LIB = -lm MATH_LIB = -lm
# Linker flags. # Linker flags.
# -Wl,...: tell GCC to pass this to linker. # -Wl,...: tell GCC to pass this to linker.
# -Map: create map file # -Map: create map file
# --cref: add cross reference to map file # --cref: add cross reference to map file
LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections
ifeq ($(DEBUG),NO) ifeq ($(DEBUG),NO)
LDFLAGS += -Wl,-static -Wl,-s LDFLAGS += -Wl,-static -Wl,-s
endif endif
LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS))
LDFLAGS += -lc LDFLAGS += -lc
LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS))
LDFLAGS += $(MATH_LIB) LDFLAGS += $(MATH_LIB)
LDFLAGS += -lc -lgcc LDFLAGS += -lc -lgcc
# Set linker-script name depending on selected submodel name # Set linker-script name depending on selected submodel name
LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_$(BOARD)_$(BOOT_MODEL).ld LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_$(BOARD)_$(BOOT_MODEL).ld
# Test if quotes are needed for the echo-command # Test if quotes are needed for the echo-command
result = ${shell echo "test"} result = ${shell echo "test"}
ifeq (${result}, test) ifeq (${result}, test)
quote = ' quote = '
else else
quote = quote =
endif endif
OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).elf
# Program # Program
OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)" OOCD_CL+=-c "flash write_image $(OOCD_LOADFILE)"
# Verify # Verify
OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)" OOCD_CL+=-c "verify_image $(OOCD_LOADFILE)"
# reset target # reset target
OOCD_CL+=-c "reset run" OOCD_CL+=-c "reset run"
# terminate OOCD after programming # terminate OOCD after programming
OOCD_CL+=-c shutdown OOCD_CL+=-c shutdown
# Define programs and commands. # Define programs and commands.
CC = $(TCHAIN_PREFIX)gcc CC = $(TCHAIN_PREFIX)gcc
CPP = $(TCHAIN_PREFIX)g++ CPP = $(TCHAIN_PREFIX)g++
AR = $(TCHAIN_PREFIX)ar AR = $(TCHAIN_PREFIX)ar
OBJCOPY = $(TCHAIN_PREFIX)objcopy OBJCOPY = $(TCHAIN_PREFIX)objcopy
OBJDUMP = $(TCHAIN_PREFIX)objdump OBJDUMP = $(TCHAIN_PREFIX)objdump
SIZE = $(TCHAIN_PREFIX)size SIZE = $(TCHAIN_PREFIX)size
NM = $(TCHAIN_PREFIX)nm NM = $(TCHAIN_PREFIX)nm
REMOVE = $(REMOVE_CMD) -f REMOVE = $(REMOVE_CMD) -f
###SHELL = sh ###SHELL = sh
###COPY = cp ###COPY = cp
# Define Messages # Define Messages
# English # English
MSG_ERRORS_NONE = Errors: none MSG_ERRORS_NONE = Errors: none
MSG_BEGIN = ${quote}-------- begin (mode: $(RUN_MODE)) --------${quote} MSG_BEGIN = ${quote}-------- begin (mode: $(RUN_MODE)) --------${quote}
MSG_END = ${quote}-------- end --------${quote} MSG_END = ${quote}-------- end --------${quote}
MSG_MODINIT = ${quote}**** Generating ModInit.c${quote} MSG_MODINIT = ${quote}**** Generating ModInit.c${quote}
MSG_SIZE_BEFORE = ${quote}Size before:${quote} MSG_SIZE_BEFORE = ${quote}Size before:${quote}
MSG_SIZE_AFTER = ${quote}Size after build:${quote} MSG_SIZE_AFTER = ${quote}Size after build:${quote}
MSG_LOAD_FILE = ${quote}Creating load file:${quote} MSG_LOAD_FILE = ${quote}Creating load file:${quote}
MSG_EXTENDED_LISTING = ${quote}Creating Extended Listing/Disassembly:${quote} MSG_EXTENDED_LISTING = ${quote}Creating Extended Listing/Disassembly:${quote}
MSG_SYMBOL_TABLE = ${quote}Creating Symbol Table:${quote} MSG_SYMBOL_TABLE = ${quote}Creating Symbol Table:${quote}
MSG_LINKING = ${quote}**** Linking :${quote} MSG_LINKING = ${quote}**** Linking :${quote}
MSG_COMPILING = ${quote}**** Compiling C :${quote} MSG_COMPILING = ${quote}**** Compiling C :${quote}
MSG_COMPILING_ARM = ${quote}**** Compiling C (ARM-only):${quote} MSG_COMPILING_ARM = ${quote}**** Compiling C (ARM-only):${quote}
MSG_COMPILINGCPP = ${quote}Compiling C++ :${quote} MSG_COMPILINGCPP = ${quote}Compiling C++ :${quote}
MSG_COMPILINGCPP_ARM = ${quote}Compiling C++ (ARM-only):${quote} MSG_COMPILINGCPP_ARM = ${quote}Compiling C++ (ARM-only):${quote}
MSG_ASSEMBLING = ${quote}**** Assembling:${quote} MSG_ASSEMBLING = ${quote}**** Assembling:${quote}
MSG_ASSEMBLING_ARM = ${quote}****Assembling (ARM-only):${quote} MSG_ASSEMBLING_ARM = ${quote}****Assembling (ARM-only):${quote}
MSG_CLEANING = ${quote}Cleaning project:${quote} MSG_CLEANING = ${quote}Cleaning project:${quote}
MSG_FORMATERROR = ${quote}Can not handle output-format${quote} MSG_FORMATERROR = ${quote}Can not handle output-format${quote}
MSG_ASMFROMC = ${quote}Creating asm-File from C-Source:${quote} MSG_ASMFROMC = ${quote}Creating asm-File from C-Source:${quote}
MSG_ASMFROMC_ARM = ${quote}Creating asm-File from C-Source (ARM-only):${quote} MSG_ASMFROMC_ARM = ${quote}Creating asm-File from C-Source (ARM-only):${quote}
# List of all source files. # List of all source files.
ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC)
# List of all source files without directory and file-extension. # List of all source files without directory and file-extension.
ALLSRCBASE = $(notdir $(basename $(ALLSRC))) ALLSRCBASE = $(notdir $(basename $(ALLSRC)))
# Define all object files. # Define all object files.
ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE)))
# Define all listing files (used for make clean). # Define all listing files (used for make clean).
LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE)))
# Define all depedency-files (used for make clean). # Define all depedency-files (used for make clean).
DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE)))
# Default target. # Default target.
#all: begin gccversion sizebefore build sizeafter finished end #all: begin gccversion sizebefore build sizeafter finished end
all: begin gccversion build sizeafter finished end all: begin gccversion build sizeafter finished end
elf: $(OUTDIR)/$(TARGET).elf elf: $(OUTDIR)/$(TARGET).elf
lss: $(OUTDIR)/$(TARGET).lss lss: $(OUTDIR)/$(TARGET).lss
sym: $(OUTDIR)/$(TARGET).sym sym: $(OUTDIR)/$(TARGET).sym
hex: $(OUTDIR)/$(TARGET).hex hex: $(OUTDIR)/$(TARGET).hex
bin: $(OUTDIR)/$(TARGET).bin bin: $(OUTDIR)/$(TARGET).bin
ifeq ($(LOADFORMAT),ihex) ifeq ($(LOADFORMAT),ihex)
build: elf hex sym build: elf hex sym
else else
ifeq ($(LOADFORMAT),binary) ifeq ($(LOADFORMAT),binary)
build: elf bin sym build: elf bin sym
else else
ifeq ($(LOADFORMAT),both) ifeq ($(LOADFORMAT),both)
build: elf hex bin sym build: elf hex bin sym
else else
$(error "$(MSG_FORMATERROR) $(FORMAT)") $(error "$(MSG_FORMATERROR) $(FORMAT)")
endif endif
endif endif
endif endif
# Eye candy. # Eye candy.
begin: begin:
## @echo ## @echo
@echo $(MSG_BEGIN) @echo $(MSG_BEGIN)
ifeq ($(SOURCE_BL), NULL) ifeq ($(SOURCE_BL), NULL)
@echo ${quote}Please specify the source bootloader binary with SOURCE_BL=source_name${quote} @echo ${quote}Please specify the source bootloader binary with SOURCE_BL=source_name${quote}
@exit 2 @exit 2
endif endif
ifeq ($(BOARD), NULL) ifeq ($(BOARD), NULL)
@echo ${quote}Please specify the board name with BOARD=board_name (STM3210E_OP,STM32103CB_AHRS,STM32103CB_PIPXTREME,STM32103CB_CC_Rev1)${quote} @echo ${quote}Please specify the board name with BOARD=board_name (STM3210E_OP,STM32103CB_AHRS,STM32103CB_PIPXTREME,STM32103CB_CC_Rev1)${quote}
@exit 2 @exit 2
endif endif
ifeq ($(MODEL), NULL) ifeq ($(MODEL), NULL)
@echo ${quote}Please specify the chip model with MODEL=MD/HD${quote} @echo ${quote}Please specify the chip model with MODEL=MD/HD${quote}
@exit 2 @exit 2
endif endif
python file_to_array.py $(SOURCE_BL) bl_array.h python file_to_array.py $(SOURCE_BL) bl_array.h
#UNAME := $(shell python file_to_array.py $(SOURCE_BL) bl_array.h) #UNAME := $(shell python file_to_array.py $(SOURCE_BL) bl_array.h)
########################################################################################################### ###########################################################################################################
finished: finished:
## @echo $(MSG_ERRORS_NONE) ## @echo $(MSG_ERRORS_NONE)
end: end:
@echo $(MSG_END) @echo $(MSG_END)
## @echo ## @echo
# Display sizes of sections. # Display sizes of sections.
ELFSIZE = $(SIZE) -A $(OUTDIR)/$(TARGET).elf ELFSIZE = $(SIZE) -A $(OUTDIR)/$(TARGET).elf
sizebefore: sizebefore:
# @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi # @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
sizeafter: sizeafter:
# @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi # @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
@echo $(MSG_SIZE_AFTER) @echo $(MSG_SIZE_AFTER)
$(ELFSIZE) $(ELFSIZE)
# Display compiler version information. # Display compiler version information.
gccversion : gccversion :
@$(CC) --version @$(CC) --version
# @echo $(ALLOBJ) # @echo $(ALLOBJ)
# Program the device. # Program the device.
ifeq ($(FLASH_TOOL),OPENOCD) ifeq ($(FLASH_TOOL),OPENOCD)
# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". # Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script".
program: $(OUTDIR)/$(TARGET).elf program: $(OUTDIR)/$(TARGET).elf
@echo ${quote}Programming with OPENOCD${quote} @echo ${quote}Programming with OPENOCD${quote}
$(OOCD_EXE) $(OOCD_CL) $(OOCD_EXE) $(OOCD_CL)
endif endif
# Create final output file (.hex) from ELF output file. # Create final output file (.hex) from ELF output file.
%.hex: %.elf %.hex: %.elf
## @echo ## @echo
@echo $(MSG_LOAD_FILE) $@ @echo $(MSG_LOAD_FILE) $@
$(OBJCOPY) -O ihex $< $@ $(OBJCOPY) -O ihex $< $@
# Create final output file (.bin) from ELF output file. # Create final output file (.bin) from ELF output file.
%.bin: %.elf %.bin: %.elf
## @echo ## @echo
@echo $(MSG_LOAD_FILE) $@ @echo $(MSG_LOAD_FILE) $@
$(OBJCOPY) -O binary $< $@ $(OBJCOPY) -O binary $< $@
# Create extended listing file/disassambly from ELF output file. # Create extended listing file/disassambly from ELF output file.
# using objdump testing: option -C # using objdump testing: option -C
%.lss: %.elf %.lss: %.elf
## @echo ## @echo
@echo $(MSG_EXTENDED_LISTING) $@ @echo $(MSG_EXTENDED_LISTING) $@
$(OBJDUMP) -h -S -C -r $< > $@ $(OBJDUMP) -h -S -C -r $< > $@
# $(OBJDUMP) -x -S $< > $@ # $(OBJDUMP) -x -S $< > $@
# Create a symbol table from ELF output file. # Create a symbol table from ELF output file.
%.sym: %.elf %.sym: %.elf
## @echo ## @echo
@echo $(MSG_SYMBOL_TABLE) $@ @echo $(MSG_SYMBOL_TABLE) $@
$(NM) -n $< > $@ $(NM) -n $< > $@
# Link: create ELF output file from object files. # Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf .SECONDARY : $(TARGET).elf
.PRECIOUS : $(ALLOBJ) .PRECIOUS : $(ALLOBJ)
%.elf: $(ALLOBJ) %.elf: $(ALLOBJ)
@echo $(MSG_LINKING) $@ @echo $(MSG_LINKING) $@
# use $(CC) for C-only projects or $(CPP) for C++-projects: # use $(CC) for C-only projects or $(CPP) for C++-projects:
$(CC) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS) $(CC) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS)
# $(CPP) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS) # $(CPP) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS)
# Assemble: create object files from assembler source files. # Assemble: create object files from assembler source files.
define ASSEMBLE_TEMPLATE define ASSEMBLE_TEMPLATE
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) $(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
## @echo ## @echo
@echo $(MSG_ASSEMBLING) $$< to $$@ @echo $(MSG_ASSEMBLING) $$< to $$@
$(CC) -c $(THUMB) $$(ASFLAGS) $$< -o $$@ $(CC) -c $(THUMB) $$(ASFLAGS) $$< -o $$@
endef endef
$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) $(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src))))
# Assemble: create object files from assembler source files. ARM-only # Assemble: create object files from assembler source files. ARM-only
define ASSEMBLE_ARM_TEMPLATE define ASSEMBLE_ARM_TEMPLATE
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) $(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
## @echo ## @echo
@echo $(MSG_ASSEMBLING_ARM) $$< to $$@ @echo $(MSG_ASSEMBLING_ARM) $$< to $$@
$(CC) -c $$(ASFLAGS) $$< -o $$@ $(CC) -c $$(ASFLAGS) $$< -o $$@
endef endef
$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) $(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src))))
# Compile: create object files from C source files. # Compile: create object files from C source files.
define COMPILE_C_TEMPLATE define COMPILE_C_TEMPLATE
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) $(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
## @echo ## @echo
@echo $(MSG_COMPILING) $$< to $$@ @echo $(MSG_COMPILING) $$< to $$@
$(CC) -c $(THUMB) $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ $(CC) -c $(THUMB) $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@
endef endef
$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) $(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src))))
# Compile: create object files from C source files. ARM-only # Compile: create object files from C source files. ARM-only
define COMPILE_C_ARM_TEMPLATE define COMPILE_C_ARM_TEMPLATE
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) $(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
## @echo ## @echo
@echo $(MSG_COMPILING_ARM) $$< to $$@ @echo $(MSG_COMPILING_ARM) $$< to $$@
$(CC) -c $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ $(CC) -c $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@
endef endef
$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) $(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src))))
# Compile: create object files from C++ source files. # Compile: create object files from C++ source files.
define COMPILE_CPP_TEMPLATE define COMPILE_CPP_TEMPLATE
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) $(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
## @echo ## @echo
@echo $(MSG_COMPILINGCPP) $$< to $$@ @echo $(MSG_COMPILINGCPP) $$< to $$@
$(CC) -c $(THUMB) $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@ $(CC) -c $(THUMB) $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@
endef endef
$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) $(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src))))
# Compile: create object files from C++ source files. ARM-only # Compile: create object files from C++ source files. ARM-only
define COMPILE_CPP_ARM_TEMPLATE define COMPILE_CPP_ARM_TEMPLATE
$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) $(OUTDIR)/$(notdir $(basename $(1))).o : $(1)
## @echo ## @echo
@echo $(MSG_COMPILINGCPP_ARM) $$< to $$@ @echo $(MSG_COMPILINGCPP_ARM) $$< to $$@
$(CC) -c $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@ $(CC) -c $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@
endef endef
$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) $(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src))))
# Compile: create assembler files from C source files. ARM/Thumb # Compile: create assembler files from C source files. ARM/Thumb
$(SRC:.c=.s) : %.s : %.c $(SRC:.c=.s) : %.s : %.c
@echo $(MSG_ASMFROMC) $< to $@ @echo $(MSG_ASMFROMC) $< to $@
$(CC) $(THUMB) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@ $(CC) $(THUMB) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@
# Compile: create assembler files from C source files. ARM only # Compile: create assembler files from C source files. ARM only
$(SRCARM:.c=.s) : %.s : %.c $(SRCARM:.c=.s) : %.s : %.c
@echo $(MSG_ASMFROMC_ARM) $< to $@ @echo $(MSG_ASMFROMC_ARM) $< to $@
$(CC) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@ $(CC) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@
# Generate Doxygen documents # Generate Doxygen documents
docs: docs:
doxygen $(DOXYGENDIR)/doxygen.cfg doxygen $(DOXYGENDIR)/doxygen.cfg
# Target: clean project. # Target: clean project.
clean: begin clean_list finished end clean: begin clean_list finished end
clean_list : clean_list :
## @echo ## @echo
@echo $(MSG_CLEANING) @echo $(MSG_CLEANING)
$(REMOVE) $(OUTDIR)/$(TARGET).map $(REMOVE) $(OUTDIR)/$(TARGET).map
$(REMOVE) $(OUTDIR)/$(TARGET).elf $(REMOVE) $(OUTDIR)/$(TARGET).elf
$(REMOVE) $(OUTDIR)/$(TARGET).hex $(REMOVE) $(OUTDIR)/$(TARGET).hex
$(REMOVE) $(OUTDIR)/$(TARGET).bin $(REMOVE) $(OUTDIR)/$(TARGET).bin
$(REMOVE) $(OUTDIR)/$(TARGET).sym $(REMOVE) $(OUTDIR)/$(TARGET).sym
$(REMOVE) $(OUTDIR)/$(TARGET).lss $(REMOVE) $(OUTDIR)/$(TARGET).lss
$(REMOVE) $(ALLOBJ) $(REMOVE) $(ALLOBJ)
$(REMOVE) $(LSTFILES) $(REMOVE) $(LSTFILES)
$(REMOVE) $(DEPFILES) $(REMOVE) $(DEPFILES)
$(REMOVE) $(SRC:.c=.s) $(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRCARM:.c=.s) $(REMOVE) $(SRCARM:.c=.s)
$(REMOVE) $(CPPSRC:.cpp=.s) $(REMOVE) $(CPPSRC:.cpp=.s)
$(REMOVE) $(CPPSRCARM:.cpp=.s) $(REMOVE) $(CPPSRCARM:.cpp=.s)
# Create output files directory # Create output files directory
# all known MS Windows OS define the ComSpec environment variable # all known MS Windows OS define the ComSpec environment variable
ifdef ComSpec ifdef ComSpec
$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL) $(shell md $(subst /,\\,$(OUTDIR)) 2>NUL)
else else
$(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir -p $(OUTDIR) 2>/dev/null)
endif endif
# Include the dependency files. # Include the dependency files.
ifdef ComSpec ifdef ComSpec
-include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*) -include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*)
else else
-include $(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) -include $(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*)
endif endif
# Listing of phony targets. # Listing of phony targets.
.PHONY : all begin finish end sizebefore sizeafter gccversion \ .PHONY : all begin finish end sizebefore sizeafter gccversion \
build elf hex bin lss sym clean clean_list program build elf hex bin lss sym clean clean_list program