@@ -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,17 +821,29 @@ 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
827
843
ifndef ARDUINO_LIBS
828
844
# automatically determine included libraries
829
845
ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_DIR ) /libraries/* ) ) , \
830
846
$(shell sed -ne 's/^ * \# * include * [<\"]\(.* \) \.h[>\"]/\1/p' $(LOCAL_SRCS ) ) )
831
- ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_SKETCHBOOK ) /libraries/* ) ) , \
832
- $(shell sed -ne 's/^ * \# * include * [<\"]\(.* \) \.h[>\"]/\1/p' $(LOCAL_SRCS ) ) )
833
- ARDUINO_LIBS += $(filter $(notdir $(wildcard $(USER_LIB_PATH ) /* ) ) , \
834
- $(shell sed -ne 's/^ * \# * include * [<\"]\(.* \) \.h[>\"]/\1/p' $(LOCAL_SRCS ) ) )
835
847
ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_PLATFORM_LIB_PATH ) /* ) ) , \
836
848
$(shell sed -ne 's/^ * \# * include * [<\"]\(.* \) \.h[>\"]/\1/p' $(LOCAL_SRCS ) ) )
837
849
endif
@@ -932,7 +944,10 @@ get_library_files = $(if $(and $(wildcard $(1)/src), $(wildcard $(1)/library.pr
932
944
$(wildcard $(1 ) /* .$(2 ) $(1 ) /utility/* .$(2 ) ) )
933
945
934
946
# General arguments
935
- USER_LIBS := $(sort $(wildcard $(patsubst % ,$(USER_LIB_PATH ) /% ,$(ARDUINO_LIBS ) ) ) )
947
+ USER_LIBS := $(wildcard $(patsubst % ,$(USER_LIB_PATH ) /% ,$(ARDUINO_LIBS ) ) ) \
948
+ $(wildcard $(patsubst % ,$(USER_LIB_PATH ) /% ,$(SKETCH_LIBS ) ) ) \
949
+ $(wildcard $(patsubst % ,$(USER_LIB_PATH ) /% ,$(SKETCH_LIBS_DEPS ) ) )
950
+
936
951
USER_LIB_NAMES := $(patsubst $(USER_LIB_PATH ) /% ,% ,$(USER_LIBS ) )
937
952
938
953
# Let user libraries override system ones.
@@ -1107,23 +1122,6 @@ else
1107
1122
$(call show_config_info,Size utility : Basic (not AVR-aware),[AUTODETECTED])
1108
1123
endif
1109
1124
1110
- ifneq (,$(strip $(ARDUINO_LIBS ) ) )
1111
- $(call arduino_output,-)
1112
- $(call show_config_info,ARDUINO_LIBS =)
1113
- endif
1114
-
1115
- ifneq (,$(strip $(USER_LIB_NAMES ) ) )
1116
- $(foreach lib,$(USER_LIB_NAMES),$(call show_config_info, $(lib),[USER]))
1117
- endif
1118
-
1119
- ifneq (,$(strip $(SYS_LIB_NAMES ) ) )
1120
- $(foreach lib,$(SYS_LIB_NAMES),$(call show_config_info, $(lib),[SYSTEM]))
1121
- endif
1122
-
1123
- ifneq (,$(strip $(PLATFORM_LIB_NAMES ) ) )
1124
- $(foreach lib,$(PLATFORM_LIB_NAMES),$(call show_config_info, $(lib),[PLATFORM]))
1125
- endif
1126
-
1127
1125
# either calculate parent dir from arduino dir, or user-defined path
1128
1126
ifndef BOOTLOADER_PARENT
1129
1127
BOOTLOADER_PARENT = $(ARDUINO_DIR ) /hardware/$(VENDOR ) /$(ARCHITECTURE ) /bootloaders
@@ -1132,14 +1130,34 @@ else
1132
1130
$(call show_config_variable,BOOTLOADER_PARENT,[USER])
1133
1131
endif
1134
1132
1135
- # #######################################################################
1136
1133
# Tools version info
1137
1134
ARDMK_VERSION = 1.5
1138
1135
$(call show_config_variable,ARDMK_VERSION,[COMPUTED])
1139
1136
1140
1137
CC_VERSION := $(shell $(CC ) -dumpversion)
1141
1138
$(call show_config_variable,CC_VERSION,[COMPUTED],($(CC_NAME)))
1142
1139
1140
+ # do we have any libs?
1141
+ ifneq (,$(strip $(USER_LIBS ) $(ARDUINO_LIBS ) $(SYS_LIBS ) $(PLATFORM_LIBS ) $(SKETCH_LIBS ) $(SKETCH_LIBS_DEPS ) ) )
1142
+ $(call show_config_info,ARDUINO_LIBS =)
1143
+ endif
1144
+
1145
+ ifneq (,$(strip $(SKETCH_LIBS ) ) )
1146
+ $(foreach lib,$(SKETCH_LIBS),$(call show_config_info, $(lib),[USER]))
1147
+ endif
1148
+
1149
+ ifneq (,$(strip $(SKETCH_LIBS_DEPS ) ) )
1150
+ $(foreach lib,$(SKETCH_LIBS_DEPS),$(call show_config_info, $(lib),[USER]))
1151
+ endif
1152
+
1153
+ ifneq (,$(strip $(SYS_LIB_NAMES ) ) )
1154
+ $(foreach lib,$(SYS_LIB_NAMES),$(call show_config_info, $(lib),[SYSTEM]))
1155
+ endif
1156
+
1157
+ ifneq (,$(strip $(PLATFORM_LIB_NAMES ) ) )
1158
+ $(foreach lib,$(PLATFORM_LIB_NAMES),$(call show_config_info, $(lib),[PLATFORM]))
1159
+ endif
1160
+
1143
1161
# end of config output
1144
1162
$(call show_separator)
1145
1163
0 commit comments