From f756c99a42f23c5eb08e6fb88754a3ab69e30a01 Mon Sep 17 00:00:00 2001 From: Frantisek Burian Date: Mon, 6 Jan 2014 22:17:28 +0100 Subject: [PATCH] [BUILD] Removed TOOLCHAIN_DIR, add autodetection of current libopencm3 library placement --- examples/Makefile.rules | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/examples/Makefile.rules b/examples/Makefile.rules index 9decab0..a3392a5 100644 --- a/examples/Makefile.rules +++ b/examples/Makefile.rules @@ -40,27 +40,28 @@ LDSCRIPT ?= $(BINARY).ld OBJS += $(BINARY).o -TOOLCHAIN_DIR ?= ../../../../../libopencm3 -ifeq ($(wildcard $(TOOLCHAIN_DIR)/lib/lib$(LIBNAME).a),) -ifneq ($(strip $(shell which $(CC))),) -TOOLCHAIN_DIR := $(shell dirname `which $(CC)`)/../$(PREFIX) + +ifeq ($(strip $(OPENCM3_DIR)),) +# user has not specified the library path, so we try to detect it + +# where we search for the library +LIBPATHS := ./libopencm3 ../../../../../libopencm3 + +OPENCM3_DIR := $(wildcard $(LIBPATHS:=/locm3.sublime-project)) +OPENCM3_DIR := $(firstword $(shell dirname $(OPENCM3_DIR))) + +ifeq ($(strip $(OPENCM3_DIR)),) +$(error Cannot find libopencm3 library in the standard search paths.) endif -else +endif + ifeq ($(V),1) -$(info Building the example in the source directory. Using local library!) -endif +$(info Using $(OPENCM3_DIR) path to library) endif - -INCLUDE_DIR = $(TOOLCHAIN_DIR)/include -LIB_DIR = $(TOOLCHAIN_DIR)/lib -SCRIPT_DIR = $(TOOLCHAIN_DIR)/share/libopencm3/scripts - -ifneq ($(OPENCM3_DIR),) INCLUDE_DIR = $(OPENCM3_DIR)/include LIB_DIR = $(OPENCM3_DIR)/lib SCRIPT_DIR = $(OPENCM3_DIR)/scripts -endif