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.
This commit is contained in:
Piotr Esden-Tempski 2012-08-13 15:23:07 -07:00
parent 3441bba1c4
commit b82e7eee52
7 changed files with 56 additions and 21 deletions

View File

@ -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

View File

@ -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_lpc13xx.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-m3 -mthumb -MD
LDSCRIPT ?= $(BINARY).ld

View File

@ -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_lpc17xx.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 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
-mcpu=cortex-m3 -mthumb -MD
LDSCRIPT ?= $(BINARY).ld

View File

@ -27,9 +27,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_lpc43xx.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 += -O2 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
-mcpu=cortex-m4 -mthumb -MD \
-mfloat-abi=hard -mfpu=fpv4-sp-d16

View File

@ -25,9 +25,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_stm32f1.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
ARCH_FLAGS = -mthumb -mcpu=cortex-m3 -msoft-float
CFLAGS += -Os -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include \
-fno-common $(ARCH_FLAGS) -MD -DSTM32F1

View File

@ -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_stm32f2.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-m3 -mthumb -msoft-float -MD -DSTM32F2
LDSCRIPT ?= $(BINARY).ld

View File

@ -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