From b82e7eee52f72200b9f4a615c299056c4e09e071 Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Mon, 13 Aug 2012 15:23:07 -0700 Subject: Examples detect if they are being built in src dir. If an example is in the libopencm3 source directory it will use the locally built library instead of the system library. When you copy an example out of the libopencm3 tree it will automatically detect it and build using the system wide installation. --- examples/stm32/f4/Makefile.include | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'examples/stm32/f4') diff --git a/examples/stm32/f4/Makefile.include b/examples/stm32/f4/Makefile.include index 42e7162..2e915ce 100644 --- a/examples/stm32/f4/Makefile.include +++ b/examples/stm32/f4/Makefile.include @@ -26,9 +26,14 @@ LD = $(PREFIX)-gcc OBJCOPY = $(PREFIX)-objcopy OBJDUMP = $(PREFIX)-objdump GDB = $(PREFIX)-gdb -# Uncomment this line if you want to use the installed (not local) library. -#TOOLCHAIN_DIR := $(shell dirname `which $(CC)`)/../$(PREFIX) -TOOLCHAIN_DIR = ../../../../.. +ifeq ($(shell ls ../../../../../lib/libopencm3_stm32f4.a 2>/dev/null),) +TOOLCHAIN_DIR := $(shell dirname `which $(CC)`)/../$(PREFIX) +else +ifeq ($(V),1) +$(info We seem to be building the example in the source directory. Using local library!) +endif +TOOLCHAIN_DIR := ../../../../.. +endif CFLAGS += -Os -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include \ -fno-common -mcpu=cortex-m4 -mthumb -msoft-float -MD -DSTM32F4 LDSCRIPT ?= $(BINARY).ld -- cgit v1.2.3