From db3a874e750d830a39e9478d34a52124b8e1f3bf Mon Sep 17 00:00:00 2001 From: Sudar Date: Sat, 5 May 2012 13:54:31 +0530 Subject: [PATCH 01/83] Corrected the ubuntu package names --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f086c92..23249aa 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ The Makefile also delegates resetting the board to a short Perl program. You'll need to install Device::SerialPort to use it though. On Debian or Ubuntu do - apt-get install libdevice-serial-perl + apt-get install libdevice-serialport-perl libconfig-yaml-perl On other systems From 1750ef08a47503f1ccd6e42b2d2d546dca88c132 Mon Sep 17 00:00:00 2001 From: Sudar Date: Sat, 5 May 2012 16:03:40 +0530 Subject: [PATCH 02/83] Prevent the *file-not-found* error if the depends.mk file is not needed --- arduino-mk/Arduino.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5261afa..125505b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -690,4 +690,5 @@ monitor: .PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor -include $(DEP_FILE) +# added - in the beginning, so that we don't get an error if the file is not present +-include $(DEP_FILE) From 378b59fb95f9f867d27fec869076d9c5a6f613a0 Mon Sep 17 00:00:00 2001 From: Sudar Date: Sat, 5 May 2012 16:07:12 +0530 Subject: [PATCH 03/83] Delete the build-cli folder as well while doing make clean --- arduino-mk/Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 125505b..f2dc959 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -674,7 +674,7 @@ ispload: $(TARGET_HEX) -U lock:w:$(ISP_LOCK_FUSE_POST):m clean: - $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) + $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) @rm -rf ${OBJDIR} depends: $(DEPS) cat $(DEPS) > $(DEP_FILE) From efc64c79ee4a2056bd5793658cf60e2d917d263d Mon Sep 17 00:00:00 2001 From: Scott Howard Date: Sun, 6 May 2012 10:20:59 -0300 Subject: [PATCH 04/83] the package name in Debian and Ubuntu is arduino-mk --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f086c92..2351760 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ documentation](http://mjo.tc/atelier/2009/02/arduino-cli.html "Documentation") exists. If you're using Debian or Ubuntu, you can find this in the -arduino-core package. +arduino-mk package. # Important Changes, 2012-04-29 From e046112c8342d05d1f1f5e5058b2e5a212267db5 Mon Sep 17 00:00:00 2001 From: Sudar Date: Sat, 12 May 2012 13:26:00 +0530 Subject: [PATCH 05/83] Added support for compiling .pde files in Arduino 1.0 environment --- arduino-mk/Arduino.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index f2dc959..70637ca 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -564,9 +564,11 @@ $(OBJDIR)/%.d: %.S $(OBJDIR)/%.d: %.s $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) +#backward compatibility for .pde files +# We should check for Arduino version, if the file is .pde because a .pde file might be used in Arduino 1.0 # the pde -> cpp -> o file $(OBJDIR)/%.cpp: %.pde - $(ECHO) '#include "WProgram.h"' > $@ + $(ECHO) '#if ARDUINO >= 100\n #include "Arduino.h"\n#else\n #include "WProgram.h"\n#endif' > $@ $(CAT) $< >> $@ # the ino -> cpp -> o file From af52a2dcc8c0119eca135cf1c5f66276a8efd5d5 Mon Sep 17 00:00:00 2001 From: Sudar Date: Sat, 9 Jun 2012 10:59:02 +0530 Subject: [PATCH 06/83] Replaced = with += in CPPFLAGS assignment so that we can set CPPFLAGS per sketch if needed --- arduino-mk/Arduino.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 70637ca..315492f 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -494,7 +494,8 @@ LIB_OBJS = $(patsubst $(ARDUINO_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(LIB_C_SR USER_LIB_OBJS = $(patsubst $(USER_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(USER_LIB_CPP_SRCS)) \ $(patsubst $(USER_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(USER_LIB_C_SRCS)) -CPPFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \ +# Using += instead of =, so that CPPFLAGS can be set per sketch level +CPPFLAGS += -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \ -I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ $(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -w -Wall \ -ffunction-sections -fdata-sections From 1e5d7c1a33955e70275f8f7e828498c98995590e Mon Sep 17 00:00:00 2001 From: Adam Dunlap Date: Sun, 10 Jun 2012 14:40:31 -0700 Subject: [PATCH 07/83] Changed echo command to work on linux --- arduino-mk/Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 315492f..a091b2b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -478,7 +478,7 @@ NM = $(AVR_TOOLS_PATH)/avr-nm REMOVE = rm -f MV = mv -f CAT = cat -ECHO = echo +ECHO = echo -e # General arguments SYS_LIBS = $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS)) From 4a81c19a8beaf8c2b20b3b7d7f1ba78da8b5ecb9 Mon Sep 17 00:00:00 2001 From: Adam Dunlap Date: Sun, 10 Jun 2012 15:06:08 -0700 Subject: [PATCH 08/83] Changed AVRDUDE_CONF so it can be defined in per-project makefile --- arduino-mk/Arduino.mk | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index a091b2b..0ea464b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -285,8 +285,6 @@ ifdef ARDUINO_DIR ifndef AVR_TOOLS_DIR AVR_TOOLS_DIR = $(ARDUINO_DIR)/hardware/tools/avr -# The avrdude bundled with Arduino can't find it's config -AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf endif ifndef AVR_TOOLS_PATH @@ -612,6 +610,14 @@ ifndef AVRDUDE AVRDUDE = $(AVR_TOOLS_PATH)/avrdude endif +ifndef AVRDUDE_CONF +ifndef AVR_TOOLS_DIR +# The avrdude bundled with Arduino can't find its config +AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf +endif +# If avrdude is installed separately, it can find its own config flie +endif + AVRDUDE_COM_OPTS = -q -V -p $(MCU) ifdef AVRDUDE_CONF AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF) From a6c076c5d355c561d0dc5fbf19c5ababcadfde2d Mon Sep 17 00:00:00 2001 From: Sudar Date: Sat, 23 Jun 2012 11:23:16 +0530 Subject: [PATCH 09/83] cleaner way to delete the build-cli directory when make clean is invoked --- arduino-mk/Arduino.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 0ea464b..dd0db28 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -473,7 +473,7 @@ OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump AR = $(AVR_TOOLS_PATH)/avr-ar SIZE = $(AVR_TOOLS_PATH)/avr-size NM = $(AVR_TOOLS_PATH)/avr-nm -REMOVE = rm -f +REMOVE = rm -rf MV = mv -f CAT = cat ECHO = echo -e @@ -683,7 +683,7 @@ ispload: $(TARGET_HEX) -U lock:w:$(ISP_LOCK_FUSE_POST):m clean: - $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) @rm -rf ${OBJDIR} + $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) ${OBJDIR} depends: $(DEPS) cat $(DEPS) > $(DEP_FILE) From f970cf406be06e300be4337042677d4dfa426d01 Mon Sep 17 00:00:00 2001 From: Scott Howard Date: Sun, 6 May 2012 10:20:59 -0300 Subject: [PATCH 10/83] the package name in Debian and Ubuntu is arduino-mk --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 23249aa..6525553 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ documentation](http://mjo.tc/atelier/2009/02/arduino-cli.html "Documentation") exists. If you're using Debian or Ubuntu, you can find this in the -arduino-core package. +arduino-mk package. # Important Changes, 2012-04-29 From 854a7aa8c03bd4bc5c5e9fc6fb5d6c46bf860472 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 28 Jun 2012 18:28:22 -0500 Subject: [PATCH 11/83] Be able to autodetect ARDUINO_DIR in some cases --- arduino-mk/Arduino.mk | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5261afa..18a9860 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -263,6 +263,23 @@ # ######################################################################## +dir_if_exists = $(shell test -e $(1)$(2) && echo $(1) || true) + +ifndef ARDUINO_DIR +NIX_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/usr/share/arduino) +ifdef NIX_DEFAULT_ARDUINO_DIR +ARDUINO_DIR = $(NIX_DEFAULT_ARDUINO_DIR) +endif + +MAC_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/Applications/Arduino.app/Contents/Resources/Java) +ifdef MAC_DEFAULT_ARDUINO_DIR +ARDUINO_DIR = $(MAC_DEFAULT_ARDUINO_DIR) +endif + +ifdef ARDUINO_DIR +$(info Using autodetected ARDUINO_DIR '$(ARDUINO_DIR)') +endif +endif ######################################################################## # # Default TARGET to cwd (ex Daniele Vergini) From 7f3fe664956930c35181d6c2f8198f565177718a Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 28 Jun 2012 18:32:23 -0500 Subject: [PATCH 12/83] Only use Arduino's bundled AVR tools if they exist, otherwise try using "which" --- arduino-mk/Arduino.mk | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 18a9860..6102893 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -301,10 +301,26 @@ endif ifdef ARDUINO_DIR ifndef AVR_TOOLS_DIR -AVR_TOOLS_DIR = $(ARDUINO_DIR)/hardware/tools/avr + +BUNDLED_AVR_TOOLS_DIR := $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/avr) + +ifdef BUNDLED_AVR_TOOLS_DIR +$(info Using autodetected (bundled) AVR_TOOLS_DIR '$(BUNDLED_AVR_TOOLS_DIR)') +AVR_TOOLS_DIR = $(BUNDLED_AVR_TOOLS_DIR) # The avrdude bundled with Arduino can't find it's config AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf -endif + +else + +SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which avr-gcc))/..)) +ifdef SYSTEMPATH_AVR_TOOLS_DIR +$(info Using autodetected (from PATH) AVR_TOOLS_DIR '$(SYSTEMPATH_AVR_TOOLS_DIR)') +AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR) +endif # SYSTEMPATH_AVR_TOOLS_DIR + +endif # BUNDLED_AVR_TOOLS_EIR + +endif #ndef AVR_TOOLS_DIR ifndef AVR_TOOLS_PATH AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin From dfd32d2b2cbc3925f8967dc3abff6c824a238495 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 28 Jun 2012 18:32:41 -0500 Subject: [PATCH 13/83] Properly categorize libs into user and system automatically. --- arduino-mk/Arduino.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 6102893..d846977 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -514,8 +514,8 @@ CAT = cat ECHO = echo # General arguments -SYS_LIBS = $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS)) -USER_LIBS = $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS)) +SYS_LIBS = $(foreach libdir,$(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS)),$(call dir_if_exists,$(libdir))) +USER_LIBS = $(foreach libdir,$(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS)),$(call dir_if_exists,$(libdir))) SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS)) USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS)) LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS))) From 3a37aa58315ed816e539938910b01eb0fbb06533 Mon Sep 17 00:00:00 2001 From: Jared Szechy Date: Sun, 1 Jul 2012 01:56:43 -0400 Subject: [PATCH 14/83] Fix size so it uses the elf file rather than the hex. Also added the mcu so it shows device memory usage. --- arduino-mk/Arduino.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5261afa..38d8217 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -679,8 +679,8 @@ clean: depends: $(DEPS) cat $(DEPS) > $(DEP_FILE) -size: $(OBJDIR) $(TARGET_HEX) - $(SIZE) $(TARGET_HEX) +size: $(OBJDIR) $(TARGET_ELF) + $(SIZE) -C --mcu=$(MCU) $(TARGET_ELF) show_boards: $(PARSE_BOARD_CMD) --boards From a128ce20209284393ca76cc9e3851707dc0be143 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Sun, 1 Jul 2012 12:52:36 +0200 Subject: [PATCH 15/83] allow user to choose source files --- .gitignore | 1 + arduino-mk/Arduino.mk | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 7294495..06cff06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.o build-cli +/.project diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index dd0db28..16e5929 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -3,6 +3,10 @@ # Arduino command line tools Makefile # System part (i.e. project independent) # +# Copyright (C) 2012 Gabriel Fournier , based on +# - M J Oldfield work: https://github.com/mjoldfield/Arduino-Makefile +# - sudar work: https://github.com/sudar/Arduino-Makefile.git +# # Copyright (C) 2010,2011,2012 Martin Oldfield , based on # work that is copyright Nicholas Zambetti, David A. Mellis & Hernando # Barragan. @@ -77,7 +81,11 @@ # - Moved the reset target to Perl for # clarity and better error handling (ex # Daniele Vergini) -# +# +# 0.9.1 01.vii.2012 Gaftech +# - Allow user to choose source files +# (LOCAL_*_SRCS flags) +# ######################################################################## # # PATHS YOU NEED TO SET UP @@ -421,12 +429,12 @@ OBJDIR = build-cli ######################################################################## # Local sources # -LOCAL_C_SRCS = $(wildcard *.c) -LOCAL_CPP_SRCS = $(wildcard *.cpp) -LOCAL_CC_SRCS = $(wildcard *.cc) -LOCAL_PDE_SRCS = $(wildcard *.pde) -LOCAL_INO_SRCS = $(wildcard *.ino) -LOCAL_AS_SRCS = $(wildcard *.S) +LOCAL_C_SRCS ?= $(wildcard *.c) +LOCAL_CPP_SRCS ?= $(wildcard *.cpp) +LOCAL_CC_SRCS ?= $(wildcard *.cc) +LOCAL_PDE_SRCS ?= $(wildcard *.pde) +LOCAL_INO_SRCS ?= $(wildcard *.ino) +LOCAL_AS_SRCS ?= $(wildcard *.S) LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \ $(LOCAL_CC_SRCS:.cc=.o) $(LOCAL_PDE_SRCS:.pde=.o) \ $(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o) From 489dbb6fbb3d4ecdf43784ecf84937b027904cc6 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Sun, 1 Jul 2012 13:04:39 +0200 Subject: [PATCH 16/83] modified 'make size' behaviour --- arduino-mk/Arduino.mk | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 16e5929..068ba0a 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -85,6 +85,9 @@ # 0.9.1 01.vii.2012 Gaftech # - Allow user to choose source files # (LOCAL_*_SRCS flags) +# - Modified 'make size' behaviour: using --mcu option +# and targetting .elf file instead of .hex +# file. # ######################################################################## # @@ -509,6 +512,7 @@ CFLAGS = -std=gnu99 CXXFLAGS = -fno-exceptions ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os +SIZEFLAGS ?= --mcu=$(MCU) -C # Expand and pick the first port ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) @@ -696,8 +700,8 @@ clean: depends: $(DEPS) cat $(DEPS) > $(DEP_FILE) -size: $(OBJDIR) $(TARGET_HEX) - $(SIZE) $(TARGET_HEX) +size: $(OBJDIR) $(TARGET_ELF) + $(SIZE) $(SIZEFLAGS) $(TARGET_ELF) show_boards: $(PARSE_BOARD_CMD) --boards From 8b99f165e781a7a3211802458750705026124af8 Mon Sep 17 00:00:00 2001 From: Sudar Date: Mon, 2 Jul 2012 13:47:28 +0530 Subject: [PATCH 17/83] Revert "Changed echo command to work on linux". Was having issues with Ubuntu and Mac This reverts commit 1e5d7c1a33955e70275f8f7e828498c98995590e. --- arduino-mk/Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index dd0db28..cfc25ef 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -476,7 +476,7 @@ NM = $(AVR_TOOLS_PATH)/avr-nm REMOVE = rm -rf MV = mv -f CAT = cat -ECHO = echo -e +ECHO = echo # General arguments SYS_LIBS = $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS)) From 9027158e5f3db99e51f21432f7be9bfdb7ad476c Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Tue, 3 Jul 2012 12:36:00 -0500 Subject: [PATCH 18/83] Add a disasm target to build the .lss file. --- arduino-mk/Arduino.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index d846977..ab83302 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -721,6 +721,8 @@ show_boards: monitor: $(MONITOR_CMD) $(ARD_PORT) $(MONITOR_BAUDRATE) +disasm: all $(OBJDIR)/$(TARGET).lss + .PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor include $(DEP_FILE) From 8896b8fcf60aea8ace1f2e08648dba5e1f60255f Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 12:29:33 -0500 Subject: [PATCH 19/83] Autodetect arduino version when possible --- arduino-mk/Arduino.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index ab83302..f3c22e4 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -292,8 +292,17 @@ endif # # Arduino version number ifndef ARDUINO_VERSION + +# Remove all the decimals, and right-pad with zeros, and finally grab the first 3 bytes. +# Works for 1.0 and 1.0.1 +AUTO_ARDUINO_VERSION := $(shell cat $(ARDUINO_DIR)/lib/version.txt | sed -e 's/[.]//g' -e 's/$$/0000/' | head --bytes=3) +ifdef AUTO_ARDUINO_VERSION +$(info Using guessed/detected ARDUINO version define $(AUTO_ARDUINO_VERSION)) +ARDUINO_VERSION = $(AUTO_ARDUINO_VERSION) +else ARDUINO_VERSION = 100 endif +endif ######################################################################## # Arduino and system paths From abad0738c047e503819e174b970f2317c3541cf2 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 12:45:05 -0500 Subject: [PATCH 20/83] Deduce whether we have an avr-patched version of size, and use it. --- arduino-mk/Arduino.mk | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index f3c22e4..11c7cf0 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -548,6 +548,14 @@ LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os # Expand and pick the first port ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) +# Command for avr_size: do $(call avr_size,elffile,hexfile) +SIZE_ACCEPTS_MCU = $(shell $(SIZE) --help | grep 'AVR' && echo TRUE || true) +ifdef SIZE_ACCEPTS_MCU +avr_size = $(SIZE) --mcu=$(MCU) --format=avr $(1) +else +avr_size = $(SIZE) $(2) +endif + # Implicit rules for building everything (needed to get everything in # the right directory) # @@ -722,7 +730,7 @@ depends: $(DEPS) cat $(DEPS) > $(DEP_FILE) size: $(OBJDIR) $(TARGET_HEX) - $(SIZE) $(TARGET_HEX) + $(call avr_size,$(TARGET_ELF),$(TARGET_HEX)) show_boards: $(PARSE_BOARD_CMD) --boards From 8273ef1153fc4ad103653749b980cc418f01dc4c Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 12:45:19 -0500 Subject: [PATCH 21/83] Dump size at the end of the build. --- arduino-mk/Arduino.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 11c7cf0..de16a0e 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -640,6 +640,9 @@ $(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp # various object conversions $(OBJDIR)/%.hex: $(OBJDIR)/%.elf $(OBJCOPY) -O ihex -R .eeprom $< $@ + # Dump size for microcontroller. + echo + $(call avr_size,$<,$@) $(OBJDIR)/%.eep: $(OBJDIR)/%.elf -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ From 040f5c7388367dc0633707e90fe86bb780a959ff Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 12:45:52 -0500 Subject: [PATCH 22/83] Remove trailing spaces --- arduino-mk/Arduino.mk | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index de16a0e..58337fe 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -6,7 +6,7 @@ # Copyright (C) 2010,2011,2012 Martin Oldfield , based on # work that is copyright Nicholas Zambetti, David A. Mellis & Hernando # Barragan. -# +# # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the @@ -39,13 +39,13 @@ # # 0.6 22.vi.2011 M J Oldfield # - added ard-parse-boards supports -# - added -lc to linker opts, +# - added -lc to linker opts, # on Fabien Le Lez's advice # # 0.7 12.vii.2011 M J Oldfield # - moved -lm to the end of linker opts, # to solve Frank Knopf's problem; -# - added -F to stty opts: Craig Hollabaugh +# - added -F to stty opts: Craig Hollabaugh # reckons it's good for Ubuntu # # 0.8 12.ii.2012 M J Oldfield @@ -72,12 +72,12 @@ # defined (ex Peplin) # - Added a monitor target which talks to the # Arduino serial port (Peplin's suggestion) -# - Rejigged PATH calculations for general +# - Rejigged PATH calculations for general # tidiness (ex Peplin) # - Moved the reset target to Perl for # clarity and better error handling (ex # Daniele Vergini) -# +# ######################################################################## # # PATHS YOU NEED TO SET UP @@ -90,7 +90,7 @@ # 1. Things which are included in this distribution e.g. ard-parse-boards # => ARDMK_DIR # -# 2. Things which are always in the Arduino distribution e.g. +# 2. Things which are always in the Arduino distribution e.g. # boards.txt, libraries, &c. # => ARDUINO_DIR # @@ -114,13 +114,13 @@ # ARDMK_DIR = /usr/local # AVR_TOOLS_DIR = /usr # -# You can either set these up in the Makefile, or put them in your +# You can either set these up in the Makefile, or put them in your # environment e.g. in your .bashrc # # If you don't install the ard-... binaries to /usr/local/bin, but # instead copy them to e.g. /home/mjo/arduino.mk/bin then set # ARDML_DIR = /home/mjo/arduino.mk -# +# ######################################################################## # # DEPENDENCIES @@ -148,7 +148,7 @@ # # ARDUINO_LIBS - A list of any libraries used by the sketch (we # assume these are in -# $(ARDUINO_DIR)/hardware/libraries +# $(ARDUINO_DIR)/hardware/libraries # # ARDUINO_PORT - The port where the Arduino can be found (only needed # when uploading @@ -182,7 +182,7 @@ # SERIAL MONITOR # # The serial monitor just invokes the GNU screen program with suitable -# options. For more information see screen (1) and search for +# options. For more information see screen (1) and search for # 'character special device'. # # The really useful thing to know is that ^A-k gets you out! @@ -207,7 +207,7 @@ # 1. Things which are included in this distribution e.g. ard-parse-boards # => ARDMK_DIR # -# 2. Things which are always in the Arduino distribution e.g. +# 2. Things which are always in the Arduino distribution e.g. # boards.txt, libraries, &c. # => ARDUINO_DIR # @@ -232,7 +232,7 @@ # AVR_TOOLS_DIR = /usr # # -# +# # ######################################################################## # @@ -246,7 +246,7 @@ # # You might also need to set the fuse bits, but typically they'll be # read from boards.txt, based on the BOARD_TAG variable: -# +# # ISP_LOCK_FUSE_PRE = 0x3f # ISP_LOCK_FUSE_POST = 0xcf # ISP_HIGH_FUSE = 0xdf @@ -255,7 +255,7 @@ # # I think the fuses here are fine for uploading to the ATmega168 # without bootloader. -# +# # To actually do this upload use the ispload target: # # make ispload @@ -281,7 +281,7 @@ $(info Using autodetected ARDUINO_DIR '$(ARDUINO_DIR)') endif endif ######################################################################## -# +# # Default TARGET to cwd (ex Daniele Vergini) ifndef TARGET TARGET = $(notdir $(CURDIR)) @@ -701,19 +701,19 @@ raw_upload: $(TARGET_HEX) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ -U flash:w:$(TARGET_HEX):i -reset: +reset: $(RESET_CMD) $(ARD_PORT) # stty on MacOS likes -F, but on Debian it likes -f redirecting # stdin/out appears to work but generates a spurious error on MacOS at # least. Perhaps it would be better to just do it in perl ? -reset_stty: +reset_stty: for STTYF in 'stty -F' 'stty --file' 'stty -f' 'stty <' ; \ do $$STTYF /dev/tty >/dev/null 2>/dev/null && break ; \ done ;\ $$STTYF $(ARD_PORT) hupcl ;\ (sleep 0.1 || sleep 1) ;\ - $$STTYF $(ARD_PORT) -hupcl + $$STTYF $(ARD_PORT) -hupcl ispload: $(TARGET_HEX) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \ @@ -735,7 +735,7 @@ depends: $(DEPS) size: $(OBJDIR) $(TARGET_HEX) $(call avr_size,$(TARGET_ELF),$(TARGET_HEX)) -show_boards: +show_boards: $(PARSE_BOARD_CMD) --boards monitor: From 3bb4bde491e4a390312a5cedaf92f40d459deffd Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 12:57:02 -0500 Subject: [PATCH 23/83] Remove duplicated section of documentation. --- arduino-mk/Arduino.mk | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 58337fe..5ae497a 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -197,45 +197,6 @@ # ######################################################################## # -# PATHS -# -# I've reworked the way paths to executables are constructed in this -# version of Makefile. -# -# We need to worry about three different sorts of file: -# -# 1. Things which are included in this distribution e.g. ard-parse-boards -# => ARDMK_DIR -# -# 2. Things which are always in the Arduino distribution e.g. -# boards.txt, libraries, &c. -# => ARDUINO_DIR -# -# 3. Things which might be bundled with the Arduino distribution, but -# might come from the system. Most of the toolchain is like this: -# on Linux it's supplied by the system. -# => AVR_TOOLS_DIR -# -# Having set these three variables, we can work out the rest assuming -# that things are canonically arranged beneath the directories defined -# above. -# -# So, on the Mac you might want to set: -# -# ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java -# ARDMK_DIR = /usr/local -# -# On Linux, you might prefer: -# -# ARDUINO_DIR = /usr/share/arduino -# ARDMK_DIR = /usr/local -# AVR_TOOLS_DIR = /usr -# -# -# -# -######################################################################## -# # ARDUINO WITH ISP # # You need to specify some details of your ISP programmer and might From aaf74a971acf570c9ed71894915c7f476a814e97 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 12:57:24 -0500 Subject: [PATCH 24/83] Add autodetection caveat to docs --- arduino-mk/Arduino.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5ae497a..2c88de3 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -117,6 +117,9 @@ # You can either set these up in the Makefile, or put them in your # environment e.g. in your .bashrc # +# If you don't specify these, we can try to guess, but that might not work +# or work the way you want it to. +# # If you don't install the ard-... binaries to /usr/local/bin, but # instead copy them to e.g. /home/mjo/arduino.mk/bin then set # ARDML_DIR = /home/mjo/arduino.mk From 2a5e7fd242e38256b3a4e80bc655a97b8791e85b Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 12:57:32 -0500 Subject: [PATCH 25/83] Fix typo in docs --- arduino-mk/Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 2c88de3..d33640b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -154,7 +154,7 @@ # $(ARDUINO_DIR)/hardware/libraries # # ARDUINO_PORT - The port where the Arduino can be found (only needed -# when uploading +# when uploading) # # BOARD_TAG - The ard-parse-boards tag for the board e.g. uno or mega # 'make show_boards' shows a list From 229187d26c444feeb64fffd24757237735d2b36c Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 12:57:45 -0500 Subject: [PATCH 26/83] add the size and disasm targets to the docs --- arduino-mk/Arduino.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index d33640b..1c7935e 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -179,6 +179,11 @@ # make raw_upload - upload without first resetting # make show_boards - list all the boards defined in boards.txt # make monitor - connect to the Arduino's serial port +# make size - show the size of the compiled output (relative to +# resources, if you have a patched avr-size) +# make disasm - generate a .lss file in build-cli that contains +# disassembly of the compiled file interspersed +# with your original source code. # ######################################################################## # From 6ab91c23be6a9a7b34d1d634a0d5b12b9b5ca7f3 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 12:58:05 -0500 Subject: [PATCH 27/83] Clarify where we actually look for libs --- arduino-mk/Arduino.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 1c7935e..f3f2e32 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -150,8 +150,8 @@ # Hopefully these will be self-explanatory but in case they're not: # # ARDUINO_LIBS - A list of any libraries used by the sketch (we -# assume these are in -# $(ARDUINO_DIR)/hardware/libraries +# assume these are in $(ARDUINO_DIR)/hardware/libraries +# or your sketchbook's libraries directory) # # ARDUINO_PORT - The port where the Arduino can be found (only needed # when uploading) From 13000c35ca5026d4ca8e22c3b973eabcd272ddec Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 12:58:32 -0500 Subject: [PATCH 28/83] Add info about setting USER_LIB_PATH and ARDMK_DIR relative to source. --- arduino-mk/Arduino.mk | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index f3f2e32..88bf0c4 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -159,7 +159,19 @@ # BOARD_TAG - The ard-parse-boards tag for the board e.g. uno or mega # 'make show_boards' shows a list # -# Once this file has been created the typical workflow is just +# If you have your additional libraries relative to your source, rather +# than in your "sketchbook", also set USER_LIB_PATH, like this example: +# +# USER_LIB_PATH := $(realpath ../../libraries) +# +# If you've added the Arduino-Makefile repository to your git repo as a +# submodule (or other similar arrangement), you might have lines like this +# in your Makefile: +# +# ARDMK_DIR := $(realpath ../../tools/Arduino-Makefile) +# include $(ARDMK_DIR)/arduino-mk/Arduino.mk +# +# In any case, once this file has been created the typical workflow is just # # $ make upload # From 1f1f43822787985e4de308949f14f9314cedb05e Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 13:58:54 -0500 Subject: [PATCH 29/83] Clean up and improve displayed output. --- arduino-mk/Arduino.mk | 99 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 84 insertions(+), 15 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 88bf0c4..e8c5f56 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -245,6 +245,25 @@ ######################################################################## dir_if_exists = $(shell test -e $(1)$(2) && echo $(1) || true) +# Useful functions +# Returns the first argument (typically a directory), if the file or directory +# named by concatenating the first and optionally second argument +# (directory and optional filename) exists + +# For message printing: pad the right side of the first argument with spaces to +# the number of bytes indicated by the second argument. +space_pad_to = $(shell echo $(1) " " | head --bytes=$(2)) + +# Call with the name of the variable, a prefix tag if desired (like [AUTODETECTED]), +# and an explanation if desired (like (found in $$PATH) +show_config_info = $(info - $(call space_pad_to,$(2),20) $(1) = $($(1)) $(3)) + +# Just a nice simple visual separator +show_separator = $(info -------------------------) + + +$(call show_separator) +$(info Arduino.mk Configuration:) ifndef ARDUINO_DIR NIX_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/usr/share/arduino) @@ -258,8 +277,11 @@ ARDUINO_DIR = $(MAC_DEFAULT_ARDUINO_DIR) endif ifdef ARDUINO_DIR -$(info Using autodetected ARDUINO_DIR '$(ARDUINO_DIR)') +$(call show_config_info,ARDUINO_DIR,[AUTODETECTED]) endif + +else +$(call show_config_info,ARDUINO_DIR) endif ######################################################################## # @@ -278,11 +300,14 @@ ifndef ARDUINO_VERSION # Works for 1.0 and 1.0.1 AUTO_ARDUINO_VERSION := $(shell cat $(ARDUINO_DIR)/lib/version.txt | sed -e 's/[.]//g' -e 's/$$/0000/' | head --bytes=3) ifdef AUTO_ARDUINO_VERSION -$(info Using guessed/detected ARDUINO version define $(AUTO_ARDUINO_VERSION)) ARDUINO_VERSION = $(AUTO_ARDUINO_VERSION) +$(call show_config_info,ARDUINO_VERSION,[AUTODETECTED]) else ARDUINO_VERSION = 100 +$(call show_config_info,ARDUINO_VERSION,[DEFAULT]) endif +else +$(call show_config_info,ARDUINO_VERSION) endif ######################################################################## @@ -293,29 +318,27 @@ ifdef ARDUINO_DIR ifndef AVR_TOOLS_DIR BUNDLED_AVR_TOOLS_DIR := $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/avr) - ifdef BUNDLED_AVR_TOOLS_DIR -$(info Using autodetected (bundled) AVR_TOOLS_DIR '$(BUNDLED_AVR_TOOLS_DIR)') AVR_TOOLS_DIR = $(BUNDLED_AVR_TOOLS_DIR) # The avrdude bundled with Arduino can't find it's config AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf +$(call show_config_info,AVR_TOOLS_DIR,[BUNDLED],(in Arduino distribution)) else SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which avr-gcc))/..)) ifdef SYSTEMPATH_AVR_TOOLS_DIR -$(info Using autodetected (from PATH) AVR_TOOLS_DIR '$(SYSTEMPATH_AVR_TOOLS_DIR)') AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR) +$(call show_config_info,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH)) endif # SYSTEMPATH_AVR_TOOLS_DIR -endif # BUNDLED_AVR_TOOLS_EIR +endif # BUNDLED_AVR_TOOLS_DIR +else + +$(call show_config_info,AVR_TOOLS_DIR) endif #ndef AVR_TOOLS_DIR -ifndef AVR_TOOLS_PATH -AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin -endif - ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants @@ -326,13 +349,26 @@ echo $(error "ARDUINO_DIR is not defined") endif +ifdef AVR_TOOLS_DIR + +ifndef AVR_TOOLS_PATH +AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin +endif + +endif + ######################################################################## # Makefile distribution path # ifdef ARDMK_DIR +$(call show_config_info,ARDMK_DIR) ifndef ARDMK_PATH ARDMK_PATH = $(ARDMK_DIR)/bin +$(call show_config_info,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR)) + +else +$(call show_config_info,ARDMK_PATH) endif else @@ -350,6 +386,9 @@ endif ifndef USER_LIB_PATH USER_LIB_PATH = $(ARDUINO_SKETCHBOOK)/libraries +$(call show_config_info,USER_LIB_PATH,[DEFAULT],(in user sketchbook)) +else +$(call show_config_info,USER_LIB_PATH) endif ######################################################################## @@ -378,6 +417,9 @@ endif # ifndef BOARD_TAG BOARD_TAG = uno +$(call show_config_info,BOARD_TAG,[DEFAULT]) +else +$(call show_config_info,BOARD_TAG) endif ifndef BOARDS_TXT @@ -468,12 +510,15 @@ CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp) ifneq ($(strip $(NO_CORE_MAIN_CPP)),) CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS)) +$(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE_MAIN_CPP)) endif CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o) CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \ $(OBJDIR)/%,$(CORE_OBJ_FILES)) endif +else +$(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE)) endif @@ -529,14 +574,38 @@ LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os # Expand and pick the first port ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) +ifndef SIZE_UTILITY_TYPE # Command for avr_size: do $(call avr_size,elffile,hexfile) -SIZE_ACCEPTS_MCU = $(shell $(SIZE) --help | grep 'AVR' && echo TRUE || true) -ifdef SIZE_ACCEPTS_MCU -avr_size = $(SIZE) --mcu=$(MCU) --format=avr $(1) +ifneq (,$(findstring AVR,$(shell $(SIZE) --help))) +SIZE_UTILITY_TYPE = AVR_ENHANCED else +SIZE_UTILITY_TYPE = BASIC +endif +$(call show_config_info,SIZE_UTILITY_TYPE,[AUTODETECTED]) + +else +$(call show_config_info,SIZE_UTILITY_TYPE,[MANUAL OVERRIDE],Warning - Manually overriding this is not recommended!) +endif + +ifeq ($(SIZE_UTILITY_TYPE),BASIC) +# We have a plain-old binutils version - just give it the hex. avr_size = $(SIZE) $(2) endif +ifeq ($(SIZE_UTILITY_TYPE),AVR_ENHANCED) +# We have a patched version of binutils that mentions AVR - pass the MCU +# and the elf to get nice output. +avr_size = $(SIZE) --mcu=$(MCU) --format=avr $(1) +endif + +ifndef avr_size +$(error "We told you not to override SIZE_UTILITY_TYPE!") +endif + +# end of config output +$(call show_separator) + + # Implicit rules for building everything (needed to get everything in # the right directory) # @@ -621,8 +690,8 @@ $(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp # various object conversions $(OBJDIR)/%.hex: $(OBJDIR)/%.elf $(OBJCOPY) -O ihex -R .eeprom $< $@ - # Dump size for microcontroller. - echo + @echo + @echo $(call avr_size,$<,$@) $(OBJDIR)/%.eep: $(OBJDIR)/%.elf From 49cca1da1161ce909c1d28a95a7e48084cdfc871 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 13:59:12 -0500 Subject: [PATCH 30/83] Less shell-based implementation of dir_if_exists --- arduino-mk/Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index e8c5f56..4a020bc 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -244,11 +244,11 @@ # ######################################################################## -dir_if_exists = $(shell test -e $(1)$(2) && echo $(1) || true) # Useful functions # Returns the first argument (typically a directory), if the file or directory # named by concatenating the first and optionally second argument # (directory and optional filename) exists +dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) # For message printing: pad the right side of the first argument with spaces to # the number of bytes indicated by the second argument. From 744cb5350d5a80d4368d7a22e4a9ec1e7c9fb408 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 14:04:35 -0500 Subject: [PATCH 31/83] Clarify by adding (space-based) indentation. Helps simplify understanding all the nested conditionals. --- arduino-mk/Arduino.mk | 230 +++++++++++++++++++++--------------------- 1 file changed, 115 insertions(+), 115 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 4a020bc..39e5697 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -266,28 +266,28 @@ $(call show_separator) $(info Arduino.mk Configuration:) ifndef ARDUINO_DIR -NIX_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/usr/share/arduino) -ifdef NIX_DEFAULT_ARDUINO_DIR -ARDUINO_DIR = $(NIX_DEFAULT_ARDUINO_DIR) -endif + NIX_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/usr/share/arduino) + ifdef NIX_DEFAULT_ARDUINO_DIR + ARDUINO_DIR = $(NIX_DEFAULT_ARDUINO_DIR) + endif -MAC_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/Applications/Arduino.app/Contents/Resources/Java) -ifdef MAC_DEFAULT_ARDUINO_DIR -ARDUINO_DIR = $(MAC_DEFAULT_ARDUINO_DIR) -endif + MAC_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/Applications/Arduino.app/Contents/Resources/Java) + ifdef MAC_DEFAULT_ARDUINO_DIR + ARDUINO_DIR = $(MAC_DEFAULT_ARDUINO_DIR) + endif -ifdef ARDUINO_DIR -$(call show_config_info,ARDUINO_DIR,[AUTODETECTED]) -endif + ifdef ARDUINO_DIR + $(call show_config_info,ARDUINO_DIR,[AUTODETECTED]) + endif else -$(call show_config_info,ARDUINO_DIR) + $(call show_config_info,ARDUINO_DIR) endif ######################################################################## # # Default TARGET to cwd (ex Daniele Vergini) ifndef TARGET -TARGET = $(notdir $(CURDIR)) + TARGET = $(notdir $(CURDIR)) endif ######################################################################## @@ -296,18 +296,18 @@ endif # Arduino version number ifndef ARDUINO_VERSION -# Remove all the decimals, and right-pad with zeros, and finally grab the first 3 bytes. -# Works for 1.0 and 1.0.1 -AUTO_ARDUINO_VERSION := $(shell cat $(ARDUINO_DIR)/lib/version.txt | sed -e 's/[.]//g' -e 's/$$/0000/' | head --bytes=3) -ifdef AUTO_ARDUINO_VERSION -ARDUINO_VERSION = $(AUTO_ARDUINO_VERSION) -$(call show_config_info,ARDUINO_VERSION,[AUTODETECTED]) + # Remove all the decimals, and right-pad with zeros, and finally grab the first 3 bytes. + # Works for 1.0 and 1.0.1 + AUTO_ARDUINO_VERSION := $(shell cat $(ARDUINO_DIR)/lib/version.txt | sed -e 's/[.]//g' -e 's/$$/0000/' | head --bytes=3) + ifdef AUTO_ARDUINO_VERSION + ARDUINO_VERSION = $(AUTO_ARDUINO_VERSION) + $(call show_config_info,ARDUINO_VERSION,[AUTODETECTED]) + else + ARDUINO_VERSION = 100 + $(call show_config_info,ARDUINO_VERSION,[DEFAULT]) + endif else -ARDUINO_VERSION = 100 -$(call show_config_info,ARDUINO_VERSION,[DEFAULT]) -endif -else -$(call show_config_info,ARDUINO_VERSION) + $(call show_config_info,ARDUINO_VERSION) endif ######################################################################## @@ -315,45 +315,45 @@ endif # ifdef ARDUINO_DIR -ifndef AVR_TOOLS_DIR + ifndef AVR_TOOLS_DIR -BUNDLED_AVR_TOOLS_DIR := $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/avr) -ifdef BUNDLED_AVR_TOOLS_DIR -AVR_TOOLS_DIR = $(BUNDLED_AVR_TOOLS_DIR) -# The avrdude bundled with Arduino can't find it's config -AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf -$(call show_config_info,AVR_TOOLS_DIR,[BUNDLED],(in Arduino distribution)) + BUNDLED_AVR_TOOLS_DIR := $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/avr) + ifdef BUNDLED_AVR_TOOLS_DIR + AVR_TOOLS_DIR = $(BUNDLED_AVR_TOOLS_DIR) + # The avrdude bundled with Arduino can't find it's config + AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf + $(call show_config_info,AVR_TOOLS_DIR,[BUNDLED],(in Arduino distribution)) + + else + + SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which avr-gcc))/..)) + ifdef SYSTEMPATH_AVR_TOOLS_DIR + AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR) + $(call show_config_info,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH)) + endif # SYSTEMPATH_AVR_TOOLS_DIR + + endif # BUNDLED_AVR_TOOLS_DIR + + else + + $(call show_config_info,AVR_TOOLS_DIR) + endif #ndef AVR_TOOLS_DIR + + ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries + ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino + ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants else -SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which avr-gcc))/..)) -ifdef SYSTEMPATH_AVR_TOOLS_DIR -AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR) -$(call show_config_info,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH)) -endif # SYSTEMPATH_AVR_TOOLS_DIR - -endif # BUNDLED_AVR_TOOLS_DIR - -else - -$(call show_config_info,AVR_TOOLS_DIR) -endif #ndef AVR_TOOLS_DIR - -ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries -ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino -ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants - -else - -echo $(error "ARDUINO_DIR is not defined") + echo $(error "ARDUINO_DIR is not defined") endif ifdef AVR_TOOLS_DIR -ifndef AVR_TOOLS_PATH -AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin -endif + ifndef AVR_TOOLS_PATH + AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin + endif endif @@ -361,19 +361,19 @@ endif # Makefile distribution path # ifdef ARDMK_DIR -$(call show_config_info,ARDMK_DIR) + $(call show_config_info,ARDMK_DIR) -ifndef ARDMK_PATH -ARDMK_PATH = $(ARDMK_DIR)/bin -$(call show_config_info,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR)) + ifndef ARDMK_PATH + ARDMK_PATH = $(ARDMK_DIR)/bin + $(call show_config_info,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR)) -else -$(call show_config_info,ARDMK_PATH) -endif + else + $(call show_config_info,ARDMK_PATH) + endif else -echo $(error "ARDMK_DIR is not defined") + echo $(error "ARDMK_DIR is not defined") endif @@ -381,14 +381,14 @@ endif # Miscellanea # ifndef ARDUINO_SKETCHBOOK -ARDUINO_SKETCHBOOK = $(HOME)/sketchbook + ARDUINO_SKETCHBOOK = $(HOME)/sketchbook endif ifndef USER_LIB_PATH -USER_LIB_PATH = $(ARDUINO_SKETCHBOOK)/libraries -$(call show_config_info,USER_LIB_PATH,[DEFAULT],(in user sketchbook)) + USER_LIB_PATH = $(ARDUINO_SKETCHBOOK)/libraries + $(call show_config_info,USER_LIB_PATH,[DEFAULT],(in user sketchbook)) else -$(call show_config_info,USER_LIB_PATH) + $(call show_config_info,USER_LIB_PATH) endif ######################################################################## @@ -399,87 +399,87 @@ endif # for more information (search for 'character special device'). # ifndef MONITOR_BAUDRATE -MONITOR_BAUDRATE = 9600 + MONITOR_BAUDRATE = 9600 endif ifndef MONITOR_CMD -MONITOR_CMD = screen + MONITOR_CMD = screen endif ######################################################################## # Reset ifndef RESET_CMD -RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino $(ARD_RESET_OPTS) + RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino $(ARD_RESET_OPTS) endif ######################################################################## # boards.txt parsing # ifndef BOARD_TAG -BOARD_TAG = uno -$(call show_config_info,BOARD_TAG,[DEFAULT]) + BOARD_TAG = uno + $(call show_config_info,BOARD_TAG,[DEFAULT]) else -$(call show_config_info,BOARD_TAG) + $(call show_config_info,BOARD_TAG) endif ifndef BOARDS_TXT -BOARDS_TXT = $(ARDUINO_DIR)/hardware/arduino/boards.txt + BOARDS_TXT = $(ARDUINO_DIR)/hardware/arduino/boards.txt endif ifndef PARSE_BOARD -PARSE_BOARD = $(ARDMK_PATH)/ard-parse-boards + PARSE_BOARD = $(ARDMK_PATH)/ard-parse-boards endif ifndef PARSE_BOARD_OPTS -PARSE_BOARD_OPTS = --boards_txt=$(BOARDS_TXT) + PARSE_BOARD_OPTS = --boards_txt=$(BOARDS_TXT) endif ifndef PARSE_BOARD_CMD -PARSE_BOARD_CMD = $(PARSE_BOARD) $(PARSE_BOARD_OPTS) + PARSE_BOARD_CMD = $(PARSE_BOARD) $(PARSE_BOARD_OPTS) endif # Which variant ? This affects the include path ifndef VARIANT -VARIANT = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.variant) + VARIANT = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.variant) endif # processor stuff ifndef MCU -MCU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.mcu) + MCU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.mcu) endif ifndef F_CPU -F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu) + F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu) endif # normal programming info ifndef AVRDUDE_ARD_PROGRAMMER -AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.protocol) + AVRDUDE_ARD_PROGRAMMER = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.protocol) endif ifndef AVRDUDE_ARD_BAUDRATE -AVRDUDE_ARD_BAUDRATE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.speed) + AVRDUDE_ARD_BAUDRATE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.speed) endif # fuses if you're using e.g. ISP ifndef ISP_LOCK_FUSE_PRE -ISP_LOCK_FUSE_PRE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.unlock_bits) + ISP_LOCK_FUSE_PRE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.unlock_bits) endif ifndef ISP_LOCK_FUSE_POST -ISP_LOCK_FUSE_POST = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.lock_bits) + ISP_LOCK_FUSE_POST = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.lock_bits) endif ifndef ISP_HIGH_FUSE -ISP_HIGH_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.high_fuses) + ISP_HIGH_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.high_fuses) endif ifndef ISP_LOW_FUSE -ISP_LOW_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.low_fuses) + ISP_LOW_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.low_fuses) endif ifndef ISP_EXT_FUSE -ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended_fuses) + ISP_EXT_FUSE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) bootloader.extended_fuses) endif # Everything gets built in here @@ -504,21 +504,21 @@ DEPS = $(LOCAL_OBJS:.o=.d) # core sources ifeq ($(strip $(NO_CORE)),) -ifdef ARDUINO_CORE_PATH -CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c) -CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp) + ifdef ARDUINO_CORE_PATH + CORE_C_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.c) + CORE_CPP_SRCS = $(wildcard $(ARDUINO_CORE_PATH)/*.cpp) -ifneq ($(strip $(NO_CORE_MAIN_CPP)),) -CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS)) -$(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE_MAIN_CPP)) -endif + ifneq ($(strip $(NO_CORE_MAIN_CPP)),) + CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS)) + $(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE_MAIN_CPP)) + endif -CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o) -CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \ - $(OBJDIR)/%,$(CORE_OBJ_FILES)) -endif + CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o) + CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \ + $(OBJDIR)/%,$(CORE_OBJ_FILES)) + endif else -$(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE)) + $(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE)) endif @@ -575,31 +575,31 @@ LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) ifndef SIZE_UTILITY_TYPE -# Command for avr_size: do $(call avr_size,elffile,hexfile) -ifneq (,$(findstring AVR,$(shell $(SIZE) --help))) -SIZE_UTILITY_TYPE = AVR_ENHANCED -else -SIZE_UTILITY_TYPE = BASIC -endif -$(call show_config_info,SIZE_UTILITY_TYPE,[AUTODETECTED]) + # Command for avr_size: do $(call avr_size,elffile,hexfile) + ifneq (,$(findstring AVR,$(shell $(SIZE) --help))) + SIZE_UTILITY_TYPE = AVR_ENHANCED + else + SIZE_UTILITY_TYPE = BASIC + endif + $(call show_config_info,SIZE_UTILITY_TYPE,[AUTODETECTED]) else -$(call show_config_info,SIZE_UTILITY_TYPE,[MANUAL OVERRIDE],Warning - Manually overriding this is not recommended!) + $(call show_config_info,SIZE_UTILITY_TYPE,[MANUAL OVERRIDE],Warning - Manually overriding this is not recommended!) endif ifeq ($(SIZE_UTILITY_TYPE),BASIC) -# We have a plain-old binutils version - just give it the hex. -avr_size = $(SIZE) $(2) + # We have a plain-old binutils version - just give it the hex. + avr_size = $(SIZE) $(2) endif ifeq ($(SIZE_UTILITY_TYPE),AVR_ENHANCED) -# We have a patched version of binutils that mentions AVR - pass the MCU -# and the elf to get nice output. -avr_size = $(SIZE) --mcu=$(MCU) --format=avr $(1) + # We have a patched version of binutils that mentions AVR - pass the MCU + # and the elf to get nice output. + avr_size = $(SIZE) --mcu=$(MCU) --format=avr $(1) endif ifndef avr_size -$(error "We told you not to override SIZE_UTILITY_TYPE!") + $(error "We told you not to override SIZE_UTILITY_TYPE!") endif # end of config output @@ -709,18 +709,18 @@ $(OBJDIR)/%.sym: $(OBJDIR)/%.elf # Avrdude # ifndef AVRDUDE -AVRDUDE = $(AVR_TOOLS_PATH)/avrdude + AVRDUDE = $(AVR_TOOLS_PATH)/avrdude endif AVRDUDE_COM_OPTS = -q -V -p $(MCU) ifdef AVRDUDE_CONF -AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF) + AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF) endif AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(ARD_PORT) ifndef ISP_PROG -ISP_PROG = -c stk500v2 + ISP_PROG = -c stk500v2 endif AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG) From 940a6b6ecca5af82fc2363027fde2be41642f33e Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 14:39:32 -0500 Subject: [PATCH 32/83] Simplify finding arduino dir --- arduino-mk/Arduino.mk | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 39e5697..0118855 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -266,17 +266,11 @@ $(call show_separator) $(info Arduino.mk Configuration:) ifndef ARDUINO_DIR - NIX_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/usr/share/arduino) - ifdef NIX_DEFAULT_ARDUINO_DIR - ARDUINO_DIR = $(NIX_DEFAULT_ARDUINO_DIR) - endif - - MAC_DEFAULT_ARDUINO_DIR := $(call dir_if_exists,/Applications/Arduino.app/Contents/Resources/Java) - ifdef MAC_DEFAULT_ARDUINO_DIR - ARDUINO_DIR = $(MAC_DEFAULT_ARDUINO_DIR) - endif - - ifdef ARDUINO_DIR + AUTO_ARDUINO_DIR := $(firstword \ + $(call dir_if_exists,/usr/share/arduino) \ + $(call dir_if_exists,/Applications/Arduino.app/Contents/Resources/Java) ) + ifdef AUTO_ARDUINO_DIR + ARDUINO_DIR = $(AUTO_ARDUINO_DIR) $(call show_config_info,ARDUINO_DIR,[AUTODETECTED]) endif From e6ac1cae3aeb851bad9a22767cbf4d2faa8261c2 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 14:39:50 -0500 Subject: [PATCH 33/83] Simplify user and system libraries --- arduino-mk/Arduino.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 0118855..f28a104 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -543,8 +543,8 @@ CAT = cat ECHO = echo # General arguments -SYS_LIBS = $(foreach libdir,$(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS)),$(call dir_if_exists,$(libdir))) -USER_LIBS = $(foreach libdir,$(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS)),$(call dir_if_exists,$(libdir))) +SYS_LIBS = $(wildcard $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS))) +USER_LIBS = $(wildcard $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS))) SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS)) USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS)) LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS))) From 6c7a8bad60e56502c91da9ab4b3588dbd3ab21f4 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 15:01:11 -0500 Subject: [PATCH 34/83] rename functions to allow nicer output. This also lets us restore the non-overridable detection of avr-size type. --- arduino-mk/Arduino.mk | 79 ++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index f28a104..5ab69c8 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -254,9 +254,12 @@ dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) # the number of bytes indicated by the second argument. space_pad_to = $(shell echo $(1) " " | head --bytes=$(2)) +# Call with some text, and a prefix tag if desired (like [AUTODETECTED]), +show_config_info = $(info - $(call space_pad_to,$(2),20) $(1)) + # Call with the name of the variable, a prefix tag if desired (like [AUTODETECTED]), # and an explanation if desired (like (found in $$PATH) -show_config_info = $(info - $(call space_pad_to,$(2),20) $(1) = $($(1)) $(3)) +show_config_variable = $(call show_config_info,$(1) = $($(1)) $(3),$(2)) # Just a nice simple visual separator show_separator = $(info -------------------------) @@ -271,11 +274,11 @@ ifndef ARDUINO_DIR $(call dir_if_exists,/Applications/Arduino.app/Contents/Resources/Java) ) ifdef AUTO_ARDUINO_DIR ARDUINO_DIR = $(AUTO_ARDUINO_DIR) - $(call show_config_info,ARDUINO_DIR,[AUTODETECTED]) + $(call show_config_variable,ARDUINO_DIR,[AUTODETECTED]) endif else - $(call show_config_info,ARDUINO_DIR) + $(call show_config_variable,ARDUINO_DIR) endif ######################################################################## # @@ -295,13 +298,13 @@ ifndef ARDUINO_VERSION AUTO_ARDUINO_VERSION := $(shell cat $(ARDUINO_DIR)/lib/version.txt | sed -e 's/[.]//g' -e 's/$$/0000/' | head --bytes=3) ifdef AUTO_ARDUINO_VERSION ARDUINO_VERSION = $(AUTO_ARDUINO_VERSION) - $(call show_config_info,ARDUINO_VERSION,[AUTODETECTED]) + $(call show_config_variable,ARDUINO_VERSION,[AUTODETECTED]) else ARDUINO_VERSION = 100 - $(call show_config_info,ARDUINO_VERSION,[DEFAULT]) + $(call show_config_variable,ARDUINO_VERSION,[DEFAULT]) endif else - $(call show_config_info,ARDUINO_VERSION) + $(call show_config_variable,ARDUINO_VERSION) endif ######################################################################## @@ -316,24 +319,25 @@ ifdef ARDUINO_DIR AVR_TOOLS_DIR = $(BUNDLED_AVR_TOOLS_DIR) # The avrdude bundled with Arduino can't find it's config AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf - $(call show_config_info,AVR_TOOLS_DIR,[BUNDLED],(in Arduino distribution)) + $(call show_config_variable,AVR_TOOLS_DIR,[BUNDLED],(in Arduino distribution)) else SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which avr-gcc))/..)) ifdef SYSTEMPATH_AVR_TOOLS_DIR AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR) - $(call show_config_info,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH)) + $(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH)) endif # SYSTEMPATH_AVR_TOOLS_DIR endif # BUNDLED_AVR_TOOLS_DIR else - $(call show_config_info,AVR_TOOLS_DIR) + $(call show_config_variable,AVR_TOOLS_DIR) endif #ndef AVR_TOOLS_DIR ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries + $(call show_config_variable,ARDUINO_LIB_PATH,[COMPUTED],(from ARDUINO_DIR)) ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants @@ -355,14 +359,14 @@ endif # Makefile distribution path # ifdef ARDMK_DIR - $(call show_config_info,ARDMK_DIR) + $(call show_config_variable,ARDMK_DIR) ifndef ARDMK_PATH ARDMK_PATH = $(ARDMK_DIR)/bin - $(call show_config_info,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR)) + $(call show_config_variable,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR)) else - $(call show_config_info,ARDMK_PATH) + $(call show_config_variable,ARDMK_PATH) endif else @@ -380,9 +384,9 @@ endif ifndef USER_LIB_PATH USER_LIB_PATH = $(ARDUINO_SKETCHBOOK)/libraries - $(call show_config_info,USER_LIB_PATH,[DEFAULT],(in user sketchbook)) + $(call show_config_variable,USER_LIB_PATH,[DEFAULT],(in user sketchbook)) else - $(call show_config_info,USER_LIB_PATH) + $(call show_config_variable,USER_LIB_PATH) endif ######################################################################## @@ -411,9 +415,9 @@ endif # ifndef BOARD_TAG BOARD_TAG = uno - $(call show_config_info,BOARD_TAG,[DEFAULT]) + $(call show_config_variable,BOARD_TAG,[DEFAULT]) else - $(call show_config_info,BOARD_TAG) + $(call show_config_variable,BOARD_TAG) endif ifndef BOARDS_TXT @@ -504,7 +508,7 @@ ifeq ($(strip $(NO_CORE)),) ifneq ($(strip $(NO_CORE_MAIN_CPP)),) CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS)) - $(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE_MAIN_CPP)) + $(call show_config_info,NO_CORE_MAIN_CPP set so core library will not include main.cpp,[MANUAL]) endif CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o) @@ -512,7 +516,7 @@ ifeq ($(strip $(NO_CORE)),) $(OBJDIR)/%,$(CORE_OBJ_FILES)) endif else - $(call show_config_info,CORE_CPP_SRCS,[MODIFIED],(Modified by the variable NO_CORE)) + $(call show_config_info,NO_CORE set so core library will not be built,[MANUAL]) endif @@ -568,32 +572,29 @@ LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os # Expand and pick the first port ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) -ifndef SIZE_UTILITY_TYPE - # Command for avr_size: do $(call avr_size,elffile,hexfile) - ifneq (,$(findstring AVR,$(shell $(SIZE) --help))) - SIZE_UTILITY_TYPE = AVR_ENHANCED - else - SIZE_UTILITY_TYPE = BASIC - endif - $(call show_config_info,SIZE_UTILITY_TYPE,[AUTODETECTED]) - -else - $(call show_config_info,SIZE_UTILITY_TYPE,[MANUAL OVERRIDE],Warning - Manually overriding this is not recommended!) -endif - -ifeq ($(SIZE_UTILITY_TYPE),BASIC) - # We have a plain-old binutils version - just give it the hex. - avr_size = $(SIZE) $(2) -endif - -ifeq ($(SIZE_UTILITY_TYPE),AVR_ENHANCED) +# Command for avr_size: do $(call avr_size,elffile,hexfile) +ifneq (,$(findstring AVR,$(shell $(SIZE) --help))) # We have a patched version of binutils that mentions AVR - pass the MCU # and the elf to get nice output. avr_size = $(SIZE) --mcu=$(MCU) --format=avr $(1) + $(call show_config_info,Size utility: AVR-aware for enhanced output,[AUTODETECTED]) +else + # We have a plain-old binutils version - just give it the hex. + avr_size = $(SIZE) $(2) + $(call show_config_info,Size utility: Basic (not AVR-aware),[AUTODETECTED]) endif -ifndef avr_size - $(error "We told you not to override SIZE_UTILITY_TYPE!") + +ifneq (,$(strip $(ARDUINO_LIBS))) + $(info -) + $(call show_config_info,ARDUINO_LIBS =) +endif +ifneq (,$(strip $(USER_LIB_NAMES))) + $(foreach lib,$(USER_LIB_NAMES),$(call show_config_info, $(lib),[USER])) +endif + +ifneq (,$(strip $(SYS_LIB_NAMES))) + $(foreach lib,$(SYS_LIB_NAMES),$(call show_config_info, $(lib),[SYSTEM])) endif # end of config output From c93c8e16a5480205f452e18e022ad7f812ca7206 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 5 Jul 2012 15:02:24 -0500 Subject: [PATCH 35/83] Improved library finding logic. Look first in the user dir. Any not found there are sought in the system (Arduino) dir. If any are not found, error out right away with a useful message. Show all libraries and where they were found (user or system) in the config info. --- arduino-mk/Arduino.mk | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5ab69c8..d50ff22 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -547,8 +547,19 @@ CAT = cat ECHO = echo # General arguments -SYS_LIBS = $(wildcard $(patsubst %,$(ARDUINO_LIB_PATH)/%,$(ARDUINO_LIBS))) USER_LIBS = $(wildcard $(patsubst %,$(USER_LIB_PATH)/%,$(ARDUINO_LIBS))) +USER_LIB_NAMES= $(patsubst $(USER_LIB_PATH)/%,%,$(USER_LIBS)) + +# Let user libraries override system ones. +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)) +endif + SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS)) USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS)) LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS))) From fcdaa4b3bfa3faa5f7ccfb2d3a934471c6968d55 Mon Sep 17 00:00:00 2001 From: Sudar Date: Fri, 6 Jul 2012 12:12:43 +0530 Subject: [PATCH 36/83] Updated Readme and added the list of changes done in this fork --- README.md | 21 ++++++++++++++++++--- arduino-mk/Arduino.mk | 16 +++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6525553..570bad4 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ # A Makefile for Arduino Sketches -This is a very simple Makefile which knows how to build Arduino sketches. +This is a very simple Makefile which knows how to build Arduino sketches. It defines the entire workflows for compiling code, flashing it to Arduino and even communicating through Serial monitor. You don't need to change anything in the Arduino sketches Until March 2012, this was simply posted on my website where you can -still find [what -documentation](http://mjo.tc/atelier/2009/02/arduino-cli.html +still find [what documentation](http://mjo.tc/atelier/2009/02/arduino-cli.html "Documentation") exists. If you're using Debian or Ubuntu, you can find this in the @@ -53,3 +52,19 @@ In order to use Arduino libraries installed in the user's sketchbook folder (the standard location for custom libraries when using the Arduino IDE), you need to set the `ARDUNIO_SKETCHBOOK` variable to point to this directory. By default it is set to `$HOME/sketchbook`. + +## Notes from Sudar + +The following are the list of changes that I have made or merged in this fork. Hopefully it gets into mjoldfield repo one day :) + +### 0.9.1 06.vi.2012 + + - Corrected the ubuntu package names + - Prevent the *file-not-found* error if the depends.mk file is not needed + - Delete the build-cli folder as well while doing make clean + - Added support for compiling .pde files in Arduino 1.0 environment + - Replaced = with += in CPPFLAGS assignment so that we can set CPPFLAGS per sketch if needed + - Changed AVRDUDE_CONF so it can be defined in per-project makefile (https://github.com/WizenedEE) + - Cleaner way to delete the build-cli directory when make clean is invoked + - The package name in Debian and Ubuntu is arduino-mk (https://github.com/maqifrnswa) + diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index cfc25ef..eacca44 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -3,6 +3,9 @@ # Arduino command line tools Makefile # System part (i.e. project independent) # +# Copyright (C) 2012 Sudar , based on +# - M J Oldfield work: https://github.com/mjoldfield/Arduino-Makefile +# # Copyright (C) 2010,2011,2012 Martin Oldfield , based on # work that is copyright Nicholas Zambetti, David A. Mellis & Hernando # Barragan. @@ -77,7 +80,18 @@ # - Moved the reset target to Perl for # clarity and better error handling (ex # Daniele Vergini) -# +# +# 0.9.1 06.vi.2012 Sudar +# - Corrected the ubuntu package names +# - Prevent the *file-not-found* error if the depends.mk file is not needed +# - Delete the build-cli folder as well while doing make clean +# - Added support for compiling .pde files in Arduino 1.0 environment +# - Replaced = with += in CPPFLAGS assignment so that we can set CPPFLAGS per sketch if needed +# - Changed AVRDUDE_CONF so it can be defined in per-project makefile (https://github.com/WizenedEE) +# - Cleaner way to delete the build-cli directory when make clean is invoked +# - The package name in Debian and Ubuntu is arduino-mk (https://github.com/maqifrnswa) +# +# ######################################################################## # # PATHS YOU NEED TO SET UP From 0068267feae8d004ca77e0228287d07b576df532 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Sun, 1 Jul 2012 12:52:36 +0200 Subject: [PATCH 37/83] allow user to choose source files --- .gitignore | 1 + arduino-mk/Arduino.mk | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 7294495..06cff06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.o build-cli +/.project diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index eacca44..ffa91b4 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -91,6 +91,9 @@ # - Cleaner way to delete the build-cli directory when make clean is invoked # - The package name in Debian and Ubuntu is arduino-mk (https://github.com/maqifrnswa) # +# +# 0.9.2 06.vi.2012 Sudar +# - Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech) # ######################################################################## # @@ -435,12 +438,12 @@ OBJDIR = build-cli ######################################################################## # Local sources # -LOCAL_C_SRCS = $(wildcard *.c) -LOCAL_CPP_SRCS = $(wildcard *.cpp) -LOCAL_CC_SRCS = $(wildcard *.cc) -LOCAL_PDE_SRCS = $(wildcard *.pde) -LOCAL_INO_SRCS = $(wildcard *.ino) -LOCAL_AS_SRCS = $(wildcard *.S) +LOCAL_C_SRCS ?= $(wildcard *.c) +LOCAL_CPP_SRCS ?= $(wildcard *.cpp) +LOCAL_CC_SRCS ?= $(wildcard *.cc) +LOCAL_PDE_SRCS ?= $(wildcard *.pde) +LOCAL_INO_SRCS ?= $(wildcard *.ino) +LOCAL_AS_SRCS ?= $(wildcard *.S) LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \ $(LOCAL_CC_SRCS:.cc=.o) $(LOCAL_PDE_SRCS:.pde=.o) \ $(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o) From 8d16c45b8d4c7cc93d45364bef353a3240a2eae4 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Sun, 1 Jul 2012 13:04:39 +0200 Subject: [PATCH 38/83] modified 'make size' behaviour --- arduino-mk/Arduino.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index ffa91b4..9df8080 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -94,6 +94,7 @@ # # 0.9.2 06.vi.2012 Sudar # - Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech) +# - Modified 'make size' behaviour: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) # ######################################################################## # @@ -518,6 +519,7 @@ CFLAGS = -std=gnu99 CXXFLAGS = -fno-exceptions ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os +SIZEFLAGS ?= --mcu=$(MCU) -C # Expand and pick the first port ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) @@ -705,8 +707,8 @@ clean: depends: $(DEPS) cat $(DEPS) > $(DEP_FILE) -size: $(OBJDIR) $(TARGET_HEX) - $(SIZE) $(TARGET_HEX) +size: $(OBJDIR) $(TARGET_ELF) + $(SIZE) $(SIZEFLAGS) $(TARGET_ELF) show_boards: $(PARSE_BOARD_CMD) --boards From 4b74f5433464141b5052df7f177f333da95cb130 Mon Sep 17 00:00:00 2001 From: Sudar Date: Fri, 6 Jul 2012 16:03:32 +0530 Subject: [PATCH 39/83] Updated Readme with latest changes --- README.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 570bad4..5a74a3d 100644 --- a/README.md +++ b/README.md @@ -55,16 +55,20 @@ is set to `$HOME/sketchbook`. ## Notes from Sudar -The following are the list of changes that I have made or merged in this fork. Hopefully it gets into mjoldfield repo one day :) +The following are the list of changes that I have made or merged in this fork. Hopefully it gets into mjoldfield repo and ultimately into Ubuntu package one day :) ### 0.9.1 06.vi.2012 - - Corrected the ubuntu package names - - Prevent the *file-not-found* error if the depends.mk file is not needed - - Delete the build-cli folder as well while doing make clean - - Added support for compiling .pde files in Arduino 1.0 environment - - Replaced = with += in CPPFLAGS assignment so that we can set CPPFLAGS per sketch if needed - - Changed AVRDUDE_CONF so it can be defined in per-project makefile (https://github.com/WizenedEE) - - Cleaner way to delete the build-cli directory when make clean is invoked - - The package name in Debian and Ubuntu is arduino-mk (https://github.com/maqifrnswa) +- Corrected the ubuntu package names +- Prevent the *file-not-found* error if the depends.mk file is not needed +- Delete the build-cli folder as well while doing make clean +- Added support for compiling .pde files in Arduino 1.0 environment +- Replaced = with += in CPPFLAGS assignment so that we can set CPPFLAGS per sketch if needed +- Changed AVRDUDE_CONF so it can be defined in per-project makefile (https://github.com/WizenedEE) +- Cleaner way to delete the build-cli directory when make clean is invoked +- The package name in Debian and Ubuntu is arduino-mk (https://github.com/maqifrnswa) +### 0.9.2 06.vi.2012 + +- Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech) +- Modified 'make size' behaviour: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) From aabe3d2c58c468e20b5d6e6792a6267a04945129 Mon Sep 17 00:00:00 2001 From: Sudar Date: Fri, 13 Jul 2012 22:52:27 +0530 Subject: [PATCH 40/83] Updated Readme --- README.md | 8 ++++++++ arduino-mk/Arduino.mk | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 5a74a3d..e622212 100644 --- a/README.md +++ b/README.md @@ -72,3 +72,11 @@ The following are the list of changes that I have made or merged in this fork. H - Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech) - Modified 'make size' behaviour: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) + + +### 0.9.3 13.vi.2012 + +- Autodetect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/) +- Categorize libs into user and system (https://github.com/rpavlik/) +- Dump size at the end of the build (https://github.com/rpavlik/) +- Lots and lots of improvements (https://github.com/rpavlik/) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 7119cd4..94e6bea 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -96,6 +96,11 @@ # - Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech) # - Modified 'make size' behavior: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) # +# 0.9.3 13.vi.2012 Sudar +# - Autodetect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/) +# - Categorize libs into user and system (https://github.com/rpavlik/) +# - Dump size at the end of the build (https://github.com/rpavlik/) +# - Lots and lots of improvements (https://github.com/rpavlik/) ######################################################################## # # DEPENDENCIES From ad005789a0c690fff7bda56e801c55fc80215c8d Mon Sep 17 00:00:00 2001 From: Sudar Date: Fri, 13 Jul 2012 22:56:48 +0530 Subject: [PATCH 41/83] Changed bytes option for the head shell command, so that it works in Mac as well --- README.md | 1 + arduino-mk/Arduino.mk | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e622212..83f4b7c 100644 --- a/README.md +++ b/README.md @@ -80,3 +80,4 @@ The following are the list of changes that I have made or merged in this fork. H - Categorize libs into user and system (https://github.com/rpavlik/) - Dump size at the end of the build (https://github.com/rpavlik/) - Lots and lots of improvements (https://github.com/rpavlik/) +- Changed bytes option for the head shell command, so that it works in Mac as well diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 94e6bea..06870ec 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -101,6 +101,7 @@ # - Categorize libs into user and system (https://github.com/rpavlik/) # - Dump size at the end of the build (https://github.com/rpavlik/) # - Lots and lots of improvements (https://github.com/rpavlik/) +# - Changed bytes option for the head shell command, so that it works in Mac as well ######################################################################## # # DEPENDENCIES @@ -229,7 +230,7 @@ dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) # For message printing: pad the right side of the first argument with spaces to # the number of bytes indicated by the second argument. -space_pad_to = $(shell echo $(1) " " | head --bytes=$(2)) +space_pad_to = $(shell echo $(1) " " | head -c$(2)) # Call with some text, and a prefix tag if desired (like [AUTODETECTED]), show_config_info = $(info - $(call space_pad_to,$(2),20) $(1)) @@ -272,7 +273,7 @@ ifndef ARDUINO_VERSION # Remove all the decimals, and right-pad with zeros, and finally grab the first 3 bytes. # Works for 1.0 and 1.0.1 - AUTO_ARDUINO_VERSION := $(shell cat $(ARDUINO_DIR)/lib/version.txt | sed -e 's/[.]//g' -e 's/$$/0000/' | head --bytes=3) + AUTO_ARDUINO_VERSION := $(shell cat $(ARDUINO_DIR)/lib/version.txt | sed -e 's/[.]//g' -e 's/$$/0000/' | head -c3) ifdef AUTO_ARDUINO_VERSION ARDUINO_VERSION = $(AUTO_ARDUINO_VERSION) $(call show_config_variable,ARDUINO_VERSION,[AUTODETECTED]) From 94fa378eaa9fc3c0a52107010d8ca75d08dbfb36 Mon Sep 17 00:00:00 2001 From: Sudar Date: Sat, 14 Jul 2012 12:21:54 +0530 Subject: [PATCH 42/83] Fixed line spacing and added doc block which got removed in the earlier commit --- arduino-mk/Arduino.mk | 50 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 06870ec..e5f504d 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -102,6 +102,53 @@ # - Dump size at the end of the build (https://github.com/rpavlik/) # - Lots and lots of improvements (https://github.com/rpavlik/) # - Changed bytes option for the head shell command, so that it works in Mac as well +# +######################################################################## +# +# PATHS YOU NEED TO SET UP +# +# I've reworked the way paths to executables are constructed in this +# version (0.9) of the Makefile. +# +# We need to worry about three different sorts of file: +# +# 1. Things which are included in this distribution e.g. ard-parse-boards +# => ARDMK_DIR +# +# 2. Things which are always in the Arduino distribution e.g. +# boards.txt, libraries, &c. +# => ARDUINO_DIR +# +# 3. Things which might be bundled with the Arduino distribution, but +# might come from the system. Most of the toolchain is like this: +# on Linux it's supplied by the system. +# => AVR_TOOLS_DIR +# +# Having set these three variables, we can work out the rest assuming +# that things are canonically arranged beneath the directories defined +# above. +# +# On the Mac you might want to set: +# +# ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java +# ARDMK_DIR = /usr/local +# +# On Linux, you might prefer: +# +# ARDUINO_DIR = /usr/share/arduino +# ARDMK_DIR = /usr/local +# AVR_TOOLS_DIR = /usr +# +# You can either set these up in the Makefile, or put them in your +# environment e.g. in your .bashrc +# +# If you don't specify these, we can try to guess, but that might not work +# or work the way you want it to. +# +# If you don't install the ard-... binaries to /usr/local/bin, but +# instead copy them to e.g. /home/mjo/arduino.mk/bin then set +# ARDML_DIR = /home/mjo/arduino.mk +# ######################################################################## # # DEPENDENCIES @@ -258,6 +305,7 @@ ifndef ARDUINO_DIR else $(call show_config_variable,ARDUINO_DIR) endif + ######################################################################## # # Default TARGET to cwd (ex Daniele Vergini) @@ -266,8 +314,6 @@ ifndef TARGET endif ######################################################################## - -# # Arduino version number ifndef ARDUINO_VERSION From 4dc74572654ed598caf017af476228eddc8fb7aa Mon Sep 17 00:00:00 2001 From: Sudar Date: Sat, 14 Jul 2012 12:22:34 +0530 Subject: [PATCH 43/83] Don't include dependent makefile when doing make clean --- arduino-mk/Arduino.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index e5f504d..c362c96 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -839,4 +839,6 @@ disasm: all $(OBJDIR)/$(TARGET).lss .PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor # added - in the beginning, so that we don't get an error if the file is not present +ifneq ($(MAKECMDGOALS),clean) -include $(DEP_FILE) +endif From eed8c52ffd4ce94ab44d40a8243e240fcd409d63 Mon Sep 17 00:00:00 2001 From: Sudar Date: Sun, 15 Jul 2012 13:25:45 +0530 Subject: [PATCH 44/83] Automatically read the BAUDRATE from sketch. Works only in linux for now --- README.md | 9 ++++++--- arduino-mk/Arduino.mk | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 83f4b7c..9f44651 100644 --- a/README.md +++ b/README.md @@ -71,13 +71,16 @@ The following are the list of changes that I have made or merged in this fork. H ### 0.9.2 06.vi.2012 - Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech) -- Modified 'make size' behaviour: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) - +- Modified "make size" behavior: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) ### 0.9.3 13.vi.2012 -- Autodetect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/) +- Auto detect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/) - Categorize libs into user and system (https://github.com/rpavlik/) - Dump size at the end of the build (https://github.com/rpavlik/) - Lots and lots of improvements (https://github.com/rpavlik/) - 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 + +## Know Issues +- Because of the way the makefile is structured, the configuration parameters gets printed twice. diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index c362c96..4f312fa 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -102,6 +102,7 @@ # - Dump size at the end of the build (https://github.com/rpavlik/) # - Lots and lots of improvements (https://github.com/rpavlik/) # - 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 # ######################################################################## # @@ -238,7 +239,8 @@ # bindkey ^C kill # # If you want to change the baudrate, just set MONITOR_BAUDRATE. If you -# don't set it, it defaults to 9600 baud. +# don't set it, it tries to read from the sketch. If it couldn't read +# from the sketch, then it defaults to 9600 baud. # ######################################################################## # @@ -421,7 +423,19 @@ endif # for more information (search for 'character special device'). # ifndef MONITOR_BAUDRATE - MONITOR_BAUDRATE = 9600 + #This works only in linux. TODO: Port it to MAC OS also + SPEED = $(shell grep --max-count=1 --regexp="Serial.begin" $$(ls -1 *.ino) | sed -e 's/\/\/.*$$//g' -e 's/(/\t/' -e 's/)/\t/' | awk -F '\t' '{print $$2}' ) + MONITOR_BAUDRATE = $(findstring $(SPEED),300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200) + + ifeq ($(MONITOR_BAUDRATE),) + $(warning The monitor speed wasnt properly set. Set to 9600 by default) + $(shell sleep 1) + MONITOR_BAUDRATE = 9600 + else + $(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch)) + endif +else + $(call show_config_variable,MONITOR_BAUDRATE, [SPECIFIED]) endif ifndef MONITOR_CMD From b74f2efbcec0e2a4c23bea259bb2f5f97eafce71 Mon Sep 17 00:00:00 2001 From: Sudar Date: Sun, 15 Jul 2012 13:25:45 +0530 Subject: [PATCH 45/83] Automatically read the BAUDRATE from sketch. Works only in linux for now --- arduino-mk/Arduino.mk | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 4f312fa..c3e3272 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -428,11 +428,10 @@ ifndef MONITOR_BAUDRATE MONITOR_BAUDRATE = $(findstring $(SPEED),300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200) ifeq ($(MONITOR_BAUDRATE),) - $(warning The monitor speed wasnt properly set. Set to 9600 by default) - $(shell sleep 1) MONITOR_BAUDRATE = 9600 + $(call show_config_variable,MONITOR_BAUDRATE,[ASSUMED]) else - $(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch)) + $(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch)) endif else $(call show_config_variable,MONITOR_BAUDRATE, [SPECIFIED]) From eef73003c939e418a0cb09ca1dcaac9b86c2c5d9 Mon Sep 17 00:00:00 2001 From: jeffkowalski Date: Sat, 18 Aug 2012 18:16:44 -0700 Subject: [PATCH 46/83] added auto-detection of ARDUINO_LIBS referenced in LOCAL_SRCS --- arduino-mk/Arduino.mk | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index c3e3272..9cd973f 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -95,7 +95,7 @@ # 0.9.2 06.vi.2012 Sudar # - Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech) # - Modified 'make size' behavior: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) -# +# # 0.9.3 13.vi.2012 Sudar # - Autodetect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/) # - Categorize libs into user and system (https://github.com/rpavlik/) @@ -529,6 +529,9 @@ LOCAL_CC_SRCS ?= $(wildcard *.cc) LOCAL_PDE_SRCS ?= $(wildcard *.pde) LOCAL_INO_SRCS ?= $(wildcard *.ino) 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_CC_SRCS:.cc=.o) $(LOCAL_PDE_SRCS:.pde=.o) \ $(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o) @@ -556,6 +559,17 @@ else $(call show_config_info,NO_CORE set so core library will not be built,[MANUAL]) 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 @@ -833,7 +847,7 @@ ispload: $(TARGET_HEX) -U lock:w:$(ISP_LOCK_FUSE_POST):m clean: - $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) ${OBJDIR} + $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) ${OBJDIR} depends: $(DEPS) cat $(DEPS) > $(DEP_FILE) From d09a316d7ae990bdfbd3630a289b27f2dfeb5ec3 Mon Sep 17 00:00:00 2001 From: jeffkowalski Date: Sat, 18 Aug 2012 19:24:07 -0700 Subject: [PATCH 47/83] Added autodetection of ARDUINO_SKETCHBOOK, by looking to match IDE's setting in $(HOME)/.arduino/preferences.txt before setting default of $(HOME)/sketchbook. --- arduino-mk/Arduino.mk | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 9cd973f..e08fd62 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -405,7 +405,19 @@ endif # Miscellanea # ifndef ARDUINO_SKETCHBOOK - ARDUINO_SKETCHBOOK = $(HOME)/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 + $(call show_config_variable,ARDUINO_SKETCHBOOK,[DEFAULT]) + endif +else + $(call show_config_variable,ARDUINO_SKETCHBOOK) endif ifndef USER_LIB_PATH From 486be238badbc36fb0859be068f2c8e99b892ffa Mon Sep 17 00:00:00 2001 From: jeffkowalski Date: Sat, 18 Aug 2012 20:30:25 -0700 Subject: [PATCH 48/83] Added autodetection of ARDMK_DIR --- arduino-mk/Arduino.mk | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index e08fd62..113d569 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -384,23 +384,26 @@ endif ######################################################################## # Makefile distribution path # -ifdef ARDMK_DIR - $(call show_config_variable,ARDMK_DIR) +ifndef 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 ARDMK_PATH = $(ARDMK_DIR)/bin $(call show_config_variable,ARDMK_PATH,[COMPUTED],(relative to ARDMK_DIR)) - else $(call show_config_variable,ARDMK_PATH) endif - else - echo $(error "ARDMK_DIR is not defined") - endif + ######################################################################## # Miscellanea # @@ -574,7 +577,6 @@ endif ######################################################################## # Determine ARDUINO_LIBS automatically # - ifndef ARDUINO_LIBS # automatically determine included libraries ARDUINO_LIBS += $(filter $(notdir $(wildcard $(ARDUINO_DIR)/libraries/*)), \ From fc968b919148eb99d1d58a8454a71bf703ca7c78 Mon Sep 17 00:00:00 2001 From: jeffkowalski Date: Sat, 18 Aug 2012 23:00:39 -0700 Subject: [PATCH 49/83] Libraries may also contain subdirectory called "utility", containing header files to be included and source files to be built. Modified SYS_LIBS and USER_LIBS to accomodate those directories if they exist. --- arduino-mk/Arduino.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 113d569..3b0a6f1 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -438,7 +438,7 @@ endif # for more information (search for 'character special device'). # ifndef MONITOR_BAUDRATE - #This works only in linux. TODO: Port it to MAC OS also + #This works only in linux. TODO: Port it to MAC OS also SPEED = $(shell grep --max-count=1 --regexp="Serial.begin" $$(ls -1 *.ino) | sed -e 's/\/\/.*$$//g' -e 's/(/\t/' -e 's/)/\t/' | awk -F '\t' '{print $$2}' ) MONITOR_BAUDRATE = $(findstring $(SPEED),300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200) @@ -625,6 +625,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)) 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))) From ee0cb6e764277d0e110efb3ffd94455dcea47eb4 Mon Sep 17 00:00:00 2001 From: jeffkowalski Date: Sat, 18 Aug 2012 23:36:40 -0700 Subject: [PATCH 50/83] detabbed changelog, and appended my contributions --- arduino-mk/Arduino.mk | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 3b0a6f1..9a85222 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -82,27 +82,36 @@ # Daniele Vergini) # # 0.9.1 06.vi.2012 Sudar -# - Corrected the ubuntu package names -# - Prevent the *file-not-found* error if the depends.mk file is not needed -# - Delete the build-cli folder as well while doing make clean -# - Added support for compiling .pde files in Arduino 1.0 environment -# - Replaced = with += in CPPFLAGS assignment so that we can set CPPFLAGS per sketch if needed -# - Changed AVRDUDE_CONF so it can be defined in per-project makefile (https://github.com/WizenedEE) -# - Cleaner way to delete the build-cli directory when make clean is invoked -# - The package name in Debian and Ubuntu is arduino-mk (https://github.com/maqifrnswa) +# - Corrected the ubuntu package names +# - Prevent the *file-not-found* error if the depends.mk file is not needed +# - Delete the build-cli folder as well while doing make clean +# - Added support for compiling .pde files in Arduino 1.0 environment +# - Replaced = with += in CPPFLAGS assignment so that we can set CPPFLAGS per sketch if needed +# - Changed AVRDUDE_CONF so it can be defined in per-project makefile (https://github.com/WizenedEE) +# - Cleaner way to delete the build-cli directory when make clean is invoked +# - The package name in Debian and Ubuntu is arduino-mk (https://github.com/maqifrnswa) # # # 0.9.2 06.vi.2012 Sudar -# - Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech) -# - Modified 'make size' behavior: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) +# - Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech) +# - Modified 'make size' behavior: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) # # 0.9.3 13.vi.2012 Sudar -# - Autodetect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/) -# - Categorize libs into user and system (https://github.com/rpavlik/) -# - Dump size at the end of the build (https://github.com/rpavlik/) -# - Lots and lots of improvements (https://github.com/rpavlik/) -# - 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 +# - Autodetect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/) +# - Categorize libs into user and system (https://github.com/rpavlik/) +# - Dump size at the end of the build (https://github.com/rpavlik/) +# - Lots and lots of improvements (https://github.com/rpavlik/) +# - 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 +# +# 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 # ######################################################################## # @@ -239,7 +248,7 @@ # bindkey ^C kill # # If you want to change the baudrate, just set MONITOR_BAUDRATE. If you -# don't set it, it tries to read from the sketch. If it couldn't read +# don't set it, it tries to read from the sketch. If it couldn't read # from the sketch, then it defaults to 9600 baud. # ######################################################################## From d1f49b6ea4ff9830ef75893f4a26e6c69b39c83c Mon Sep 17 00:00:00 2001 From: Sudar Date: Mon, 20 Aug 2012 13:59:58 +0530 Subject: [PATCH 51/83] Updated Readme with jeffkowalski --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 9f44651..eda11f3 100644 --- a/README.md +++ b/README.md @@ -82,5 +82,11 @@ The following are the list of changes that I have made or merged in this fork. H - 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 +### 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 + ## Know Issues - Because of the way the makefile is structured, the configuration parameters gets printed twice. From 06bc8d6aa388b1f24789c5f29e312eb199e74619 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 23 Aug 2012 12:39:31 -0500 Subject: [PATCH 52/83] Allow passing extra flags --- arduino-mk/Arduino.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index d50ff22..dc2ee0f 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -575,10 +575,10 @@ CPPFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \ -I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ $(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -w -Wall \ -ffunction-sections -fdata-sections -CFLAGS = -std=gnu99 -CXXFLAGS = -fno-exceptions +CFLAGS = -std=gnu99 $(EXTRA_FLAGS) $(EXTRA_CFLAGS) +CXXFLAGS = -fno-exceptions $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS) ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp -LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os +LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS) # Expand and pick the first port ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) From aaed1fc6faefb93fb810a5f28491c764ffb032e2 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 23 Aug 2012 12:39:42 -0500 Subject: [PATCH 53/83] Make listing files more useful --- arduino-mk/Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index dc2ee0f..5dad154 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -705,7 +705,7 @@ $(OBJDIR)/%.eep: $(OBJDIR)/%.elf --change-section-lma .eeprom=0 -O ihex $< $@ $(OBJDIR)/%.lss: $(OBJDIR)/%.elf - $(OBJDUMP) -h -S $< > $@ + $(OBJDUMP) -h --source --demangle --wide $< > $@ $(OBJDIR)/%.sym: $(OBJDIR)/%.elf $(NM) -n $< > $@ From d8530a16e85226756522e38b5d46c805233b0969 Mon Sep 17 00:00:00 2001 From: Adam Dunlap Date: Mon, 27 Aug 2012 13:08:48 -0700 Subject: [PATCH 54/83] Making other *FLAGS += rather than = --- arduino-mk/Arduino.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 9a85222..8fc8e5c 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -652,10 +652,10 @@ CPPFLAGS += -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \ -I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ $(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -w -Wall \ -ffunction-sections -fdata-sections -CFLAGS = -std=gnu99 -CXXFLAGS = -fno-exceptions -ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp -LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os +CFLAGS += -std=gnu99 +CXXFLAGS += -fno-exceptions +ASFLAGS += -mmcu=$(MCU) -I. -x assembler-with-cpp +LDFLAGS += -mmcu=$(MCU) -Wl,--gc-sections -Os SIZEFLAGS ?= --mcu=$(MCU) -C # Expand and pick the first port From 048762156bcefa45b099be267818988a0a25f86f Mon Sep 17 00:00:00 2001 From: Sudar Date: Mon, 10 Sep 2012 22:17:01 +0530 Subject: [PATCH 55/83] Fixed a typo in README. Issue reported at upstream (https://github.com/mjoldfield/Arduino-Makefile/issues/21) --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index eda11f3..233f6dc 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ On other systems In order to use Arduino libraries installed in the user's sketchbook folder (the standard location for custom libraries when using the Arduino IDE), you need to -set the `ARDUNIO_SKETCHBOOK` variable to point to this directory. By default it +set the `ARDUINO_SKETCHBOOK` variable to point to this directory. By default it is set to `$HOME/sketchbook`. ## Notes from Sudar @@ -88,5 +88,10 @@ The following are the list of changes that I have made or merged in this fork. H - Autodetect ARDMK_DIR based on location of this file - Added support for utility directory within SYS and USER libraries +### 0.9.3.2 10.ix.2012 Sudar +- Fixed a typo in README. Issue reported at upstream (https://github.com/mjoldfield/Arduino-Makefile/issues/21) + ## Know Issues - Because of the way the makefile is structured, the configuration parameters gets printed twice. +- Doesn't work with Leonardo yet. +- More todo's at https://github.com/sudar/Arduino-Makefile/issues/ From 87060fa5c2d1f55375f643ac98f7c7818a8615ce Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 20 Sep 2012 11:28:42 -0500 Subject: [PATCH 56/83] Add knowledge of device-specific assembler --- arduino-mk/Arduino.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5dad154..a71def9 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -536,6 +536,7 @@ DEP_FILE = $(OBJDIR)/depends.mk # Names of executables CC = $(AVR_TOOLS_PATH)/avr-gcc CXX = $(AVR_TOOLS_PATH)/avr-g++ +AS = $(AVR_TOOLS_PATH)/avr-as OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump AR = $(AVR_TOOLS_PATH)/avr-ar From 24c2366f26d68f242353a8d5471320fe56adde47 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 20 Sep 2012 11:29:15 -0500 Subject: [PATCH 57/83] Use variables instead of hardcoded commands --- arduino-mk/Arduino.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index a71def9..0fb384b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -697,8 +697,8 @@ $(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp # various object conversions $(OBJDIR)/%.hex: $(OBJDIR)/%.elf $(OBJCOPY) -O ihex -R .eeprom $< $@ - @echo - @echo + @$(ECHO) + @$(ECHO) $(call avr_size,$<,$@) $(OBJDIR)/%.eep: $(OBJDIR)/%.elf @@ -787,7 +787,7 @@ clean: $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEP_FILE) $(DEPS) $(USER_LIB_OBJS) depends: $(DEPS) - cat $(DEPS) > $(DEP_FILE) + $(CAT) $(DEPS) > $(DEP_FILE) size: $(OBJDIR) $(TARGET_HEX) $(call avr_size,$(TARGET_ELF),$(TARGET_HEX)) From 05a31db4817b57101d7a2a29fed099ed63e0a4c4 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 20 Sep 2012 11:29:26 -0500 Subject: [PATCH 58/83] Make disasm more helpful --- arduino-mk/Arduino.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 0fb384b..5ed7206 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -798,7 +798,8 @@ show_boards: monitor: $(MONITOR_CMD) $(ARD_PORT) $(MONITOR_BAUDRATE) -disasm: all $(OBJDIR)/$(TARGET).lss +disasm: $(OBJDIR)/$(TARGET).lss + @$(ECHO) The compiled ELF file has been disassembled to $(OBJDIR)/$(TARGET).lss .PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor From 6041f6201da0cacedaec55504cf31365120dbe30 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 20 Sep 2012 11:29:36 -0500 Subject: [PATCH 59/83] Change .sym output --- arduino-mk/Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5ed7206..e564369 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -709,7 +709,7 @@ $(OBJDIR)/%.lss: $(OBJDIR)/%.elf $(OBJDUMP) -h --source --demangle --wide $< > $@ $(OBJDIR)/%.sym: $(OBJDIR)/%.elf - $(NM) -n $< > $@ + $(NM) --size-sort --demangle --reverse-sort --line-numbers $< > $@ ######################################################################## # From 84648978fbdcd569e12ac43579d452941b78a3e1 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 20 Sep 2012 11:30:46 -0500 Subject: [PATCH 60/83] Provide symbol_sizes and generated_assembly targets. Also update existing auxiliary targets with help, and make the .PHONY list complete and in order. --- arduino-mk/Arduino.mk | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index e564369..5179f9d 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -687,6 +687,13 @@ $(OBJDIR)/%.o: $(OBJDIR)/%.cpp $(OBJDIR)/%.d: $(OBJDIR)/%.cpp $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) +# generated assembly +$(OBJDIR)/%.s: $(OBJDIR)/%.cpp + $(CXX) -S -fverbose-asm $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + +#$(OBJDIR)/%.lst: $(OBJDIR)/%.s +# $(AS) -mmcu=$(MCU) -alhnd $< > $@ + # core files $(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ @@ -801,6 +808,12 @@ monitor: disasm: $(OBJDIR)/$(TARGET).lss @$(ECHO) The compiled ELF file has been disassembled to $(OBJDIR)/$(TARGET).lss -.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor +symbol_sizes: $(OBJDIR)/$(TARGET).sym + @$(ECHO) A symbol listing sorted by their size have been dumped to $(OBJDIR)/$(TARGET).sym + +generated_assembly: $(OBJDIR)/$(TARGET).s + @$(ECHO) Compiler-generated assembly for the main input source has been dumped to $(OBJDIR)/$(TARGET).s + +.PHONY: all upload raw_upload reset reset_stty ispload clean depends size show_boards monitor disasm symbol_sizes generated_assembly include $(DEP_FILE) From 184b482a98a5047726250507baae5d16d81bb804 Mon Sep 17 00:00:00 2001 From: Alex Szczuczko Date: Tue, 25 Sep 2012 21:34:26 -0400 Subject: [PATCH 61/83] Update boards_txt path in bin/ard-parse-boards to include environment variable ARDUINO_DIR This corrects the behaviour of ard-parse-boards --boards , which would fail if the path to boards.txt on the system didn't match the value which was hardcoded. --- bin/ard-parse-boards | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ard-parse-boards b/bin/ard-parse-boards index e2de71b..de046c0 100755 --- a/bin/ard-parse-boards +++ b/bin/ard-parse-boards @@ -9,7 +9,7 @@ use YAML; my %Opt = ( - boards_txt => '/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt', + boards_txt => "$ENV{'ARDUINO_DIR'}/hardware/arduino/boards.txt", ); GetOptions(\%Opt, From adbd6532f9877b646d41f039cc1fd4cdd787d54b Mon Sep 17 00:00:00 2001 From: Andreas Lohr Date: Sun, 7 Oct 2012 10:28:10 +0200 Subject: [PATCH 62/83] set USB_VID and USB_PID only for leonardo boards --- arduino-mk/Arduino.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 09819ac..450e482 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -401,6 +401,7 @@ ifndef F_CPU F_CPU = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.f_cpu) endif +ifeq ($(VARIANT),leonardo) # USB IDs for the Leonardo ifndef USB_VID USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid) @@ -409,6 +410,7 @@ endif ifndef USB_PID USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid) endif +endif # normal programming info ifndef AVRDUDE_ARD_PROGRAMMER From 77f8ee0d77b4029300e0fda877db8e091f25c5d0 Mon Sep 17 00:00:00 2001 From: Andreas Lohr Date: Sun, 7 Oct 2012 10:33:22 +0200 Subject: [PATCH 63/83] use perl from /opt/local --- bin/ard-parse-boards | 2 +- bin/ard-reset-arduino | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ard-parse-boards b/bin/ard-parse-boards index e2de71b..a18d5b7 100755 --- a/bin/ard-parse-boards +++ b/bin/ard-parse-boards @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#! /opt/local/bin/perl5 use strict; use warnings; diff --git a/bin/ard-reset-arduino b/bin/ard-reset-arduino index 22c7109..17548d6 100755 --- a/bin/ard-reset-arduino +++ b/bin/ard-reset-arduino @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#! /opt/local/bin/perl5 use strict; use warnings; From 4241eccacc6a64cff1638a393a96a8a34acda9d3 Mon Sep 17 00:00:00 2001 From: Andreas Lohr Date: Sun, 7 Oct 2012 11:54:14 +0200 Subject: [PATCH 64/83] added MacPorts --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 0d949ae..9351277 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,13 @@ On Fedora: yum install perl-Device-SerialPort yum install perl-YAML +On Mac using MacPorts: + + sudo port install p5-device-serialport + sudo port install p5-YAML + + and use /opt/local/bin/perl5 instead of /usr/bin/perl + On other systems: cpanm Device::SerialPort From 86b7b034dc241ca3469d199e67ad3b278ef80114 Mon Sep 17 00:00:00 2001 From: Alistair MacLeod Date: Sun, 21 Oct 2012 21:05:56 +0100 Subject: [PATCH 65/83] Changed shebang to use /usr/bin/env --- bin/ard-parse-boards | 2 +- bin/ard-reset-arduino | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ard-parse-boards b/bin/ard-parse-boards index e2de71b..9f690e2 100755 --- a/bin/ard-parse-boards +++ b/bin/ard-parse-boards @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#! /usr/bin/env perl use strict; use warnings; diff --git a/bin/ard-reset-arduino b/bin/ard-reset-arduino index 22c7109..085e442 100755 --- a/bin/ard-reset-arduino +++ b/bin/ard-reset-arduino @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#! /usr/bin/env perl use strict; use warnings; From bc8caf8358dfb1c87bcbdef107fe5a7d74b37c4a Mon Sep 17 00:00:00 2001 From: Jan Gosmann Date: Thu, 1 Nov 2012 12:01:54 +0100 Subject: [PATCH 66/83] Fixing problem of hanging upload. --- arduino-mk/Arduino.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 8fc8e5c..84d6573 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -848,6 +848,8 @@ raw_upload: $(TARGET_HEX) reset: $(RESET_CMD) $(ARD_PORT) + sleep 1 # If avrdude is called to early after the reset, the upload may + # hang. # stty on MacOS likes -F, but on Debian it likes -f redirecting # stdin/out appears to work but generates a spurious error on MacOS at From a814a9c276bd6586f50e366f8df32c2c93ee7651 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 1 Nov 2012 10:33:46 -0500 Subject: [PATCH 67/83] Be able to silence configuration output --- arduino-mk/Arduino.mk | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 5179f9d..b90f81b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -124,6 +124,8 @@ # instead copy them to e.g. /home/mjo/arduino.mk/bin then set # ARDML_DIR = /home/mjo/arduino.mk # +# If you'd rather not see the configuration output, define ARDUINO_QUIET. +# ######################################################################## # # DEPENDENCIES @@ -254,19 +256,25 @@ dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) # the number of bytes indicated by the second argument. space_pad_to = $(shell echo $(1) " " | head --bytes=$(2)) +ifndef ARDUINO_QUIET + arduino_output = $(info $(1)) +else + arduino_output = +endif + # Call with some text, and a prefix tag if desired (like [AUTODETECTED]), -show_config_info = $(info - $(call space_pad_to,$(2),20) $(1)) +show_config_info = $(call arduino_output,- $(call space_pad_to,$(2),20) $(1)) # Call with the name of the variable, a prefix tag if desired (like [AUTODETECTED]), # and an explanation if desired (like (found in $$PATH) show_config_variable = $(call show_config_info,$(1) = $($(1)) $(3),$(2)) # Just a nice simple visual separator -show_separator = $(info -------------------------) +show_separator = $(call arduino_output,-------------------------) $(call show_separator) -$(info Arduino.mk Configuration:) +$(call arduino_output,Arduino.mk Configuration:) ifndef ARDUINO_DIR AUTO_ARDUINO_DIR := $(firstword \ @@ -598,7 +606,7 @@ endif ifneq (,$(strip $(ARDUINO_LIBS))) - $(info -) + $(call arduino_output,-) $(call show_config_info,ARDUINO_LIBS =) endif ifneq (,$(strip $(USER_LIB_NAMES))) From ee98d0c89b66adb5c54c0867d14d6c72261ef9a9 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 1 Nov 2012 10:34:09 -0500 Subject: [PATCH 68/83] Make everybody depend on the makefile, in case cflags are changed, etc. --- arduino-mk/Arduino.mk | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index b90f81b..a12c5d2 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -649,81 +649,82 @@ $(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c # normal local sources # .o rules are for objects, .d for dependency tracking # there seems to be an awful lot of duplication here!!! -$(OBJDIR)/%.o: %.c +COMMON_DEPS := Makefile +$(OBJDIR)/%.o: %.c $(COMMON_DEPS) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ -$(OBJDIR)/%.o: %.cc +$(OBJDIR)/%.o: %.cc $(COMMON_DEPS) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -$(OBJDIR)/%.o: %.cpp +$(OBJDIR)/%.o: %.cpp $(COMMON_DEPS) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -$(OBJDIR)/%.o: %.S +$(OBJDIR)/%.o: %.S $(COMMON_DEPS) $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ -$(OBJDIR)/%.o: %.s +$(OBJDIR)/%.o: %.s $(COMMON_DEPS) $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ -$(OBJDIR)/%.d: %.c +$(OBJDIR)/%.d: %.c $(COMMON_DEPS) $(CC) -MM $(CPPFLAGS) $(CFLAGS) $< -MF $@ -MT $(@:.d=.o) -$(OBJDIR)/%.d: %.cc +$(OBJDIR)/%.d: %.cc $(COMMON_DEPS) $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) -$(OBJDIR)/%.d: %.cpp +$(OBJDIR)/%.d: %.cpp $(COMMON_DEPS) $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) -$(OBJDIR)/%.d: %.S +$(OBJDIR)/%.d: %.S $(COMMON_DEPS) $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) -$(OBJDIR)/%.d: %.s +$(OBJDIR)/%.d: %.s $(COMMON_DEPS) $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) # the pde -> cpp -> o file -$(OBJDIR)/%.cpp: %.pde +$(OBJDIR)/%.cpp: %.pde $(COMMON_DEPS) $(ECHO) '#include "WProgram.h"' > $@ $(CAT) $< >> $@ # the ino -> cpp -> o file -$(OBJDIR)/%.cpp: %.ino +$(OBJDIR)/%.cpp: %.ino $(COMMON_DEPS) $(ECHO) '#include ' > $@ $(CAT) $< >> $@ -$(OBJDIR)/%.o: $(OBJDIR)/%.cpp +$(OBJDIR)/%.o: $(OBJDIR)/%.cpp $(COMMON_DEPS) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -$(OBJDIR)/%.d: $(OBJDIR)/%.cpp +$(OBJDIR)/%.d: $(OBJDIR)/%.cpp $(COMMON_DEPS) $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) # generated assembly -$(OBJDIR)/%.s: $(OBJDIR)/%.cpp +$(OBJDIR)/%.s: $(OBJDIR)/%.cpp $(COMMON_DEPS) $(CXX) -S -fverbose-asm $(CPPFLAGS) $(CXXFLAGS) $< -o $@ #$(OBJDIR)/%.lst: $(OBJDIR)/%.s # $(AS) -mmcu=$(MCU) -alhnd $< > $@ # core files -$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c +$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c $(COMMON_DEPS) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ -$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp +$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp $(COMMON_DEPS) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # various object conversions -$(OBJDIR)/%.hex: $(OBJDIR)/%.elf +$(OBJDIR)/%.hex: $(OBJDIR)/%.elf $(COMMON_DEPS) $(OBJCOPY) -O ihex -R .eeprom $< $@ @$(ECHO) @$(ECHO) $(call avr_size,$<,$@) -$(OBJDIR)/%.eep: $(OBJDIR)/%.elf +$(OBJDIR)/%.eep: $(OBJDIR)/%.elf $(COMMON_DEPS) -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ --change-section-lma .eeprom=0 -O ihex $< $@ -$(OBJDIR)/%.lss: $(OBJDIR)/%.elf +$(OBJDIR)/%.lss: $(OBJDIR)/%.elf $(COMMON_DEPS) $(OBJDUMP) -h --source --demangle --wide $< > $@ -$(OBJDIR)/%.sym: $(OBJDIR)/%.elf +$(OBJDIR)/%.sym: $(OBJDIR)/%.elf $(COMMON_DEPS) $(NM) --size-sort --demangle --reverse-sort --line-numbers $< > $@ ######################################################################## From edd514d65cc70b140e2882900e461ce87294bdd8 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 1 Nov 2012 10:57:11 -0500 Subject: [PATCH 69/83] Make the makefile error if the arduino port is not present. --- arduino-mk/Arduino.mk | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index a12c5d2..84c451b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -589,8 +589,8 @@ CXXFLAGS = -fno-exceptions $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS) ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp LDFLAGS = -mmcu=$(MCU) -Wl,--gc-sections -Os $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS) -# Expand and pick the first port -ARD_PORT = $(firstword $(wildcard $(ARDUINO_PORT))) +# Returns the Arduino port (first wildcard expansion) if it exists, otherwise it errors. +get_arduino_port = $(if $(wildcard $(ARDUINO_PORT)),$(firstword $(wildcard $(ARDUINO_PORT))),$(error Arduino port $(ARDUINO_PORT) not found!)) # Command for avr_size: do $(call avr_size,elffile,hexfile) ifneq (,$(findstring AVR,$(shell $(SIZE) --help))) @@ -740,7 +740,7 @@ ifdef AVRDUDE_CONF AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF) endif -AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(ARD_PORT) +AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(call get_arduino_port) ifndef ISP_PROG ISP_PROG = -c stk500v2 @@ -775,7 +775,7 @@ raw_upload: $(TARGET_HEX) -U flash:w:$(TARGET_HEX):i reset: - $(RESET_CMD) $(ARD_PORT) + $(RESET_CMD) $(call get_arduino_port) # stty on MacOS likes -F, but on Debian it likes -f redirecting # stdin/out appears to work but generates a spurious error on MacOS at @@ -784,9 +784,9 @@ reset_stty: for STTYF in 'stty -F' 'stty --file' 'stty -f' 'stty <' ; \ do $$STTYF /dev/tty >/dev/null 2>/dev/null && break ; \ done ;\ - $$STTYF $(ARD_PORT) hupcl ;\ + $$STTYF $(call get_arduino_port) hupcl ;\ (sleep 0.1 || sleep 1) ;\ - $$STTYF $(ARD_PORT) -hupcl + $$STTYF $(call get_arduino_port) -hupcl ispload: $(TARGET_HEX) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \ @@ -812,7 +812,7 @@ show_boards: $(PARSE_BOARD_CMD) --boards monitor: - $(MONITOR_CMD) $(ARD_PORT) $(MONITOR_BAUDRATE) + $(MONITOR_CMD) $(call get_arduino_port) $(MONITOR_BAUDRATE) disasm: $(OBJDIR)/$(TARGET).lss @$(ECHO) The compiled ELF file has been disassembled to $(OBJDIR)/$(TARGET).lss From 90e3c9ad0bb75d87e19d9eb017024aed55b544d1 Mon Sep 17 00:00:00 2001 From: Jan Gosmann Date: Fri, 2 Nov 2012 12:51:53 +0100 Subject: [PATCH 70/83] Fix upload in case of parallelized make. --- arduino-mk/Arduino.mk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 84d6573..b47a025 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -840,16 +840,14 @@ $(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) $(DEP_FILE): $(OBJDIR) $(DEPS) cat $(DEPS) > $(DEP_FILE) -upload: reset raw_upload +upload: raw_upload -raw_upload: $(TARGET_HEX) +raw_upload: reset $(TARGET_HEX) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ -U flash:w:$(TARGET_HEX):i reset: $(RESET_CMD) $(ARD_PORT) - sleep 1 # If avrdude is called to early after the reset, the upload may - # hang. # stty on MacOS likes -F, but on Debian it likes -f redirecting # stdin/out appears to work but generates a spurious error on MacOS at From 1e078625cbb01370f83e314ce4c5b1d068b121e7 Mon Sep 17 00:00:00 2001 From: gabriel Date: Tue, 6 Nov 2012 14:33:10 +0100 Subject: [PATCH 71/83] removing -w from CPPFLAGS (warnings can be usefull) --- arduino-mk/Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 8fc8e5c..c85a38f 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -650,7 +650,7 @@ USER_LIB_OBJS = $(patsubst $(USER_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(USER_LIB_ # Using += instead of =, so that CPPFLAGS can be set per sketch level CPPFLAGS += -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \ -I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ - $(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -w -Wall \ + $(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -Wall \ -ffunction-sections -fdata-sections CFLAGS += -std=gnu99 CXXFLAGS += -fno-exceptions From b5448a64dc20f996a753c2cd3332e30be8df3ab8 Mon Sep 17 00:00:00 2001 From: Fabio Pugliese Ornellas Date: Mon, 12 Nov 2012 21:34:51 -0200 Subject: [PATCH 72/83] Added sketch size verification. --- arduino-mk/Arduino.mk | 15 +++++++++++---- bin/ard-verify-size | 9 +++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100755 bin/ard-verify-size diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 09819ac..56204f9 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -445,6 +445,10 @@ ifndef OBJDIR OBJDIR = build-$(BOARD_TAG) endif +ifndef HEX_MAXIMUM_SIZE +HEX_MAXIMUM_SIZE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.maximum_size) +endif + ######################################################################## # Local sources # @@ -655,7 +659,7 @@ AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG) # Explicit targets start here # -all: $(OBJDIR) $(TARGET_HEX) +all: $(OBJDIR) $(TARGET_HEX) verify_size $(OBJDIR): mkdir $(OBJDIR) @@ -671,7 +675,7 @@ $(DEP_FILE): $(OBJDIR) $(DEPS) upload: reset raw_upload -raw_upload: $(TARGET_HEX) +raw_upload: $(TARGET_HEX) verify_size $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ -U flash:w:$(TARGET_HEX):i @@ -689,7 +693,7 @@ reset_stty: (sleep 0.1 || sleep 1) ;\ $$STTYF $(ARD_PORT) -hupcl -ispload: $(TARGET_HEX) +ispload: $(TARGET_HEX) verify_size $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \ -U lock:w:$(ISP_LOCK_FUSE_PRE):m \ -U hfuse:w:$(ISP_HIGH_FUSE):m \ @@ -715,6 +719,9 @@ show_boards: monitor: $(MONITOR_CMD) $(ARD_PORT) $(MONITOR_BAUDRATE) -.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor +verify_size: $(TARGET_HEX) + $(ARDMK_PATH)/ard-verify-size $(TARGET_HEX) $(HEX_MAXIMUM_SIZE) + +.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor verify_size include $(DEP_FILE) diff --git a/bin/ard-verify-size b/bin/ard-verify-size new file mode 100755 index 0000000..2a7fa28 --- /dev/null +++ b/bin/ard-verify-size @@ -0,0 +1,9 @@ +#!/bin/bash +TARGET_HEX="$1" +MAX_SIZE="$2" +HEX_SIZE="$(cut -c12- < $TARGET_HEX | tr -d \\n | tr -d \\r | wc -c | awk '{print $1/2}')" +if [ $HEX_SIZE -gt $MAX_SIZE ] +then + echo "Sketch size is ${HEX_SIZE} bytes and maximum allowed is ${MAX_SIZE} bytes; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it." 1>&2 + exit 1 +fi From bfd9dac2167043b4e8b24324119bf89fd90c75bf Mon Sep 17 00:00:00 2001 From: Fabio Pugliese Ornellas Date: Mon, 12 Nov 2012 22:13:03 -0200 Subject: [PATCH 73/83] Added dummy file to verify_size to avoid always being run. --- arduino-mk/Arduino.mk | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 56204f9..6cbf133 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -719,9 +719,12 @@ show_boards: monitor: $(MONITOR_CMD) $(ARD_PORT) $(MONITOR_BAUDRATE) -verify_size: $(TARGET_HEX) +$(TARGET_HEX).sizeok: $(TARGET_HEX) $(ARDMK_PATH)/ard-verify-size $(TARGET_HEX) $(HEX_MAXIMUM_SIZE) + touch $@ -.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitor verify_size +verify_size: $(TARGET_HEX) $(TARGET_HEX).sizeok + +.PHONY: all clean depends upload raw_upload reset reset_stty size show_boards monitorx verify_size include $(DEP_FILE) From 168292425f856a213ffb477fd20d79b16bf9358c Mon Sep 17 00:00:00 2001 From: gabriel Date: Sat, 17 Nov 2012 22:18:56 +0100 Subject: [PATCH 74/83] add eeprom upload support --- arduino-mk/Arduino.mk | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index c85a38f..b79ff3f 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -113,6 +113,10 @@ # - Added support for utility directory # within SYS and USER libraries # +# ?.?.?.? 09.xi.2012 gaftech +# - Add EEPROM upload support: eeprom and raw_eeprom targets +# and ISP_EEPROM option. +# ######################################################################## # # PATHS YOU NEED TO SET UP @@ -601,6 +605,7 @@ endif # The name of the main targets TARGET_HEX = $(OBJDIR)/$(TARGET).hex TARGET_ELF = $(OBJDIR)/$(TARGET).elf +TARGET_EEP = $(OBJDIR)/$(TARGET).eep TARGETS = $(OBJDIR)/$(TARGET).* CORE_LIB = $(OBJDIR)/libcore.a @@ -818,15 +823,28 @@ ifndef ISP_PROG ISP_PROG = -c stk500v2 endif +# usb seems to be a reasonable default, at least on linux +ifndef ISP_PORT + ISP_PORT = usb +endif + AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG) +ifndef ISP_EEPROM + ISP_EEPROM = 0 +endif + +AVRDUDE_MEM_OPTS = -U flash:w:$(TARGET_HEX):i +ifneq ($(ISP_EEPROM), 0) + AVRDUDE_MEM_OPTS += -U eeprom:w:$(TARGET_EEP):i +endif ######################################################################## # # Explicit targets start here # -all: $(OBJDIR) $(TARGET_HEX) +all: $(OBJDIR) $(TARGET_EEP) $(TARGET_HEX) $(OBJDIR): mkdir $(OBJDIR) @@ -846,6 +864,11 @@ raw_upload: $(TARGET_HEX) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ -U flash:w:$(TARGET_HEX):i +eeprom: reset raw_eeprom + +raw_eeprom: $(TARGET_EEP) $(TARGET_HEX) + $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) $(AVRDUDE_MEM_OPTS) + reset: $(RESET_CMD) $(ARD_PORT) @@ -860,14 +883,14 @@ reset_stty: (sleep 0.1 || sleep 1) ;\ $$STTYF $(ARD_PORT) -hupcl -ispload: $(TARGET_HEX) +ispload: $(TARGET_EEP) $(TARGET_HEX) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e \ -U lock:w:$(ISP_LOCK_FUSE_PRE):m \ -U hfuse:w:$(ISP_HIGH_FUSE):m \ -U lfuse:w:$(ISP_LOW_FUSE):m \ -U efuse:w:$(ISP_EXT_FUSE):m $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -D \ - -U flash:w:$(TARGET_HEX):i + $(AVRDUDE_MEM_OPTS) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) \ -U lock:w:$(ISP_LOCK_FUSE_POST):m From 86165af72656fbf79b669fdafee4766773ddde04 Mon Sep 17 00:00:00 2001 From: gabriel Date: Fri, 14 Dec 2012 23:10:03 +0100 Subject: [PATCH 75/83] make build dir (OBJDIR) changeable --- arduino-mk/Arduino.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index b79ff3f..befe364 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -546,7 +546,7 @@ ifndef ISP_EXT_FUSE endif # Everything gets built in here -OBJDIR = build-cli +OBJDIR ?= build-cli ######################################################################## # Local sources From 9ebae306d0604273112f19e1311b9923c6a4af18 Mon Sep 17 00:00:00 2001 From: Adam Dunlap Date: Fri, 17 Aug 2012 11:50:05 -0700 Subject: [PATCH 76/83] Show original line number for error messages --- README.md | 1 + arduino-mk/Arduino.mk | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 44a8d9f..593369c 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ The following are the list of changes that I have made or merged in this fork. H ### 0.10.2 15.xii.2012 Sudar - Added sketch size verification. (https://github.com/fornellas) +- Show original line number for error messages (https://github.com/WizenedEE) ## Know Issues - Because of the way the makefile is structured, the configuration parameters gets printed twice. diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 57680b5..605cbc1 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -143,6 +143,7 @@ # # 0.10.2 15.xii.2012 Sudar # - Added sketch size verification. (https://github.com/fornellas) +# - Show original line number for error messages (https://github.com/WizenedEE) # ######################################################################## # @@ -812,12 +813,12 @@ $(OBJDIR)/%.d: %.s $(COMMON_DEPS) # We should check for Arduino version, if the file is .pde because a .pde file might be used in Arduino 1.0 # the pde -> cpp -> o file $(OBJDIR)/%.cpp: %.pde $(COMMON_DEPS) - $(ECHO) '#if ARDUINO >= 100\n #include "Arduino.h"\n#else\n #include "WProgram.h"\n#endif' > $@ + $(ECHO) '#if ARDUINO >= 100\n #include "Arduino.h"\n#else\n #include "WProgram.h"\n#endif\n#line 1' > $@ $(CAT) $< >> $@ # the ino -> cpp -> o file $(OBJDIR)/%.cpp: %.ino $(COMMON_DEPS) - $(ECHO) '#include ' > $@ + $(ECHO) '#include \n#line 1' > $@ $(CAT) $< >> $@ $(OBJDIR)/%.o: $(OBJDIR)/%.cpp $(COMMON_DEPS) From ec7f239bce5a7df695a2bdbba6ee46c3b39f028d Mon Sep 17 00:00:00 2001 From: Sudar Date: Mon, 17 Dec 2012 17:12:12 +0530 Subject: [PATCH 77/83] Check if ARDUINO_DIR Env variable is defined or not --- bin/ard-parse-boards | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/ard-parse-boards b/bin/ard-parse-boards index 680acee..2e975bb 100755 --- a/bin/ard-parse-boards +++ b/bin/ard-parse-boards @@ -8,9 +8,14 @@ use Pod::Usage; use YAML; my %Opt = - ( - boards_txt => "$ENV{'ARDUINO_DIR'}/hardware/arduino/boards.txt", - ); + ( + boards_txt => '/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt', + ); + +# if the ARDUINO_DIR is defined, then use it +if (defined $ENV{'ARDUINO_DIR'}) { + $Opt{boards_txt} = "$ENV{'ARDUINO_DIR'}/hardware/arduino/boards.txt"; +} GetOptions(\%Opt, "boards_txt=s", # filename of the boards.txt file From 0966e8e5f3df8cfd2d96c470fcfca6095f23a4b1 Mon Sep 17 00:00:00 2001 From: Sudar Date: Sun, 23 Dec 2012 15:42:30 +0530 Subject: [PATCH 78/83] Auto detect sketchbook location even in MAC --- arduino-mk/Arduino.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index b915445..ec5a758 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -478,6 +478,14 @@ ifndef ARDUINO_SKETCHBOOK $(HOME)/.arduino/preferences.txt | \ sed -e 's/sketchbook.path=//' ) endif + + # on mac + ifneq ($(wildcard $(HOME)/Library/Arduino/preferences.txt),) + ARDUINO_SKETCHBOOK = $(shell grep --max-count=1 --regexp="sketchbook.path=" \ + $(HOME)/Library/Arduino/preferences.txt | \ + sed -e 's/sketchbook.path=//' ) + endif + ifneq ($(ARDUINO_SKETCHBOOK),) $(call show_config_variable,ARDUINO_SKETCHBOOK,[AUTODETECTED],(in arduino preferences file)) else From e9f5897d19aa3b7396b00d35667897d931aedc5b Mon Sep 17 00:00:00 2001 From: Sudar Date: Thu, 3 Jan 2013 22:31:24 +0530 Subject: [PATCH 79/83] Fixed the automatic baudrate detection script that was broken if the line already had the tab character --- arduino-mk/Arduino.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index ec5a758..96f2e1b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -511,8 +511,8 @@ endif # for more information (search for 'character special device'). # ifndef MONITOR_BAUDRATE - #This works only in linux. TODO: Port it to MAC OS also - SPEED = $(shell grep --max-count=1 --regexp="Serial.begin" $$(ls -1 *.ino) | sed -e 's/\/\/.*$$//g' -e 's/(/\t/' -e 's/)/\t/' | awk -F '\t' '{print $$2}' ) + #This works only in linux. TODO: Port it to MAC OS also + SPEED = $(shell grep --max-count=1 --regexp="Serial.begin" $$(ls -1 *.ino) | sed -e 's/\t//g' -e 's/\/\/.*$$//g' -e 's/(/\t/' -e 's/)/\t/' | awk -F '\t' '{print $$2}' ) MONITOR_BAUDRATE = $(findstring $(SPEED),300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200) ifeq ($(MONITOR_BAUDRATE),) From c8253f60ce5ad3eca55bc42b6999a6c0bfd7d8f5 Mon Sep 17 00:00:00 2001 From: fr0sty1 Date: Mon, 21 Jan 2013 00:01:09 -0600 Subject: [PATCH 80/83] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d949ae..1d090f8 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ need the YAML library to run ard-parse-boards. On Debian or Ubuntu: - apt-get install libdevice-serial-perl + apt-get install libdevice-serialport-perl apt-get install libyaml-perl On Fedora: From cd36eb6abb43fe2a9286f4762dd9cdf4d3ad9b28 Mon Sep 17 00:00:00 2001 From: Sudar Date: Mon, 21 Jan 2013 21:17:39 +0530 Subject: [PATCH 81/83] Updated Readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7035afd..244b038 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ The following are the list of changes that I have made or merged in this fork. H - Removed -w from CPPFLAGS to show warnings (https://github.com/gaftech) - Changed shebang to use /usr/bin/env (https://github.com/anm) - set USB_VID and USB_PID only for leonardo boards(https://github.com/alohr) +- Updated Readme (https://github.com/fr0sty1/) ## Know Issues - Because of the way the makefile is structured, the configuration parameters gets printed twice. From 5634d8ba51e7708b4ef74ab6034b339b96ea5e0c Mon Sep 17 00:00:00 2001 From: Jeff Kowalski Date: Sat, 16 Mar 2013 00:19:56 -0700 Subject: [PATCH 82/83] removed unnecessary .DS_Store --- examples/BlinkWithoutDelay/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 examples/BlinkWithoutDelay/.DS_Store diff --git a/examples/BlinkWithoutDelay/.DS_Store b/examples/BlinkWithoutDelay/.DS_Store deleted file mode 100644 index 311ccf4998083c78762cf8e341f676f5d050559b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}T>S5T0$TCa92$(BtB{N^2|i;30$x9)%Wqu%d|(8VF5k5_+i7;Kj%BZG0YQ zcGqGtXAzx&*>84!b~hhne*i#udDsDP0Kh^e6l7Egxhq38lPnNXaf}d-;2vU#f@Q@( zztKf&w;_NWB3$>E^{4Y7P6CX+1@kycvv&Jk)as3`?H$Xut-Z-OnuW>IOY&KmUJs|q zau|gVfxoy>cIIb!>iG*5x$?6qMwC5Dk{IoY$sR{xHobM4tJO)r+mfBrUeS`Pe!tz4 zz3y32*p_8Guhzlg@%iP*e=MG!OU7P8Z0%ctpgkN1VC({TM63qmY^DG&^1_U#0ZMerHHyzm?wtN<>;3t z&ox+T)a4-5%s7sj`SbB2)a>Y&DjkHYky~bf8Q5f?uDcGM{}=enR6g=IOSs1jFav*# z0nr!?2OfTuIa|Md9-Xxk^$wMU@=7vL(B8NNV2AdRrV8q~BpdTwgQZ3qh5V` Date: Sun, 19 May 2013 16:33:59 +0530 Subject: [PATCH 83/83] Updated readme to add information about change in maintainers --- README.md | 149 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 85 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 244b038..35c61eb 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,17 @@ # A Makefile for Arduino Sketches -This is a very simple Makefile which knows how to build Arduino sketches. It defines the entire workflows for compiling code, flashing it to Arduino and even communicating through Serial monitor. You don't need to change anything in the Arduino sketches +This is a very simple Makefile which knows how to build Arduino sketches. It defines the entire workflows for compiling code, flashing it to Arduino and even communicating through Serial monitor. You don't need to change anything in the Arduino sketches. -Until March 2012, this was simply posted on my website where you can -still find [what documentation](http://mjo.tc/atelier/2009/02/arduino-cli.html -"Documentation") exists. +If you're using Debian or Ubuntu, you can find this in the `arduino-mk` package. -If you're using Debian or Ubuntu, you can find this in the -arduino-mk package. +## Credits -# Important Changes, 2012-04-29 +This makefile was originally created by [Martin Oldfield](http://mjo.tc/atelier/2009/02/arduino-cli.html) and he maintained it till v0.10.2. +From May 2013, it is maintained by [Sudar](http://hardwarefun.com) -I've rejigged the path calculations so that: +## Usage -1. Few, if any paths, need to specified in the project specific Makefiles. - -1. The paths can be grabber from the environment e.g. set up in a user's .bashrc. - -1. It should be easier to move between e.g. Mac and Linux. - -I'm indebted to Christopher Peplin for making me think about this, and indeed for -contributing code which did similar things in different ways. - -The upshot of all this is that you'll need to set up some variables if you want -this to work: +Download a copy of this repo some where in your system. On the Mac you might want to set: @@ -69,46 +57,17 @@ standard location for custom libraries when using the Arduino IDE), you need to set the `ARDUINO_SKETCHBOOK` variable to point to this directory. By default it is set to `$HOME/sketchbook`. -## Notes from Sudar +## Changelog -The following are the list of changes that I have made or merged in this fork. Hopefully it gets into mjoldfield repo and ultimately into Ubuntu package one day :) +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. -### 0.9.1 06.vi.2012 - -- Corrected the ubuntu package names -- Prevent the *file-not-found* error if the depends.mk file is not needed -- Delete the build-cli folder as well while doing make clean -- Added support for compiling .pde files in Arduino 1.0 environment -- Replaced = with += in CPPFLAGS assignment so that we can set CPPFLAGS per sketch if needed -- Changed AVRDUDE_CONF so it can be defined in per-project makefile (https://github.com/WizenedEE) -- Cleaner way to delete the build-cli directory when make clean is invoked -- The package name in Debian and Ubuntu is arduino-mk (https://github.com/maqifrnswa) - -### 0.9.2 06.vi.2012 - -- Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech) -- Modified "make size" behavior: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) - -### 0.9.3 13.vi.2012 - -- Auto detect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/) -- Categorize libs into user and system (https://github.com/rpavlik/) -- Dump size at the end of the build (https://github.com/rpavlik/) -- Lots and lots of improvements (https://github.com/rpavlik/) -- 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 - -### 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 - -### 0.9.3.2 10.ix.2012 Sudar -- Fixed a typo in README. Issue reported at upstream (https://github.com/mjoldfield/Arduino-Makefile/issues/21) - -### 0.10 17.ix.12 M J Oldfield -- Merged all changes from Upstream +### 0.10.2 15.xii.2012 Sudar +- Added sketch size verification. (https://github.com/fornellas) +- Show original line number for error messages (https://github.com/WizenedEE) +- Removed -w from CPPFLAGS to show warnings (https://github.com/gaftech) +- Changed shebang to use /usr/bin/env (https://github.com/anm) +- set USB_VID and USB_PID only for leonardo boards(https://github.com/alohr) +- Updated Readme (https://github.com/fr0sty1/) ### 0.10.1 15.xii.2012 Sudar - Merged all changes from Upstream and the following changes from https://github.com/rpavlik @@ -123,15 +82,77 @@ The following are the list of changes that I have made or merged in this fork. H - Make everybody depend on the makefile, in case cflags are changed, etc. - Make the makefile error if the arduino port is not present. -### 0.10.2 15.xii.2012 Sudar -- Added sketch size verification. (https://github.com/fornellas) -- Show original line number for error messages (https://github.com/WizenedEE) -- Removed -w from CPPFLAGS to show warnings (https://github.com/gaftech) -- Changed shebang to use /usr/bin/env (https://github.com/anm) -- set USB_VID and USB_PID only for leonardo boards(https://github.com/alohr) -- Updated Readme (https://github.com/fr0sty1/) +### 0.10 17.ix.12 M J Oldfield +- Merged all changes from Upstream + +### 0.9.3.2 10.ix.2012 Sudar +- Fixed a typo in README. Issue reported at upstream (https://github.com/mjoldfield/Arduino-Makefile/issues/21) + +### 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 + +### 0.9.3 13.vi.2012 + +- Auto detect ARDUINO_DIR, Arduino version (https://github.com/rpavlik/) +- Categorize libs into user and system (https://github.com/rpavlik/) +- Dump size at the end of the build (https://github.com/rpavlik/) +- Lots and lots of improvements (https://github.com/rpavlik/) +- 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 + +### 0.9.2 06.vi.2012 + +- Allow user to choose source files (LOCAL_*_SRCS flags) (https://github.com/Gaftech) +- Modified "make size" behavior: using --mcu option and targeting .elf file instead of .hex file.(https://github.com/Gaftech) + +### 0.9.1 06.vi.2012 + +- Corrected the ubuntu package names +- Prevent the *file-not-found* error if the depends.mk file is not needed +- Delete the build-cli folder as well while doing make clean +- Added support for compiling .pde files in Arduino 1.0 environment +- Replaced = with += in CPPFLAGS assignment so that we can set CPPFLAGS per sketch if needed +- Changed AVRDUDE_CONF so it can be defined in per-project makefile (https://github.com/WizenedEE) +- Cleaner way to delete the build-cli directory when make clean is invoked +- The package name in Debian and Ubuntu is arduino-mk (https://github.com/maqifrnswa) + +### 2012-02-12, version 0.8 +- Patches for version 1.0 of the Arduino IDE. Older versions might still work, but I’ve not tested it. +- A change to the build process: rather than link all the system objects directly into the executable, bundle them in a library first. This should make the final executable smaller. +- If TARGET isn’t explicitly set, default to the current directory name. Thanks to Daniele Vergini for this patch. +- Add support for .c files in system libraries: Dirk-Willem van Gulik and Evan Goldenberg both reported this and provided patches in the same spirit. +- Added a size target as suggested by Alex Satrapa. + +### Unreleased, version 0.7 +- Added -lm to the linker options, and -F to stty. + +### 2011-06-23, version 0.6 +- Added ard-parse-boards. Mark Sproul suggested doing something like this ages ago, but I’ve only recently looked at it in detail. +- Fabien Le Lez reported that one needs to link with -lc to avoid [linker errors](http://forum.arduino.cc/index.php/topic,40215.0.html). + +### 2011-06-23, version 0.5 +- Imported changes from Debian/Ubuntu, which incorporate a patch from Stefan Tomanek so that libraries would be compiled too. + +Note: Many other people sent me similar patches, but I didn’t get around to using them. In the end, I took the patch from Debian and Ubuntu: there seems merit in not forking the code and using a tested version. So, thanks and apologies to Nick Andrew, Leandro Coletto Biazon, Thibaud Chupin, Craig Hollabaugh, Johannes H. Jensen, Fabien Le Lez, Craig Leres, and Mark Sproul. + +### 2010-05-24, version 0.4 +Tweaked rules for the reset target on Philip Hands’ advice. + +### 2010-05-21, version 0.3 +- Tidied up the licensing, making it clear that it’s released under LGPL 2.1. +- [Philip Hands](http://hands.com/~phil/) sent me some code to reset the Arduino by dropping DTR for 100ms, and I added it. +- Tweaked the Makefile to handle version 0018 of the Arduino software which now includes main.cpp. Accordingly we don’t need to—and indeed must not—add main.cxx to the .pde sketch file. The paths seem to have changed a bit too. ## Know Issues - Because of the way the makefile is structured, the configuration parameters gets printed twice. - Doesn't work with Leonardo yet. - More todo's at https://github.com/sudar/Arduino-Makefile/issues/ + +## Similar works +- It's not a derivative of this, but Alan Burlison has written a [similar thing](http://bleaklow.com/2010/06/04/a_makefile_for_arduino_sketches.html). +- Alan's Makefile was used in a [Pragmatic Programmer's article](http://pragprog.com/magazines/2011-04/advanced-arduino-hacking). +- Rei Vilo wrote to tell me that he's using the Makefile ina Xcode 4 template called [embedXcode](http://embedxcode.weebly.com/). Apparently it supports many platforms and boards, including AVR-based Arduino, AVR-based Wiring, PIC32-based chipKIT, MSP430-based LaunchPad and ARM3-based Maple.