aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32/f4
diff options
context:
space:
mode:
authorPiotr Esden-Tempski2012-08-13 15:23:07 -0700
committerPiotr Esden-Tempski2012-08-13 15:29:01 -0700
commitb82e7eee52f72200b9f4a615c299056c4e09e071 (patch)
tree4a4be05d201ad2bc33296aabe0093f5428c806bd /examples/stm32/f4
parent3441bba1c4fc2710bef73402f58b5499cea20b42 (diff)
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.
Diffstat (limited to 'examples/stm32/f4')
-rw-r--r--examples/stm32/f4/Makefile.include11
1 files changed, 8 insertions, 3 deletions
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