diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5ab69c8..d50ff22 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -547,8 +547,19 @@ CAT = cat ECHO = echo # General arguments -SYS_LIBS = $(wildcard $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS))) USER_LIBS = $(wildcard $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS))) +USER_LIB_NAMES= $(patsubst $(USER_LIB_PATH)/%,%,$(USER_LIBS)) + +# Let user libraries override system ones. +SYS_LIBS = $(wildcard $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(filter-out $(USER_LIB_NAMES),$(ARDUINO_LIBS)))) +SYS_LIB_NAMES = $(patsubst $(ARDUINO_LIB_PATH)/%,%,$(SYS_LIBS)) + +# Error here if any are missing. +LIBS_NOT_FOUND = $(filter-out $(USER_LIB_NAMES) $(SYS_LIB_NAMES),$(ARDUINO_LIBS)) +ifneq (,$(strip $(LIBS_NOT_FOUND))) + $(error The following libraries specified in ARDUINO_LIBS could not be found (searched USER_LIB_PATH and ARDUINO_LIB_PATH): $(LIBS_NOT_FOUND)) +endif + SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS)) USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS)) LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS)))