aboutsummaryrefslogtreecommitdiff
path: root/examples/lpc17xx/Makefile.include
diff options
context:
space:
mode:
Diffstat (limited to 'examples/lpc17xx/Makefile.include')
-rw-r--r--examples/lpc17xx/Makefile.include6
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/lpc17xx/Makefile.include b/examples/lpc17xx/Makefile.include
index 66688d3..6d7bbfe 100644
--- a/examples/lpc17xx/Makefile.include
+++ b/examples/lpc17xx/Makefile.include
@@ -24,14 +24,18 @@ CC = $(PREFIX)-gcc
LD = $(PREFIX)-gcc
OBJCOPY = $(PREFIX)-objcopy
OBJDUMP = $(PREFIX)-objdump
+
+TOOLCHAIN_DIR ?= ../../../..
ifeq ($(wildcard ../../../../lib/libopencm3_lpc17xx.a),)
+ifneq ($(strip $(shell which $(CC))),)
TOOLCHAIN_DIR := $(shell dirname `which $(CC)`)/../$(PREFIX)
+endif
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 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
-mcpu=cortex-m3 -mthumb -MD
LDSCRIPT ?= $(BINARY).ld