@@ -794,7 +794,7 @@ ifeq ($(strip $(CHK_SOURCES)),)
794
794
$(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)
795
795
else
796
796
# TODO: Support more than one file. https://github.com/sudar/Arduino-Makefile/issues/49
797
- $(error Need exactly one .pde or .ino file. This makefile doesn't support multiple .ino/.pde files yet)
797
+ $(error Need exactly one .pde or .ino file. This makefile doesn\ 't support multiple .ino/.pde files yet)
798
798
endif
799
799
endif
800
800
@@ -821,6 +821,22 @@ else
821
821
$(call show_config_info,NO_CORE set so core library will not be built,[MANUAL])
822
822
endif
823
823
824
+ # #######################################################################
825
+ # Automatically find the libraries needed to compile the sketch
826
+
827
+ ARD_LIB_DETECTION := $(shell which ard-lib-detection 2> /dev/null)
828
+ ifndef ARD_LIB_DETECTION
829
+ ARD_LIB_DETECTION := $(ARDMK_DIR)/bin/ard-lib-detection
830
+ endif
831
+
832
+ ifndef SKETCH_LIBS
833
+ SKETCH_LIBS := $(shell $(ARD_LIB_DETECTION) $(USER_LIB_PATH) | sed -ne 's/SKETCH_LIBS \(.*\) /\1/p')
834
+ endif
835
+
836
+ ifndef SKETCH_LIBS_DEPS
837
+ SKETCH_LIBS_DEPS := $(shell $(ARD_LIB_DETECTION) $(USER_LIB_PATH) | sed -ne 's/SKETCH_LIBS_DEPS \(.*\) /\1/p')
838
+ endif
839
+
824
840
# #######################################################################
825
841
# Determine ARDUINO_LIBS automatically
826
842
@@ -932,7 +948,10 @@ get_library_files = $(if $(and $(wildcard $(1)/src), $(wildcard $(1)/library.pr
932
948
$(wildcard $(1 ) /* .$(2 ) $(1 ) /utility/* .$(2 ) ) )
933
949
934
950
# General arguments
935
- USER_LIBS := $(sort $(wildcard $(patsubst % ,$(USER_LIB_PATH ) /% ,$(ARDUINO_LIBS ) ) ) )
951
+ USER_LIBS := $(wildcard $(patsubst % ,$(USER_LIB_PATH ) /% ,$(ARDUINO_LIBS ) ) ) \
952
+ $(wildcard $(patsubst % ,$(USER_LIB_PATH ) /% ,$(SKETCH_LIBS ) ) ) \
953
+ $(wildcard $(patsubst % ,$(USER_LIB_PATH ) /% ,$(SKETCH_LIBS_DEPS ) ) )
954
+
936
955
USER_LIB_NAMES := $(patsubst $(USER_LIB_PATH ) /% ,% ,$(USER_LIBS ) )
937
956
938
957
# Let user libraries override system ones.
@@ -1107,13 +1126,27 @@ else
1107
1126
$(call show_config_info,Size utility : Basic (not AVR-aware),[AUTODETECTED])
1108
1127
endif
1109
1128
1110
- ifneq (,$(strip $(ARDUINO_LIBS ) ) )
1129
+ ifneq (,$(strip $(SKETCH_LIBS ) ) )
1111
1130
$(call arduino_output,-)
1112
- $(call show_config_info,ARDUINO_LIBS =)
1131
+ $(call show_config_info,SKETCH_LIBS =)
1113
1132
endif
1114
1133
1115
- ifneq (,$(strip $(USER_LIB_NAMES ) ) )
1116
- $(foreach lib,$(USER_LIB_NAMES),$(call show_config_info, $(lib),[USER]))
1134
+ ifneq (,$(strip $(SKETCH_LIBS ) ) )
1135
+ $(foreach lib,$(SKETCH_LIBS),$(call show_config_info, $(lib),[USER]))
1136
+ endif
1137
+
1138
+ ifneq (,$(strip $(SKETCH_LIBS_DEPS ) ) )
1139
+ $(call arduino_output,-)
1140
+ $(call show_config_info,SKETCH_LIBS_DEPS =)
1141
+ endif
1142
+
1143
+ ifneq (,$(strip $(SKETCH_LIBS_DEPS ) ) )
1144
+ $(foreach lib,$(SKETCH_LIBS_DEPS),$(call show_config_info, $(lib),[USER]))
1145
+ endif
1146
+
1147
+ ifneq (,$(strip $(SYS_LIB_NAMES ) $(PLATFORM_LIB_NAMES ) ) )
1148
+ $(call arduino_output,-)
1149
+ $(call show_config_info,SYSTEM_LIBS =)
1117
1150
endif
1118
1151
1119
1152
ifneq (,$(strip $(SYS_LIB_NAMES ) ) )
@@ -1124,6 +1157,8 @@ ifneq (,$(strip $(PLATFORM_LIB_NAMES)))
1124
1157
$(foreach lib,$(PLATFORM_LIB_NAMES),$(call show_config_info, $(lib),[PLATFORM]))
1125
1158
endif
1126
1159
1160
+ $(call arduino_output,-)
1161
+
1127
1162
# either calculate parent dir from arduino dir, or user-defined path
1128
1163
ifndef BOOTLOADER_PARENT
1129
1164
BOOTLOADER_PARENT = $(ARDUINO_DIR ) /hardware/$(VENDOR ) /$(ARCHITECTURE ) /bootloaders
0 commit comments