Merge branch 'master' into up-auto

This commit is contained in:
ladislas 2014-10-15 22:39:16 +02:00
commit fec5298c70
3 changed files with 125 additions and 27 deletions

View file

@ -317,6 +317,7 @@ ifndef ARCHITECTURE
ifeq ($(shell expr $(ARDUINO_VERSION) '>' 150), 1)
# default to avr for 1.5
ARCHITECTURE = avr
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_AVR
else
# unset for 1.0
ARCHITECTURE =
@ -324,6 +325,17 @@ ifndef ARCHITECTURE
$(call show_config_variable,ARCHITECTURE,[DEFAULT])
else
$(call show_config_variable,ARCHITECTURE,[USER])
#avoid using shell for known architectures
ifeq ($(ARCHITECTURE),avr)
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_AVR
else
ifeq ($(ARCHITECTURE),sam)
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_SAM
else
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_$(shell echo $(ARCHITECTURE) | tr '[:lower:]' '[:upper:]')
endif
endif
endif
########################################################################
@ -467,6 +479,17 @@ else
$(call show_config_variable,ARDUINO_CORE_PATH,[USER])
endif
# 1.5.x platform dependent libs path
ifndef ARDUINO_PLATFORM_LIB_PATH
ifeq ($(shell expr $(ARDUINO_VERSION) '>' 150), 1)
# only for 1.5
ARDUINO_PLATFORM_LIB_PATH = $(ARDUINO_DIR)/hardware/$(VENDOR)/$(ARCHITECTURE)/libraries
$(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[COMPUTED],(from ARDUINO_DIR))
endif
else
$(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[USER])
endif
# Third party hardware and core like ATtiny or ATmega 16
ifdef ALTERNATE_CORE
$(call show_config_variable,ALTERNATE_CORE,[USER])
@ -859,6 +882,30 @@ CAT = cat
ECHO = printf
MKDIR = mkdir -p
# recursive wildcard function, call with params:
# - start directory (finished with /) or empty string for current dir
# - glob pattern
# (taken from http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html)
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
# functions used to determine various properties of library
# called with library path. Needed because of differences between library
# layouts in arduino 1.0.x and 1.5.x.
# Assuming new 1.5.x layout when there is "src" subdirectory in main directory
# and library.properties file
# Gets include flags for library
get_library_includes = $(if $(and $(wildcard $(1)/src), $(wildcard $(1)/library.properties)), \
-I$(1)/src, \
$(addprefix -I,$(1) $(wildcard $(1)/utility)))
# Gets all sources with given extension (param2) for library (path = param1)
# for old (1.0.x) layout looks in . and "utility" directories
# for new (1.5.x) layout looks in src and recursively its subdirectories
get_library_files = $(if $(and $(wildcard $(1)/src), $(wildcard $(1)/library.properties)), \
$(call rwildcard,$(1)/src/,*.$(2)), \
$(wildcard $(1)/*.$(2) $(1)/utility/*.$(2)))
# General arguments
USER_LIBS = $(wildcard $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS)))
USER_LIB_NAMES = $(patsubst $(USER_LIB_PATH)/%,%,$(USER_LIBS))
@ -867,22 +914,30 @@ USER_LIB_NAMES = $(patsubst $(USER_LIB_PATH)/%,%,$(USER_LIBS))
SYS_LIBS = $(wildcard $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(filter-out $(USER_LIB_NAMES),$(ARDUINO_LIBS))))
SYS_LIB_NAMES = $(patsubst $(ARDUINO_LIB_PATH)/%,%,$(SYS_LIBS))
# Error here if any are missing.
LIBS_NOT_FOUND = $(filter-out $(USER_LIB_NAMES) $(SYS_LIB_NAMES),$(ARDUINO_LIBS))
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))
ifdef ARDUINO_PLATFORM_LIB_PATH
PLATFORM_LIBS = $(wildcard $(patsubst %,$(ARDUINO_PLATFORM_LIB_PATH)/%,$(filter-out $(USER_LIB_NAMES),$(ARDUINO_LIBS))))
PLATFORM_LIB_NAMES = $(patsubst $(ARDUINO_PLATFORM_LIB_PATH)/%,%,$(PLATFORM_LIBS))
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))
USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS))
LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS)))
LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(SYS_LIBS)))
LIB_AS_SRCS = $(wildcard $(patsubst %,%/*.S,$(SYS_LIBS)))
USER_LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(USER_LIBS)))
USER_LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(USER_LIBS)))
USER_LIB_AS_SRCS = $(wildcard $(patsubst %,%/*.S,$(USER_LIBS)))
# Error here if any are missing.
LIBS_NOT_FOUND = $(filter-out $(USER_LIB_NAMES) $(SYS_LIB_NAMES) $(PLATFORM_LIB_NAMES),$(ARDUINO_LIBS))
ifneq (,$(strip $(LIBS_NOT_FOUND)))
ifdef ARDUINO_PLATFORM_LIB_PATH
$(error The following libraries specified in ARDUINO_LIBS could not be found (searched USER_LIB_PATH, ARDUINO_LIB_PATH and ARDUINO_PLATFORM_LIB_PATH): $(LIBS_NOT_FOUND))
else
$(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_INCLUDES = $(foreach lib, $(SYS_LIBS), $(call get_library_includes,$(lib)))
USER_INCLUDES = $(foreach lib, $(USER_LIBS), $(call get_library_includes,$(lib)))
LIB_C_SRCS = $(foreach lib, $(SYS_LIBS), $(call get_library_files,$(lib),c))
LIB_CPP_SRCS = $(foreach lib, $(SYS_LIBS), $(call get_library_files,$(lib),cpp))
LIB_AS_SRCS = $(foreach lib, $(SYS_LIBS), $(call get_library_files,$(lib),S))
USER_LIB_CPP_SRCS = $(foreach lib, $(USER_LIBS), $(call get_library_files,$(lib),cpp))
USER_LIB_C_SRCS = $(foreach lib, $(USER_LIBS), $(call get_library_files,$(lib),c))
USER_LIB_AS_SRCS = $(foreach lib, $(USER_LIBS), $(call get_library_files,$(lib),S))
LIB_OBJS = $(patsubst $(ARDUINO_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(LIB_C_SRCS)) \
$(patsubst $(ARDUINO_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(LIB_CPP_SRCS)) \
$(patsubst $(ARDUINO_LIB_PATH)/%.S,$(OBJDIR)/libs/%.o,$(LIB_AS_SRCS))
@ -890,8 +945,19 @@ USER_LIB_OBJS = $(patsubst $(USER_LIB_PATH)/%.cpp,$(OBJDIR)/userlibs/%.o,$
$(patsubst $(USER_LIB_PATH)/%.c,$(OBJDIR)/userlibs/%.o,$(USER_LIB_C_SRCS)) \
$(patsubst $(USER_LIB_PATH)/%.S,$(OBJDIR)/userlibs/%.o,$(USER_LIB_AS_SRCS))
ifdef ARDUINO_PLATFORM_LIB_PATH
PLATFORM_INCLUDES = $(foreach lib, $(PLATFORM_LIBS), $(call get_library_includes,$(lib)))
PLATFORM_LIB_CPP_SRCS = $(foreach lib, $(PLATFORM_LIBS), $(call get_library_files,$(lib),cpp))
PLATFORM_LIB_C_SRCS = $(foreach lib, $(PLATFORM_LIBS), $(call get_library_files,$(lib),c))
PLATFORM_LIB_AS_SRCS = $(foreach lib, $(PLATFORM_LIBS), $(call get_library_files,$(lib),S))
PLATFORM_LIB_OBJS = $(patsubst $(ARDUINO_PLATFORM_LIB_PATH)/%.cpp,$(OBJDIR)/platformlibs/%.o,$(PLATFORM_LIB_CPP_SRCS)) \
$(patsubst $(ARDUINO_PLATFORM_LIB_PATH)/%.c,$(OBJDIR)/platformlibs/%.o,$(PLATFORM_LIB_C_SRCS)) \
$(patsubst $(ARDUINO_PLATFORM_LIB_PATH)/%.S,$(OBJDIR)/platformlibs/%.o,$(PLATFORM_LIB_AS_SRCS))
endif
# Dependency files
DEPS = $(LOCAL_OBJS:.o=.d) $(LIB_OBJS:.o=.d) $(USER_LIB_OBJS:.o=.d) $(CORE_OBJS:.o=.d)
DEPS = $(LOCAL_OBJS:.o=.d) $(LIB_OBJS:.o=.d) $(PLATFORM_OBJS:.o=.d) $(USER_LIB_OBJS:.o=.d) $(CORE_OBJS:.o=.d)
# Optimization level for the compiler.
# You can get the list of options at http://www.nongnu.org/avr-libc/user-manual/using_tools.html#gcc_optO
@ -918,9 +984,9 @@ else
endif
# Using += instead of =, so that CPPFLAGS can be set per sketch level
CPPFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) -D__PROG_TYPES_COMPAT__ \
CPPFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) $(ARDUINO_ARCH_FLAG) -D__PROG_TYPES_COMPAT__ \
-I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \
$(SYS_INCLUDES) $(USER_INCLUDES) -Wall -ffunction-sections \
$(SYS_INCLUDES) $(PLATFORM_INCLUDES) $(USER_INCLUDES) -Wall -ffunction-sections \
-fdata-sections
ifdef DEBUG
@ -1024,7 +1090,7 @@ ifneq (,$(strip $(SYS_LIBS)))
$(call show_config_info,SYS_LIBS =)
endif
ifneq (,$(strip $(SYS_LIB_NAMES)))
ifneq (,$(strip $(SYS_LIB_NAMES) $(PLATFORM_LIB_NAMES)))
$(foreach lib,$(SYS_LIB_NAMES),$(call show_config_info, $(lib),[SYSTEM]))
endif
@ -1068,6 +1134,18 @@ $(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.S
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
$(OBJDIR)/platformlibs/%.o: $(ARDUINO_PLATFORM_LIB_PATH)/%.c
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(OBJDIR)/platformlibs/%.o: $(ARDUINO_PLATFORM_LIB_PATH)/%.cpp
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
$(OBJDIR)/platformlibs/%.o: $(ARDUINO_PLATFORM_LIB_PATH)/%.S
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@
$(OBJDIR)/userlibs/%.o: $(USER_LIB_PATH)/%.cpp
@$(MKDIR) $(dir $@)
$(CC) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
@ -1158,7 +1236,7 @@ endif
$(OBJDIR)/%.eep: $(OBJDIR)/%.elf $(COMMON_DEPS)
@$(MKDIR) $(dir $@)
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom='alloc,load' \
--change-section-lma .eeprom=0 -O ihex $< $@
$(OBJDIR)/%.lss: $(OBJDIR)/%.elf $(COMMON_DEPS)
@ -1297,8 +1375,8 @@ pre-build:
$(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS)
$(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) -lc -lm
$(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS)
$(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS)
$(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS)
$(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS)
error_on_caterina:
$(ERROR_ON_CATERINA)

View file

@ -5,6 +5,8 @@ The following is the rough list of changes that went into different versions.
I tried to give credit whenever possible. If I have missed anyone, kindly add it to the list.
### In development
- New: Add support for new 1.5.x library layout (Issue #275) (https://github.com/lukasz-e)
- New: Add support for 1.5.x vendor/hardware architecture library location (Issue #276) (https://github.com/lukasz-e)
- New: Added test suite and integration with travis CI. (https://github.com/peplin)
- New: Add information about `Bare-ArduinoProject` in README. (https://github.com/ladislas)
- New: Add information about reporting bugs to the correct project (Issue #231). (https://github.com/sej7278)
@ -25,6 +27,7 @@ I tried to give credit whenever possible. If I have missed anyone, kindly add it
- Fix: Update "make show_boards" regex to work with the Due in 1.5. (https://github.com/sej7278)
- Fix: Allow user libaries/sketches to have the same name as system libs. (Issue #244, #229). (https://github.com/sej7278)
- Fix: Remove impact of travis-ci from regular users. (Issue #258). (https://github.com/sej7278)
- Fix: objcopy quoting issue on Windows. (Issue #272). (https://github.com/sej7278)
### 1.3.4 (2014-07-12)
- Tweak: Allow spaces in "Serial.begin (....)". (Issue #190) (https://github.com/pdav)

View file

@ -111,6 +111,23 @@ ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java
----
### ARDUINO_PLATFORM_LIB_PATH
**Description:**
Directory where the Arduino platform dependent libraries are stored.
(Used only for Arduino 1.5.x)
**Example:**
```Makefile
ARDUINO_PLATFORM_LIB_PATH = /usr/share/arduino/hardware/arduino/avr/libraries
```
**Requirement:** *Optional*
----
### ARDUINO_VERSION
**Description:**