aboutsummaryrefslogtreecommitdiff
path: root/examples/lpc43xx/Makefile.include
diff options
context:
space:
mode:
Diffstat (limited to 'examples/lpc43xx/Makefile.include')
-rw-r--r--examples/lpc43xx/Makefile.include15
1 files changed, 10 insertions, 5 deletions
diff --git a/examples/lpc43xx/Makefile.include b/examples/lpc43xx/Makefile.include
index 588ddee..4b1a092 100644
--- a/examples/lpc43xx/Makefile.include
+++ b/examples/lpc43xx/Makefile.include
@@ -27,14 +27,19 @@ 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 ($(wildcard ../../../../lib/libopencm3_lpc43xx.a),)
+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 += -O2 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
-mcpu=cortex-m4 -mthumb -MD \
-mfloat-abi=hard -mfpu=fpv4-sp-d16
LDSCRIPT ?= $(BINARY).ld
-LDFLAGS += -L$(TOOLCHAIN_DIR)/lib -L$(TOOLCHAIN_DIR)/lib/lpc43xx \
+LDFLAGS += -L$(TOOLCHAIN_DIR)/lib \
-T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections -Xlinker -Map=$(BINARY).map
OBJS += $(BINARY).o
@@ -78,7 +83,7 @@ flash: $(BINARY).flash
@#printf " OBJDUMP $(*).list\n"
$(Q)$(OBJDUMP) -S $(*).elf > $(*).list
-%.elf: $(OBJS) $(LDSCRIPT) $(TOOLCHAIN_DIR)/lib/lpc43xx/libopencm3_lpc43xx.a
+%.elf: $(OBJS) $(LDSCRIPT) $(TOOLCHAIN_DIR)/lib/libopencm3_lpc43xx.a
@#printf " LD $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(LD) $(LDFLAGS) -o $(*).elf $(OBJS) -lopencm3_lpc43xx