Skip to content

Commit eef7300

Browse files
committed
added auto-detection of ARDUINO_LIBS referenced in LOCAL_SRCS
1 parent b74f2ef commit eef7300

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

arduino-mk/Arduino.mk

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
# 0.9.2 06.vi.2012 Sudar
9696
# - Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech)
9797
# - Modified 'make size' behavior: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech)
98-
#
98+
#
9999
# 0.9.3 13.vi.2012 Sudar
100100
# - Autodetect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/)
101101
# - Categorize libs into user and system (https://github.com/rpavlik/)
@@ -529,6 +529,9 @@ LOCAL_CC_SRCS ?= $(wildcard *.cc)
529529
LOCAL_PDE_SRCS ?= $(wildcard *.pde)
530530
LOCAL_INO_SRCS ?= $(wildcard *.ino)
531531
LOCAL_AS_SRCS ?= $(wildcard *.S)
532+
LOCAL_SRCS = $(LOCAL_C_SRCS) $(LOCAL_CPP_SRCS) \
533+
$(LOCAL_CC_SRCS) $(LOCAL_PDE_SRCS) \
534+
$(LOCAL_INO_SRCS) $(LOCAL_AS_SRCS)
532535
LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \
533536
$(LOCAL_CC_SRCS:.cc=.o) $(LOCAL_PDE_SRCS:.pde=.o) \
534537
$(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o)
@@ -556,6 +559,17 @@ else
556559
$(call show_config_info,NO_CORE set so core library will not be built,[MANUAL])
557560
endif
558561

562+
########################################################################
563+
# Determine ARDUINO_LIBS automatically
564+
#
565+
566+
ifndef ARDUINO_LIBS
567+
# automatically determine included libraries
568+
ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_DIR)/libraries/*)), \
569+
$(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(LOCAL_SRCS)))
570+
ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_SKETCHBOOK)/libraries/*)), \
571+
$(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(LOCAL_SRCS)))
572+
endif
559573

560574
########################################################################
561575
# Rules for making stuff
@@ -833,7 +847,7 @@ ispload: $(TARGET_HEX)
833847
-U lock:w:$(ISP_LOCK_FUSE_POST):m
834848

835849
clean:
836-
$(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) ${OBJDIR}
850+
$(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) ${OBJDIR}
837851

838852
depends: $(DEPS)
839853
cat $(DEPS) > $(DEP_FILE)

0 commit comments

Comments
 (0)