Merge pull request #2 from jeffkowalski/master
Auto-detect ARDUINO_LIBS, ARDUINO_SKETCHBOOK and ARDMK_DIR variables and automatically include /utility folder from libraries.
This commit is contained in:
commit
a5afbff9be
1 changed files with 66 additions and 27 deletions
|
@ -104,6 +104,15 @@
|
||||||
# - Changed bytes option for the head shell command, so that it works in Mac as well
|
# - Changed bytes option for the head shell command, so that it works in Mac as well
|
||||||
# - Auto detect Serial Baud rate from sketch if possible
|
# - Auto detect Serial Baud rate from sketch if possible
|
||||||
#
|
#
|
||||||
|
# 0.9.3.1 18.viii.2012 jeffkowalski
|
||||||
|
# - Autodetect ARDUINO_LIBS from includes in LOCAL_SRCS
|
||||||
|
# - Autodetect ARDUINO_SKETCHBOOK from file
|
||||||
|
# set by Arduino IDE
|
||||||
|
# - Autodetect ARDMK_DIR based on location of
|
||||||
|
# this file
|
||||||
|
# - Added support for utility directory
|
||||||
|
# within SYS and USER libraries
|
||||||
|
#
|
||||||
########################################################################
|
########################################################################
|
||||||
#
|
#
|
||||||
# PATHS YOU NEED TO SET UP
|
# PATHS YOU NEED TO SET UP
|
||||||
|
@ -384,28 +393,43 @@ endif
|
||||||
########################################################################
|
########################################################################
|
||||||
# Makefile distribution path
|
# Makefile distribution path
|
||||||
#
|
#
|
||||||
ifdef ARDMK_DIR
|
ifndef ARDMK_DIR
|
||||||
$(call show_config_variable,ARDMK_DIR)
|
# presume it's a level above the path to our own file
|
||||||
|
ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))/..)
|
||||||
|
$(call show_config_variable,ARDMK_DIR,[COMPUTED],(relative to $(notdir $(lastword $(MAKEFILE_LIST)))))
|
||||||
|
else
|
||||||
|
$(call show_config_variable,ARDMK_DIR,[USER])
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef ARDMK_DIR
|
||||||
ifndef ARDMK_PATH
|
ifndef ARDMK_PATH
|
||||||
ARDMK_PATH = $(ARDMK_DIR)/bin
|
ARDMK_PATH = $(ARDMK_DIR)/bin
|
||||||
$(call show_config_variable,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR))
|
$(call show_config_variable,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR))
|
||||||
|
|
||||||
else
|
else
|
||||||
$(call show_config_variable,ARDMK_PATH)
|
$(call show_config_variable,ARDMK_PATH)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
echo $(error "ARDMK_DIR is not defined")
|
echo $(error "ARDMK_DIR is not defined")
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Miscellanea
|
# Miscellanea
|
||||||
#
|
#
|
||||||
ifndef ARDUINO_SKETCHBOOK
|
ifndef ARDUINO_SKETCHBOOK
|
||||||
|
ifneq ($(wildcard $(HOME)/.arduino/preferences.txt),)
|
||||||
|
ARDUINO_SKETCHBOOK = $(shell grep --max-count=1 --regexp="sketchbook.path=" \
|
||||||
|
$(HOME)/.arduino/preferences.txt | \
|
||||||
|
sed -e 's/sketchbook.path=//' )
|
||||||
|
endif
|
||||||
|
ifneq ($(ARDUINO_SKETCHBOOK),)
|
||||||
|
$(call show_config_variable,ARDUINO_SKETCHBOOK,[AUTODETECTED],(in arduino preferences file))
|
||||||
|
else
|
||||||
ARDUINO_SKETCHBOOK = $(HOME)/sketchbook
|
ARDUINO_SKETCHBOOK = $(HOME)/sketchbook
|
||||||
|
$(call show_config_variable,ARDUINO_SKETCHBOOK,[DEFAULT])
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
$(call show_config_variable,ARDUINO_SKETCHBOOK)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef USER_LIB_PATH
|
ifndef USER_LIB_PATH
|
||||||
|
@ -529,6 +553,9 @@ LOCAL_CC_SRCS ?= $(wildcard *.cc)
|
||||||
LOCAL_PDE_SRCS ?= $(wildcard *.pde)
|
LOCAL_PDE_SRCS ?= $(wildcard *.pde)
|
||||||
LOCAL_INO_SRCS ?= $(wildcard *.ino)
|
LOCAL_INO_SRCS ?= $(wildcard *.ino)
|
||||||
LOCAL_AS_SRCS ?= $(wildcard *.S)
|
LOCAL_AS_SRCS ?= $(wildcard *.S)
|
||||||
|
LOCAL_SRCS = $(LOCAL_C_SRCS) $(LOCAL_CPP_SRCS) \
|
||||||
|
$(LOCAL_CC_SRCS) $(LOCAL_PDE_SRCS) \
|
||||||
|
$(LOCAL_INO_SRCS) $(LOCAL_AS_SRCS)
|
||||||
LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \
|
LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \
|
||||||
$(LOCAL_CC_SRCS:.cc=.o) $(LOCAL_PDE_SRCS:.pde=.o) \
|
$(LOCAL_CC_SRCS:.cc=.o) $(LOCAL_PDE_SRCS:.pde=.o) \
|
||||||
$(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o)
|
$(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o)
|
||||||
|
@ -556,6 +583,16 @@ else
|
||||||
$(call show_config_info,NO_CORE set so core library will not be built,[MANUAL])
|
$(call show_config_info,NO_CORE set so core library will not be built,[MANUAL])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# Determine ARDUINO_LIBS automatically
|
||||||
|
#
|
||||||
|
ifndef ARDUINO_LIBS
|
||||||
|
# automatically determine included libraries
|
||||||
|
ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_DIR)/libraries/*)), \
|
||||||
|
$(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(LOCAL_SRCS)))
|
||||||
|
ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_SKETCHBOOK)/libraries/*)), \
|
||||||
|
$(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(LOCAL_SRCS)))
|
||||||
|
endif
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Rules for making stuff
|
# Rules for making stuff
|
||||||
|
@ -597,6 +634,8 @@ 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))
|
$(error The following libraries specified in ARDUINO_LIBS could not be found (searched USER_LIB_PATH and ARDUINO_LIB_PATH): $(LIBS_NOT_FOUND))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
SYS_LIBS := $(wildcard $(SYS_LIBS) $(addsuffix /utility,$(SYS_LIBS)))
|
||||||
|
USER_LIBS := $(wildcard $(USER_LIBS) $(addsuffix /utility,$(USER_LIBS)))
|
||||||
SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS))
|
SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS))
|
||||||
USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS))
|
USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS))
|
||||||
LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS)))
|
LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS)))
|
||||||
|
|
Loading…
Reference in a new issue