diff --git a/conf/Makefile.arm-common b/conf/Makefile.arm-common index 9059041e76..3f24704557 100644 --- a/conf/Makefile.arm-common +++ b/conf/Makefile.arm-common @@ -29,11 +29,11 @@ printcommands: @echo "" @echo "Using CC = $(CC)" - @echo "Using LD = $(LD)" - @echo "Using CP = $(CP)" - @echo "Using DMP = $(DMP)" - @echo "Using NM = $(NM)" - @echo "Using SIZE = $(SIZE)" +# @echo "Using LD = $(LD)" +# @echo "Using CP = $(CP)" +# @echo "Using DMP = $(DMP)" +# @echo "Using NM = $(NM)" +# @echo "Using SIZE = $(SIZE)" @echo "GCC version:" @$(CC) --version | head -1 @echo "" diff --git a/conf/Makefile.arm-embedded b/conf/Makefile.arm-embedded index d66abd01db..f3022f8190 100644 --- a/conf/Makefile.arm-embedded +++ b/conf/Makefile.arm-embedded @@ -47,15 +47,3 @@ clean_list : $(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 diff --git a/conf/Makefile.arm-embedded-toolchain b/conf/Makefile.arm-embedded-toolchain index afc7fbe0ad..917ccba4ad 100644 --- a/conf/Makefile.arm-embedded-toolchain +++ b/conf/Makefile.arm-embedded-toolchain @@ -1,52 +1,36 @@ # Hey Emacs, this is a -*- makefile -*- # -# Copyright (C) 2012 Felix Ruess +# Copyright (C) 2012-2013 Felix Ruess # -# This is the common Makefile for finding the arm compiler and OpenOcd +# This is the common Makefile for finding the arm compiler # for bare metal systems like on the ARM7TDMI, cortex M3/4 -# -# 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 +PREFIX ?= arm-none-eabi # -# if not found in path, try the paparazzi toolchain in /opt +# if gcc can't be 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... -$(error Error: arm-none-eabi-gcc cross-compiler not found! Recommended toolchain is https://launchpad.net/gcc-arm-embedded) -endif +ifeq ($(shell which $(PREFIX)-gcc),) + PPRZ_TOOLCHAIN=$(shell find -L /opt/paparazzi/arm-multilib -maxdepth 1 -type d -name arm-none-eabi 2>/dev/null | head -n 1) + ifneq ($(PPRZ_TOOLCHAIN),) + # set prefix with full path to /opt/paparazzi/arm-multilib toolchain + PREFIX=$(shell dirname $(PPRZ_TOOLCHAIN))/bin/arm-none-eabi + else + # no suitable toolchain found... + $(error Error: arm-none-eabi-gcc cross-compiler not found! Recommended toolchain is https://launchpad.net/gcc-arm-embedded) + endif endif +CC = $(PREFIX)-gcc +LD = $(PREFIX)-gcc +AR = $(PREFIX)-ar +CP = $(PREFIX)-objcopy +DMP = $(PREFIX)-objdump +NM = $(PREFIX)-nm +SIZE = $(PREFIX)-size +GDB = $(PREFIX)-gdb # some general commands RM = rm diff --git a/conf/Makefile.arm-linux b/conf/Makefile.arm-linux index c5994d10c0..f767a488be 100644 --- a/conf/Makefile.arm-linux +++ b/conf/Makefile.arm-linux @@ -6,51 +6,32 @@ # Minimal makefile for arm-linux-gnueabi or arm-none-linux-gnueabi toolchain. # Assuming installed in default location. +PREFIX ?= arm-linux-gnueabi # -# try to pick up the compiler from the path +# if gcc can't be found in path, try the codesourcery toolchain in /usr/local/codesourcery # -CC = $(shell which arm-linux-gnueabi-gcc) -LD = $(shell which arm-linux-gnueabi-gcc) -AR = $(shell which arm-linux-gnueabi-ar) -CP = $(shell which arm-linux-gnueabi-objcopy) -DMP = $(shell which arm-linux-gnueabi-objdump) -NM = $(shell which arm-linux-gnueabi-nm) -SIZE = $(shell which arm-linux-gnueabi-size) -GDB = $(shell which arm-linux-gnueabi-gdb) -TOOLCHAIN_DIR=$(shell dirname `which arm-linux-gnueabi`) -GCC_LIB_DIR=$(TOOLCHAIN_DIR)/../arm-linux-gnueabi/lib - -# if the above toolchain is used add the include folder -CFLAGS += -I/usr/arm-linux-gnueabi/include - -# -# if not found in path, try the codesourcery toolchain in /usr/local/codesourcery -# -ifeq ($(CC),) -TOOLCHAIN=$(shell find -L /usr/local/codesourcery -maxdepth 2 -type d -name arm-none-linux-gnueabi 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-linux-gnueabi/lib - -# Define programs and commands. -GCC_BIN_PREFIX=$(GCC_BIN_DIR)/arm-none-linux-gnueabi -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 +ifeq ($(shell which $(PREFIX)-gcc),) + TOOLCHAIN=$(shell find -L /usr/local/codesourcery -maxdepth 2 -type d -name arm-none-linux-gnueabi 2>/dev/null | head -n 1) + ifneq ($(TOOLCHAIN),) + PREFIX=$(shell dirname $(TOOLCHAIN))/bin/arm-none-linux-gnueabi + else + # no suitable toolchain found... + $(error Error: arm-linux-gnueabi-gcc cross-compiler not found! Please install the gcc-arm-linux-gnueabi package.) + endif else -# toolchain not found... -endif + # this was previously explicitly added, but shouln't be needed... + #CFLAGS += -I/usr/arm-linux-gnueabi/include endif -# checking if gcc has thumb2 instruction -MULTILIB = $(shell if $(CC) --print-multi-lib | grep thumb2 > /dev/null ; then echo "yes"; else echo "no"; fi) +CC = $(PREFIX)-gcc +LD = $(PREFIX)-gcc +AR = $(PREFIX)-ar +CP = $(PREFIX)-objcopy +DMP = $(PREFIX)-objdump +NM = $(PREFIX)-nm +SIZE = $(PREFIX)-size +GDB = $(PREFIX)-gdb # some general commands RM = rm diff --git a/conf/Makefile.lpc21 b/conf/Makefile.lpc21 index 80fd9c2e16..5d2ea4acbb 100644 --- a/conf/Makefile.lpc21 +++ b/conf/Makefile.lpc21 @@ -144,6 +144,7 @@ LPC21IAP = $(PAPARAZZI_SRC)/sw/ground_segment/lpc21iap/lpc21iap # --------------------------------------------------------------------------- # Flash-Programming support using openocd +OOCD ?= openocd OOCD_INTERFACE = arm-usb-ocd OOCD_TARGET = csc diff --git a/conf/Makefile.omap b/conf/Makefile.omap index 876099cbec..21eb4d55b6 100644 --- a/conf/Makefile.omap +++ b/conf/Makefile.omap @@ -69,7 +69,7 @@ OBJ_C_OMAP = $(SRC_C_OMAP:%.c=$(OBJDIR)/%.o) SRC_CPP_OMAP = $($(TARGET).cpp_srcs) OBJ_CPP_OMAP = $(SRC_CPP_OMAP:%.cpp=$(OBJDIR)/%.o) -all: build +all: printcommands build build: $(OBJDIR) elf diff --git a/conf/Makefile.stm32-upload b/conf/Makefile.stm32-upload index 2c960fb1bb..d19b0e6f36 100644 --- a/conf/Makefile.stm32-upload +++ b/conf/Makefile.stm32-upload @@ -59,6 +59,7 @@ else ifeq ($(FLASH_MODE),JTAG) # either via normal jtag or BlackMagicProbe ifeq ($(BMP_PORT),) # normal jtag via OpenOCD +OOCD ?= openocd upload: $(OBJDIR)/$(TARGET).hex @echo "Assuming luftboot bootloader: $(ASSUMING_LUFTBOOT)" @echo "Using OOCD = $(OOCD)" diff --git a/sw/ext/Makefile b/sw/ext/Makefile index c3934a7980..ca213e8270 100644 --- a/sw/ext/Makefile +++ b/sw/ext/Makefile @@ -27,22 +27,10 @@ Q=@ PAPARAZZI_SRC=../.. EXT_DIR=$(PAPARAZZI_SRC)/sw/ext -PREFIX = arm-none-eabi - # -# if we can't find arm-none-eabi-gcc in the path, overwrite PREFIX with explicit path +# find compiler toolchain # -HAVE_ARM_NONE_EABI_GCC := $(shell which arm-none-eabi-gcc) - -ifeq ($(strip $(HAVE_ARM_NONE_EABI_GCC)),) -# not found in PATH, check paparazzi toolchain - - 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)) - PREFIX = $(TOOLCHAIN_DIR)/bin/arm-none-eabi - endif -endif +include $(PAPARAZZI_SRC)/conf/Makefile.arm-embedded-toolchain all: libopencm3.module luftboot.module