From 043cf7246d9381c35cd4b34be8ca65f7541f35c2 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Fri, 8 Feb 2013 15:12:34 +0100 Subject: [PATCH] [build system] more makefile cleanup for lpc stuff - removed usb_lib target, not used anywhere - fix lpc bootloader makefile --- Makefile | 2 +- Makefile.lpctools | 10 ++-- conf/Makefile.arm-common | 44 +---------------- conf/Makefile.arm-toolchain | 48 +++++++++++++++++++ conf/Makefile.lpc21 | 1 - sw/airborne/arch/lpc21/lpcusb/Makefile | 4 +- .../arch/lpc21/test/bootloader/Makefile | 8 ++-- 7 files changed, 60 insertions(+), 57 deletions(-) create mode 100644 conf/Makefile.arm-toolchain diff --git a/Makefile b/Makefile index d0ddb69747..1be3a02756 100644 --- a/Makefile +++ b/Makefile @@ -206,7 +206,7 @@ sim: sim_static # stuff to build and upload the lpc bootloader ... include Makefile.lpctools -lpctools: lpc21iap usb_lib +lpctools: lpc21iap commands: paparazzi diff --git a/Makefile.lpctools b/Makefile.lpctools index b8ccbdb350..0a4d0a10cc 100644 --- a/Makefile.lpctools +++ b/Makefile.lpctools @@ -1,23 +1,19 @@ # Hey Emacs, this is a -*- makefile -*- -usb_lib: - @[ -d sw/airborne/arch/lpc21/lpcusb ] && (cd sw/airborne/arch/lpc21/lpcusb; $(MAKE)) || echo "Not building usb_lib: sw/airborne/arch/lpc21/lpcusb directory missing" - bl: cd $(AIRBORNE)/arch/lpc21/test/bootloader; $(MAKE) clean; $(MAKE) -BOOTLOADER_DEV=/dev/ttyUSB0 +BOOTLOADER_DEV ?= /dev/ttyUSB0 upload_bl bl.upload: bl lpc21isp -control $(AIRBORNE)/arch/lpc21/test/bootloader/bl.hex $(BOOTLOADER_DEV) 38400 12000 -JTAG_INTERFACE = olimex-jtag-tiny.cfg +JTAG_INTERFACE ?= olimex-jtag-tiny.cfg #JTAG_INTERFACE = olimex-arm-usb-ocd.cfg upload_jtag: bl openocd -f interface/$(JTAG_INTERFACE) -f board/olimex_lpc_h2148.cfg -c init -c halt -c "flash write_image erase $(AIRBORNE)/arch/lpc21/test/bootloader/bl.hex" -c reset -c shutdown - lpc21iap: $(MAKE) -C sw/ground_segment/lpc21iap @@ -32,4 +28,4 @@ ms: upload_ms ms.upload: ms $(PAPARAZZI_SRC)/sw/ground_segment/lpc21iap/lpc21iap $(AIRBORNE)/arch/lpc21/lpcusb/examples/msc.elf -.PHONY: usb_lib bl upload_bl upload_jtag ms upload_ms lpc21iap upgrade_bl +.PHONY: bl upload_bl upload_jtag ms upload_ms lpc21iap upgrade_bl diff --git a/conf/Makefile.arm-common b/conf/Makefile.arm-common index e2e08640ac..bced43ce9c 100644 --- a/conf/Makefile.arm-common +++ b/conf/Makefile.arm-common @@ -23,49 +23,7 @@ # This is the common Makefile for finding the arm compiler and OpenOcd # -# -# 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 - +include $(PAPARAZZI_SRC)/conf/Makefile.arm-toolchain # # some generic and informative targets diff --git a/conf/Makefile.arm-toolchain b/conf/Makefile.arm-toolchain new file mode 100644 index 0000000000..91fe17aa3f --- /dev/null +++ b/conf/Makefile.arm-toolchain @@ -0,0 +1,48 @@ +# 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 diff --git a/conf/Makefile.lpc21 b/conf/Makefile.lpc21 index 436790f8c2..180500e6d3 100644 --- a/conf/Makefile.lpc21 +++ b/conf/Makefile.lpc21 @@ -107,7 +107,6 @@ LDFLAGS += $(MATH_LIB) LDFLAGS += -lc -lgcc LDFLAGS += $(CPLUSPLUS_LIB) LDFLAGS += -Wl,--gc-sections -# -lusbstack -Larm7/lpcusb ifndef LDSCRIPT ifeq ($(FLASH_MODE),ISP) diff --git a/sw/airborne/arch/lpc21/lpcusb/Makefile b/sw/airborne/arch/lpc21/lpcusb/Makefile index 8eda73cec2..af7764bf44 100644 --- a/sw/airborne/arch/lpc21/lpcusb/Makefile +++ b/sw/airborne/arch/lpc21/lpcusb/Makefile @@ -32,7 +32,7 @@ DATE = $$(date +%Y%m%d) # # find compiler toolchain # -include $(PAPARAZZI_SRC)/conf/Makefile.arm-common +include $(PAPARAZZI_SRC)/conf/Makefile.arm-toolchain # # if the new arm-none-eabi multilib compiler was not found try the old arm-elf one @@ -82,6 +82,6 @@ depend: $(LIBSRCS) $(Q)$(CC) $(CFLAGS) -MM $^ > .depend || rm -f .depend # phony targets -.PHONY: all clean depend +.PHONY: all clean lib dist depend -include .depend diff --git a/sw/airborne/arch/lpc21/test/bootloader/Makefile b/sw/airborne/arch/lpc21/test/bootloader/Makefile index ae619bc8d9..7f7bc7666b 100644 --- a/sw/airborne/arch/lpc21/test/bootloader/Makefile +++ b/sw/airborne/arch/lpc21/test/bootloader/Makefile @@ -18,7 +18,7 @@ LINKFILE_RAM = lpc2148-ram.ld # # try to find the paparazzi multilib toolchain # -include $(PAPARAZZI_SRC)/conf/Makefile.arm-common +include $(PAPARAZZI_SRC)/conf/Makefile.arm-toolchain TAR = tar @@ -49,7 +49,7 @@ lib: $(LIBOBJS) app: $(APPNAME).elf $(Q)echo "...copying" $(CP) $(CPFLAGS) $(APPNAME).elf $(APPNAME).hex - $(OD) $(ODFLAGS) $(APPNAME).elf > $(APPNAME).dmp + $(DMP) $(ODFLAGS) $(APPNAME).elf > $(APPNAME).dmp # $(Q)echo "....loading" # ./lpc21isp -control bl.hex com4 38400 12000 # ./lpc21isp -control -termonly bl.hex com4 115200 12000 @@ -57,7 +57,7 @@ app: $(APPNAME).elf app_ram: $(APPNAME_RAM).elf $(Q)echo "...copying" $(CP) $(CPFLAGS) $(APPNAME_RAM).elf $(APPNAME_RAM).hex - $(OD) $(ODFLAGS) $(APPNAME_RAM).elf > $(APPNAME_RAM).dmp + $(DMP) $(ODFLAGS) $(APPNAME_RAM).elf > $(APPNAME_RAM).dmp $(APPNAME).elf: $(OBJS) $(LIBNAME).a $(LINKFILE) $(Q)echo "..linking" @@ -81,3 +81,5 @@ dist: clean # recompile if the Makefile changes $(OBJS) $(LIBOBJS): Makefile + +.PHONY: all clean lib app app_ram arch dist