[Makefile] slightly improve common arm makefiles

This commit is contained in:
Felix Ruess
2013-04-27 14:47:41 +02:00
parent 0fa2b7e773
commit 6eaf41cf17
6 changed files with 111 additions and 100 deletions
+103
View File
@@ -0,0 +1,103 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright (C) 2012 Felix Ruess <felix.ruess@gmail.com>
#
# This is the common Makefile for finding the arm compiler and OpenOcd
# for bare metal systems like on the ARM7TDMI, cortex M3/4
include $(PAPARAZZI_SRC)/conf/Makefile.arm-common
#
# try to pick up the compiler from the path
#
CC = $(shell which arm-none-eabi-gcc)
LD = $(shell which arm-none-eabi-gcc)
AR = $(shell which arm-none-eabi-ar)
CP = $(shell which arm-none-eabi-objcopy)
DMP = $(shell which arm-none-eabi-objdump)
NM = $(shell which arm-none-eabi-nm)
SIZE = $(shell which arm-none-eabi-size)
GDB = $(shell which arm-none-eabi-gdb)
TOOLCHAIN_DIR=$(shell dirname `which arm-none-eabi-gcc`)
GCC_LIB_DIR=$(TOOLCHAIN_DIR)/../arm-none-eabi/lib
#
# if not found in path, try the paparazzi toolchain in /opt
#
ifeq ($(CC),)
TOOLCHAIN=$(shell find -L /opt/paparazzi/arm-multilib -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1)
ifneq ($(TOOLCHAIN),)
TOOLCHAIN_DIR=$(shell dirname $(TOOLCHAIN))
GCC_BIN_DIR=$(TOOLCHAIN_DIR)/bin
GCC_LIB_DIR=$(TOOLCHAIN_DIR)/arm-none-eabi/lib
# Define programs and commands.
GCC_BIN_PREFIX=$(GCC_BIN_DIR)/arm-none-eabi
CC = $(GCC_BIN_PREFIX)-gcc
LD = $(GCC_BIN_PREFIX)-gcc
AR = $(GCC_BIN_PREFIX)-ar
CP = $(GCC_BIN_PREFIX)-objcopy
DMP = $(GCC_BIN_PREFIX)-objdump
NM = $(GCC_BIN_PREFIX)-nm
SIZE = $(GCC_BIN_PREFIX)-size
GDB = $(GCC_BIN_PREFIX)-gdb
else
# toolchain not found...
endif
endif
# some general commands
RM = rm
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(OBJDIR)/$(TARGET).hex
ELFSIZE = $(SIZE) -A -x $(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
# Target: clean project.
clean: clean_list
clean_list :
@echo
$(RM) $(OBJDIR)/$(TARGET).hex
$(RM) $(OBJDIR)/$(TARGET).obj
$(RM) $(OBJDIR)/$(TARGET).elf
$(RM) $(OBJDIR)/$(TARGET).map
$(RM) $(OBJDIR)/$(TARGET).obj
$(RM) $(OBJDIR)/$(TARGET).a90
$(RM) $(OBJDIR)/$(TARGET).sym
$(RM) $(OBJDIR)/$(TARGET).lnk
$(RM) $(OBJDIR)/$(TARGET).lss
$(RM) $(COBJ)
$(RM) $(AOBJ)
$(RM) $(COBJARM)
$(RM) $(AOBJARM)
$(RM) $(LST)
$(RM) $(SRC:.c=.s)
$(RM) $(SRC:.c=.d)
$(RM) $(SRCARM:.c=.s)
$(RM) $(SRCARM:.c=.d)
$(RM) .dep/*
$(RM) *~
.PHONY : sizebefore sizeafter clean clean_list
#
# Find OpenOCD
#
# first try in the path
OOCD = $(shell which openocd)
#if OpenOCD could not be found in the path, try the toolchain dir (for backwards compatibility)
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
+1 -48
View File
@@ -23,8 +23,6 @@
# This is the common Makefile for finding the arm compiler and OpenOcd # This is the common Makefile for finding the arm compiler and OpenOcd
# #
include $(PAPARAZZI_SRC)/conf/Makefile.arm-toolchain
# #
# some generic and informative targets # some generic and informative targets
# #
@@ -40,51 +38,6 @@ printcommands:
@$(CC) --version | head -1 @$(CC) --version | head -1
@echo "" @echo ""
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(OBJDIR)/$(TARGET).hex
ELFSIZE = $(SIZE) -A -x $(OBJDIR)/$(TARGET).elf
sizebefore:
@if [ -f $(OBJDIR)/$(TARGET).elf ]; then echo; echo "Previous size:"; $(ELFSIZE); fi
sizeafter: .PHONY : printcommands
@if [ -f $(OBJDIR)/$(TARGET).elf ]; then echo; echo "Current size:"; $(ELFSIZE); fi
# Target: clean project.
clean: clean_list
clean_list :
@echo
$(RM) $(OBJDIR)/$(TARGET).hex
$(RM) $(OBJDIR)/$(TARGET).obj
$(RM) $(OBJDIR)/$(TARGET).elf
$(RM) $(OBJDIR)/$(TARGET).map
$(RM) $(OBJDIR)/$(TARGET).obj
$(RM) $(OBJDIR)/$(TARGET).a90
$(RM) $(OBJDIR)/$(TARGET).sym
$(RM) $(OBJDIR)/$(TARGET).lnk
$(RM) $(OBJDIR)/$(TARGET).lss
$(RM) $(COBJ)
$(RM) $(AOBJ)
$(RM) $(COBJARM)
$(RM) $(AOBJARM)
$(RM) $(LST)
$(RM) $(SRC:.c=.s)
$(RM) $(SRC:.c=.d)
$(RM) $(SRCARM:.c=.s)
$(RM) $(SRCARM:.c=.d)
$(RM) .dep/*
$(RM) *~
.PHONY : printcommands sizebefore sizeafter clean clean_list
#
# Find OpenOCD
#
# first try in the path
OOCD = $(shell which openocd)
#if OpenOCD could not be found in the path, try the toolchain dir (for backwards compatibility)
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
@@ -1,7 +1,10 @@
# Hey Emacs, this is a -*- makefile -*-
# #
# Copyright (C) 2012 - TU Delft Robotics Minor - Dino Hensen and Freek van Tienen # Copyright (C) 2012 - TU Delft Robotics Minor - Dino Hensen and Freek van Tienen
# #
# Minimal makefile for arm-linux-gnueabi or arm-none-linux-gnueabi toolchain. Assuming installed in default location. # Minimal makefile for arm-linux-gnueabi or arm-none-linux-gnueabi toolchain.
# Assuming installed in default location.
# #
@@ -52,5 +55,5 @@ MULTILIB = $(shell if $(CC) --print-multi-lib | grep thumb2 > /dev/null ; then e
# some general commands # some general commands
RM = rm RM = rm
@echo "Using CC = $(CC)"
include $(PAPARAZZI_SRC)/conf/Makefile.arm-common
-48
View File
@@ -1,48 +0,0 @@
# Hey Emacs, this is a -*- makefile -*-
#
# This is the common Makefile for finding the arm compiler
#
#
# try to pick up the compiler from the path
#
CC = $(shell which arm-none-eabi-gcc)
LD = $(shell which arm-none-eabi-gcc)
AR = $(shell which arm-none-eabi-ar)
CP = $(shell which arm-none-eabi-objcopy)
DMP = $(shell which arm-none-eabi-objdump)
NM = $(shell which arm-none-eabi-nm)
SIZE = $(shell which arm-none-eabi-size)
GDB = $(shell which arm-none-eabi-gdb)
TOOLCHAIN_DIR=$(shell dirname `which arm-none-eabi-gcc`)
GCC_LIB_DIR=$(TOOLCHAIN_DIR)/../arm-none-eabi/lib
#
# if not found in path, try the paparazzi toolchain in /opt
#
ifeq ($(CC),)
TOOLCHAIN=$(shell find -L /opt/paparazzi/arm-multilib -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1)
ifneq ($(TOOLCHAIN),)
TOOLCHAIN_DIR=$(shell dirname $(TOOLCHAIN))
GCC_BIN_DIR=$(TOOLCHAIN_DIR)/bin
GCC_LIB_DIR=$(TOOLCHAIN_DIR)/arm-none-eabi/lib
# Define programs and commands.
GCC_BIN_PREFIX=$(GCC_BIN_DIR)/arm-none-eabi
CC = $(GCC_BIN_PREFIX)-gcc
LD = $(GCC_BIN_PREFIX)-gcc
AR = $(GCC_BIN_PREFIX)-ar
CP = $(GCC_BIN_PREFIX)-objcopy
DMP = $(GCC_BIN_PREFIX)-objdump
NM = $(GCC_BIN_PREFIX)-nm
SIZE = $(GCC_BIN_PREFIX)-size
GDB = $(GCC_BIN_PREFIX)-gdb
else
# toolchain not found...
endif
endif
# some general commands
RM = rm
+1 -1
View File
@@ -37,7 +37,7 @@ Q=@
# #
# find compiler toolchain # find compiler toolchain
# #
include $(PAPARAZZI_SRC)/conf/Makefile.arm-common include $(PAPARAZZI_SRC)/conf/Makefile.arm-baremetal
# #
# if the new arm-none-eabi multilib compiler was not found try the old arm-elf one # if the new arm-none-eabi multilib compiler was not found try the old arm-elf one
+1 -1
View File
@@ -34,7 +34,7 @@ Q=@
# #
# find compiler toolchain # find compiler toolchain
# #
include $(PAPARAZZI_SRC)/conf/Makefile.arm-common include $(PAPARAZZI_SRC)/conf/Makefile.arm-baremetal
MCU = cortex-m3 MCU = cortex-m3