aboutsummaryrefslogtreecommitdiff
path: root/examples/lm3s
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/lm3s
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/lm3s')
-rw-r--r--examples/lm3s/Makefile.include11
1 files changed, 8 insertions, 3 deletions
diff --git a/examples/lm3s/Makefile.include b/examples/lm3s/Makefile.include
index c119846..4d774be 100644
--- a/examples/lm3s/Makefile.include
+++ b/examples/lm3s/Makefile.include
@@ -24,9 +24,14 @@ CC = $(PREFIX)-gcc
LD = $(PREFIX)-gcc
OBJCOPY = $(PREFIX)-objcopy
OBJDUMP = $(PREFIX)-objdump
-# 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_lm3s.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 += -O0 -g3 -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
-mcpu=cortex-m3 -mthumb -MD
LDSCRIPT ?= $(BINARY).ld