Revision ebc64c13bc695994f1d4d5b56ba117d800bba4da authored by Gautier Hattenberger on 25 July 2012, 15:31:03 UTC, committed by Gautier Hattenberger on 25 July 2012, 15:31:03 UTC
Units that can be automatically converted should come last so other possibilities are tested first. (ok, that is a lazy and fragile solution...) A the type of auto conversion ("display" or "code" can be changed only for conversions that were already using auto mode (eg. deg <-> decideg will not be auto converted)
1 parent 16c6ea2
Makefile.lpc21
# Hey Emacs, this is a -*- makefile -*-
#
# $Id$
# Copyright (C) 2003-2005 Pascal Brisset, Antoine Drouin
#
# This file is part of paparazzi.
#
# paparazzi 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 2, or (at your option)
# any later version.
#
# paparazzi 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 for more details.
#
# You should have received a copy of the GNU General Public License
# along with paparazzi; see the file COPYING. If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
#
# This is the common Makefile for the arm7-target.
#
#TODO: this is not needed in some cases (e.g. ap target as it is defined there already)
# but it is needed for other targets like tunnel
# only define here or elsewhere?
SRC_ARCH = arch/lpc21
# Programs location
# try to find the paparazzi multilib toolchain
TOOLCHAIN=$(shell find -L /opt/paparazzi/arm-multilib ~/sat -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1)
#
# found the new paparazzi toolchain, use it
#
ifneq ($(TOOLCHAIN),)
TOOLCHAIN_DIR=$(shell dirname $(TOOLCHAIN))
GCC_BIN_DIR=$(TOOLCHAIN_DIR)/bin
GCC_LIB_DIR=$(TOOLCHAIN_DIR)/arm-none-eabi/lib
GCC_BIN_PREFIX=$(GCC_BIN_DIR)/arm-none-eabi
CC = $(GCC_BIN_PREFIX)-gcc
LD = $(GCC_BIN_PREFIX)-gcc
OBJCOPY = $(GCC_BIN_PREFIX)-objcopy
OBJDUMP = $(GCC_BIN_PREFIX)-objdump
NM = $(GCC_BIN_PREFIX)-nm
SIZE = $(GCC_BIN_PREFIX)-size
#
# If we can't find the toolchain (in /opt/paparazzi/arm-multilib or ~/sat) then try picking up the compilers from the path
#
else
# see if we can find the new arm-none-eabi, otherwise use the older arm-elf
HAVE_ARM_NONE_EABI_GCC := $(shell which arm-none-eabi-gcc)
ifeq ($(strip $(HAVE_ARM_NONE_EABI_GCC)),)
GCC_PREFIX = arm-elf
else
GCC_PREFIX = arm-none-eabi
GCC_LIB_DIR=$(shell dirname `which arm-none-eabi-gcc`)/../arm-none-eabi/lib
endif
CC = $(shell which $(GCC_PREFIX)-gcc)
LD = $(shell which $(GCC_PREFIX)-gcc)
OBJCOPY = $(shell which $(GCC_PREFIX)-objcopy)
OBJDUMP = $(shell which $(GCC_PREFIX)-objdump)
NM = $(shell which $(GCC_PREFIX)-nm)
SIZE = $(shell which $(GCC_PREFIX)-size)
endif
#first try to find OpenOCD in the path
OOCD = $(shell which openocd)
#if OpenOCD could not be found in the path, try the toolchain dir
ifeq ($(OOCD),)
ifneq ($(TOOLCHAIN),)
OOCD = $(shell if test -e $(TOOLCHAIN_DIR)/bin/openocd ; then echo $(TOOLCHAIN_DIR)/bin/openocd ; else echo "Warning: OpenOCD not found"; fi)
endif
endif
# Define some other programs and commands.
SHELL = sh
REMOVE = rm -f
COPY = cp
MULTILIB = $(shell if $(CC) --print-multi-lib | grep thumb2 > /dev/null ; then echo "yes"; else echo "no"; fi)
# Launch with "make Q=''" to get full command display
Q=@
# MCU name and submodel
MCU = arm7tdmi
THUMB = -mthumb
THUMB_IW = -mthumb-interwork
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
#FLASH_MODE=ISP
SRCARM = $($(TARGET).srcs)
ASRCARM = crt0.S
# Optimization level, can be [0, 1, 2, 3, s].
# 0 = turn off optimization. s = optimize for size.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = s
#OPT=3
CSTANDARD = -std=gnu99
CINCS = $(INCLUDES) -I$(SRC_ARCH)/include
# Compiler flags.
CFLAGS = $(CINCS)
CFLAGS += -O$(OPT)
# CFLAGS += -malignment-traps
CFLAGS += -Wall -Wcast-qual -Wimplicit -Wcast-align
CFLAGS += -Wpointer-arith -Wswitch
CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow -Wunused
CFLAGS += -Wa,-adhlns=$(OBJDIR)/$(notdir $(subst $(suffix $<),.lst,$<))
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -finline-limit=1200 --param inline-unit-growth=100
# flags only for C
CFLAGS += -Wstrict-prototypes -Wmissing-declarations
CFLAGS += -Wmissing-prototypes -Wnested-externs
CFLAGS += $(CSTANDARD)
CFLAGS += $($(TARGET).CFLAGS) $(LOCAL_CFLAGS)
# Assembler flags.
ASFLAGS = -Wa,-adhlns=$(OBJDIR)/$(notdir $(<:.S=.lst))
#Additional libraries.
MATH_LIB = -lm
# Linker flags.
LDFLAGS = -n -nostartfiles -Wl,-Map=$(OBJDIR)/$(TARGET).map,--cref
LDFLAGS += -lc
LDFLAGS += $(MATH_LIB)
LDFLAGS += -lc -lgcc
LDFLAGS += $(CPLUSPLUS_LIB)
LDFLAGS += -Wl,--gc-sections
# -lusbstack -Larm7/lpcusb
ifndef LDSCRIPT
ifeq ($(FLASH_MODE),ISP)
LDSCRIPT = $(SRC_ARCH)/LPC2148-ROM.ld
else
LDSCRIPT = $(SRC_ARCH)/LPC2148-ROM-bl.ld
endif
endif
LDFLAGS +=-T$(LDSCRIPT)
# ---------------------------------------------------------------------------
# Flash-Programming support using lpc21isp by Martin Maurer
# Settings and variables:
LPC21ISP = lpc21isp
ifndef LPC21ISP_PORT
LPC21ISP_PORT = /dev/ttyS0
endif
LPC21ISP_FLASHFILE = $(OBJDIR)/$(TARGET).hex
# verbose output:
#LPC21ISP_DEBUG = -debug
# enter bootloader via RS232 DTR/RTS (only if hardware supports this
# feature - see Philips AppNote):
ifndef LPC21ISP_CONTROL
LPC21ISP_CONTROL =
# -control
endif
# ---------------------------------------------------------------------------
# Flash-Programming support using lpc21iap by Martin Muller (usb bootloader)
LPC21IAP = $(PAPARAZZI_SRC)/sw/ground_segment/lpc21iap/lpc21iap
# ---------------------------------------------------------------------------
# Flash-Programming support using openocd
OOCD_INTERFACE = arm-usb-ocd
OOCD_TARGET = csc
# Define all object files.
COBJ = $(SRC:%.c=$(OBJDIR)/%.o)
AOBJ = $(ASRC:%.S=$(OBJDIR)/%.o)
COBJARM = $(SRCARM:%.c=$(OBJDIR)/%.o)
AOBJARM = $(ASRCARM:%.S=$(OBJDIR)/%.o)
# Define all listing files.
LST = $(ASRC:.S=.lst) $(ASRCARM:.S=.lst) $(SRC:.c=.lst) $(SRCARM:.c=.lst)
# Compiler flags to generate dependency files.
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. $(CFLAGS)
ALL_ASFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. -x assembler-with-cpp $(ASFLAGS)
# Default target.
all: printcommands printmultilib sizebefore build sizeafter
printcommands:
@echo "Using CC = $(CC)"
@echo "Using LD = $(LD)"
@echo "Using CP = $(OBJCOPY)"
@echo "Using DMP = $(OBJDUMP)"
@echo "Using NM = $(NM)"
@echo "Using SIZE = $(SIZE)"
@echo "GCC version:"
@$(CC) --version | head -1
ifeq ("$(MULTILIB)","yes")
printmultilib:
@echo "*** Using multilib ***"
@echo "--------------------------------------"
else
printmultilib:
@echo "*** NOT using multilib ***"
@echo "--------------------------------------"
endif
build: elf hex lss sym
elf: $(OBJDIR)/$(TARGET).elf
hex: $(OBJDIR)/$(TARGET).hex
lss: $(OBJDIR)/$(TARGET).lss
sym: $(OBJDIR)/$(TARGET).sym
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(OBJDIR)/$(TARGET).hex
ELFSIZE = $(SIZE) -A $(OBJDIR)/$(TARGET).elf
sizebefore:
@if [ -f $(OBJDIR)/$(TARGET).elf ]; then echo; echo "Previous size:"; $(ELFSIZE); fi
sizeafter:
@if [ -f $(OBJDIR)/$(TARGET).elf ]; then echo; echo "Current size:"; $(ELFSIZE); fi
# Program the device.
load upload program: $(OBJDIR)/$(TARGET).hex
ifeq ($(FLASH_MODE),IAP)
$(SUDO) $(LPC21IAP) $(OBJDIR)/$(TARGET).elf
else ifeq ($(FLASH_MODE),JTAG)
@echo "Using OOCD = $(OOCD)"
@echo -e " OOCD\t$<"
$(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \
-f board/$(OOCD_TARGET).cfg \
-c init \
-c "reset halt" \
-c "flash write_image erase $(OBJDIR)/$(TARGET).bin 0x08000000" \
-c reset \
-c shutdown
else
@echo
$(LPC21ISP) $(LPC21ISP_CONTROL) $(LPC21ISP_DEBUG) $(LPC21ISP_FLASHFILE) $(LPC21ISP_PORT) $(LPC21ISP_BAUD) $(LPC21ISP_XTAL)
endif
# Create final output files (.hex, .eep) from ELF output file.
# TODO: handling the .eeprom-section should be redundant
%.hex: %.elf
@echo OBJC $@
$(Q)$(OBJCOPY) -O $(FORMAT) $< $@
# Create extended listing file from ELF output file.
# testing: option -C
%.lss: %.elf
@echo OBJD $@
$(Q)$(OBJDUMP) -h -S -C $< > $@
# Create a symbol table from ELF output file.
%.sym: %.elf
@echo NM $@
$(Q)$(NM) -n $< > $@
# Link: create ELF output file from object files.
.SECONDARY : $(OBJDIR)/$(TARGET).elf
.PRECIOUS : $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ)
%.elf: $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ)
@echo LD $@
$(Q)$(CC) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) --output $@ $(LDFLAGS) $($(TARGET).LDFLAGS)
# Compile: create object files from C source files. ARM-only
$(OBJDIR)/%.o : %.c $(OBJDIR)/../Makefile.ac
@echo CC $@
$(Q)test -d $(dir $@) || mkdir -p $(dir $@)
$(Q)$(CC) -c $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
$(OBJDIR)/%.o : $(SRC_ARCH)/lpcusb/%.c $(OBJDIR)/../Makefile.ac
@echo CC $@
$(Q)$(CC) -c $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
# grab files in var/$(AIRCRAFT)/$(TARGET) aka $(OBJDIR)
#$(OBJDIR)/%.o : $(OBJDIR)/%.c
# @echo CC $@
# $(Q)$(CC) -c $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
# Assemble: create object files from assembler source files. ARM/Thumb
$(AOBJ) : $(OBJDIR)/%.o : %.S
@echo AS $@
$(Q)$(CC) -c $(THUMB) $(ALL_ASFLAGS) $< -o $@
# Assemble: create object files from assembler source files. ARM-only
$(AOBJARM) : $(OBJDIR)/%.o : $(SRC_ARCH)/%.S
@echo AS $@
$(Q)$(CC) -c $(ALL_ASFLAGS) $< -o $@
# Target: clean project.
clean: clean_list
clean_list :
@echo
$(REMOVE) $(OBJDIR)/$(TARGET).hex
$(REMOVE) $(OBJDIR)/$(TARGET).obj
$(REMOVE) $(OBJDIR)/$(TARGET).elf
$(REMOVE) $(OBJDIR)/$(TARGET).map
$(REMOVE) $(OBJDIR)/$(TARGET).obj
$(REMOVE) $(OBJDIR)/$(TARGET).a90
$(REMOVE) $(OBJDIR)/$(TARGET).sym
$(REMOVE) $(OBJDIR)/$(TARGET).lnk
$(REMOVE) $(OBJDIR)/$(TARGET).lss
$(REMOVE) $(COBJ)
$(REMOVE) $(AOBJ)
$(REMOVE) $(COBJARM)
$(REMOVE) $(AOBJARM)
$(REMOVE) $(LST)
$(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRC:.c=.d)
$(REMOVE) $(SRCARM:.c=.s)
$(REMOVE) $(SRCARM:.c=.d)
$(REMOVE) .dep/*
$(REMOVE) *~
# Listing of phony targets.
.PHONY : all sizebefore sizeafter \
build elf hex lss sym clean clean_list program
#
# Dependencies
#
$(OBJDIR)/.depend:
@echo DEPEND $@
@test -d $(OBJDIR) || mkdir -p $(OBJDIR)
$(Q)$(CC) -MM -MG $(CFLAGS) $($(TARGET).srcs) | sed 's|\([^\.]*\.o\)|$(OBJDIR)/\1|' > $@
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),erase)
-include $(OBJDIR)/.depend
endif
endif
Computing file changes ...