@@ -736,7 +736,7 @@ ifeq ($(strip $(CHK_SOURCES)),)
736
736
$(call show_config_info,No .pde or .ino files found. If you are compiling .c or .cpp files then you need to explicitly include Arduino header files)
737
737
else
738
738
# TODO: Support more than one file. https://github.com/sudar/Arduino-Makefile/issues/49
739
- $(error Need exactly one .pde or .ino file. This makefile doesn't support multiple .ino/.pde files yet)
739
+ $(error Need exactly one .pde or .ino file. This makefile doesn\ 't support multiple .ino/.pde files yet)
740
740
endif
741
741
endif
742
742
@@ -763,6 +763,19 @@ else
763
763
$(call show_config_info,NO_CORE set so core library will not be built,[MANUAL])
764
764
endif
765
765
766
+ # #######################################################################
767
+ # Automatically find the libraries needed to compile the sketch
768
+
769
+ ifndef SKETCH_LIBS
770
+ SKETCH_LIBS := $(shell $(ARDMK_DIR)/bin/lib-detection $(USER_LIB_PATH) | \
771
+ sed -ne 's/SKETCH_LIBS \(.*\) /\1/p')
772
+ endif
773
+
774
+ ifndef SKETCH_LIBS_DEPS
775
+ SKETCH_LIBS_DEPS := $(shell $(ARDMK_DIR)/bin/lib-detection $(USER_LIB_PATH) | \
776
+ sed -ne 's/SKETCH_LIBS_DEPS \(.*\) /\1/p')
777
+ endif
778
+
766
779
# #######################################################################
767
780
# Determine ARDUINO_LIBS automatically
768
781
@@ -772,8 +785,6 @@ ifndef ARDUINO_LIBS
772
785
$(shell sed -ne "s/^ * \# * include * [<\"]\(.* \) \.h[>\"]/\1/p" $(LOCAL_SRCS ) ) )
773
786
ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_SKETCHBOOK ) /libraries/* ) ) , \
774
787
$(shell sed -ne "s/^ * \# * include * [<\"]\(.* \) \.h[>\"]/\1/p" $(LOCAL_SRCS ) ) )
775
- ARDUINO_LIBS += $(filter $(notdir $(wildcard $(USER_LIB_PATH ) /* ) ) , \
776
- $(shell sed -ne "s/^ * \# * include * [<\"]\(.* \) \.h[>\"]/\1/p" $(LOCAL_SRCS ) ) )
777
788
endif
778
789
779
790
# #######################################################################
@@ -872,7 +883,10 @@ get_library_files = $(if $(and $(wildcard $(1)/src), $(wildcard $(1)/library.pr
872
883
$(wildcard $(1 ) /* .$(2 ) $(1 ) /utility/* .$(2 ) ) )
873
884
874
885
# General arguments
875
- USER_LIBS := $(wildcard $(patsubst % ,$(USER_LIB_PATH ) /% ,$(ARDUINO_LIBS ) ) )
886
+ USER_LIBS := $(wildcard $(patsubst % ,$(USER_LIB_PATH ) /% ,$(ARDUINO_LIBS ) ) ) \
887
+ $(wildcard $(patsubst % ,$(USER_LIB_PATH ) /% ,$(SKETCH_LIBS ) ) ) \
888
+ $(wildcard $(patsubst % ,$(USER_LIB_PATH ) /% ,$(SKETCH_LIBS_DEPS ) ) )
889
+
876
890
USER_LIB_NAMES := $(patsubst $(USER_LIB_PATH ) /% ,% ,$(USER_LIBS ) )
877
891
878
892
# Let user libraries override system ones.
@@ -1032,17 +1046,32 @@ else
1032
1046
$(call show_config_info,Size utility : Basic (not AVR-aware),[AUTODETECTED])
1033
1047
endif
1034
1048
1035
- ifneq (,$(strip $(ARDUINO_LIBS ) ) )
1049
+ ifneq (,$(strip $(SKETCH_LIBS ) ) )
1050
+ $(call arduino_output,-)
1051
+ $(call show_config_info,SKETCH_LIBS =)
1052
+ endif
1053
+
1054
+ ifneq (,$(strip $(SKETCH_LIBS ) ) )
1055
+ $(foreach lib,$(SKETCH_LIBS),$(call show_config_info, $(lib),[USER]))
1056
+ endif
1057
+
1058
+ ifneq (,$(strip $(SKETCH_LIBS_DEPS ) ) )
1036
1059
$(call arduino_output,-)
1037
- $(call show_config_info,ARDUINO_LIBS =)
1060
+ $(call show_config_info,SKETCH_LIBS_DEPS =)
1038
1061
endif
1039
1062
1040
- ifneq (,$(strip $(USER_LIB_NAMES ) ) )
1041
- $(foreach lib,$(USER_LIB_NAMES),$(call show_config_info, $(lib),[USER]))
1063
+ ifneq (,$(strip $(SKETCH_LIBS_DEPS ) ) )
1064
+ $(foreach lib,$(SKETCH_LIBS_DEPS),$(call show_config_info, $(lib),[USER]))
1065
+ endif
1066
+
1067
+ ifneq (,$(strip $(SYS_LIB_NAMES ) $(PLATFORM_LIB_NAMES ) ) )
1068
+ $(call arduino_output,-)
1069
+ $(call show_config_info,SYSTEM_LIBS =)
1042
1070
endif
1043
1071
1044
1072
ifneq (,$(strip $(SYS_LIB_NAMES ) $(PLATFORM_LIB_NAMES ) ) )
1045
1073
$(foreach lib,$(SYS_LIB_NAMES),$(call show_config_info, $(lib),[SYSTEM]))
1074
+ $(call arduino_output,-)
1046
1075
endif
1047
1076
1048
1077
# either calculate parent dir from arduino dir, or user-defined path
0 commit comments