From d5815595993b96fe56ae864dcf8d77b277392cb2 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Tue, 18 Oct 2011 02:19:16 +0200 Subject: [PATCH] main makefile and lpcusb: also look for compiler in /opt/paparazzi/arm-multilib --- Makefile | 13 +++++-- sw/airborne/arch/lpc21/lpcusb/Makefile | 50 ++++++++++++++++++-------- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 8ca30a80ec..e69105403d 100644 --- a/Makefile +++ b/Makefile @@ -61,14 +61,23 @@ UBX_XML = $(CONF)/ubx.xml MTK_XML = $(CONF)/mtk.xml XSENS_XML = $(CONF)/xsens_MTi-G.xml TOOLS=$(PAPARAZZI_SRC)/sw/tools +OCAML=$(shell which ocaml) +OCAMLRUN=$(shell which ocamlrun) + +# try to find the paparazzi multilib toolchain +TOOLCHAIN_DIR=$(shell find -L ~/sat /opt/paparazzi/arm-multilib -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1 | xargs dirname ) +ifneq ($(TOOLCHAIN_DIR),) +#found the compiler from the paparazzi multilib package +ARMGCC=$(TOOLCHAIN_DIR)/bin/arm-none-eabi-gcc +else +#try picking up the arm-none-eabi compiler from the path, otherwise use arm-elf HAVE_ARM_NONE_EABI_GCC := $(shell which arm-none-eabi-gcc) ifeq ($(strip $(HAVE_ARM_NONE_EABI_GCC)),) ARMGCC=$(shell which arm-elf-gcc) else ARMGCC=$(HAVE_ARM_NONE_EABI_GCC) endif -OCAML=$(shell which ocaml) -OCAMLRUN=$(shell which ocamlrun) +endif all: conf commands static diff --git a/sw/airborne/arch/lpc21/lpcusb/Makefile b/sw/airborne/arch/lpc21/lpcusb/Makefile index 505dae4dbc..584e9bfffe 100644 --- a/sw/airborne/arch/lpc21/lpcusb/Makefile +++ b/sw/airborne/arch/lpc21/lpcusb/Makefile @@ -5,24 +5,46 @@ PKG_NAME = target DATE = $$(date +%Y%m%d) # Tool definitions -HAVE_ARM_NONE_EABI_GCC := $(shell which arm-none-eabi-gcc) +# try to find the paparazzi multilib toolchain +TOOLCHAIN_DIR=$(shell find -L ~/sat /opt/paparazzi/arm-multilib -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1 | xargs dirname ) -ifeq ($(strip $(HAVE_ARM_NONE_EABI_GCC)),) -CC = arm-elf-gcc -LD = arm-elf-ld -v -AR = arm-elf-ar -AS = arm-elf-as -CP = arm-elf-objcopy -OD = arm-elf-objdump +# +# found the new paparazzi toolchain, use it +# +ifneq ($(TOOLCHAIN_DIR),) +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)-ld -v +AR = $(GCC_BIN_PREFIX)-ar +AS = $(GCC_BIN_PREFIX)-as +CP = $(GCC_BIN_PREFIX)-objcopy +OD = $(GCC_BIN_PREFIX)-objdump + +# +# If we can't find the toolchain (in ~/sat or /opt/paparazzi/arm-multilib) then try picking up the compilers from the path +# else -CC=arm-none-eabi-gcc -LD=arm-none-eabi-ld -v -AR=arm-none-eabi-ar -AS=arm-none-eabi-ar -CP=arm-none-eabi-objcopy -OD=arm-none-eabi-objdump + +# 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)-ld) -v +AR = $(shell which $(GCC_PREFIX)-ar) +AS = $(shell which $(GCC_PREFIX)-as) +CP = $(shell which $(GCC_PREFIX)-objcopy) +OD = $(shell which $(GCC_PREFIX)-objdump) +endif + +# Define some other programs and commands. RM = rm TAR = tar