From 3d4ec88dfdcbf60b33a785cd0f2064066fc013dd Mon Sep 17 00:00:00 2001 From: gabriel Date: Thu, 31 Jan 2013 22:14:07 +0100 Subject: [PATCH 01/21] Allow adding extra common dependencies --- arduino-mk/Arduino.mk | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 96f2e1b..8b72b0b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -148,12 +148,15 @@ # - 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) # -# 0.10.3 16.xii 2012 gaftech +# 0.10.3 16.xii 2012 gaftech # - Enabling creation of EEPROM file (.eep) # - EEPROM upload: eeprom and raw_eeprom targets # - Auto EEPROM upload with isp mode: ISP_EEPROM option. # - Allow custom OBJDIR # +# 0.10.4 24.i.2013 gaftech +# - Allow adding extra common dependencies (COMMON_DEPS) +# ######################################################################## # # PATHS YOU NEED TO SET UP @@ -803,7 +806,11 @@ $(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!!! +ifdef COMMON_DEPS +COMMON_DEPS := $(COMMON_DEPS) Makefile +else COMMON_DEPS := Makefile +endif $(OBJDIR)/%.o: %.c $(COMMON_DEPS) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ From 79243b8397d18310348669b0d6967a54b73e10b7 Mon Sep 17 00:00:00 2001 From: Daniel Esteban Nombela Date: Sun, 10 Feb 2013 15:13:44 +0100 Subject: [PATCH 02/21] Added ifndef ARDUINO_VAR_PATH for compiling for the attiny --- arduino-mk/Arduino.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 09819ac..88b4448 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -309,7 +309,10 @@ endif ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino + +ifndef ARDUINO_VAR_PATH ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants +endif else From 14fd6e712699ca98485abb54e84972cc9a9a59d6 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 30 May 2013 12:55:10 +0200 Subject: [PATCH 03/21] Move MONITOR_BAUDRATE detection further down No changes are made to the code, it is only moved. This allows it to use LOCAL_INO_SRCS and LOCAL_INO_PDE_SRCS in the next commit. --- arduino-mk/Arduino.mk | 52 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 96f2e1b..24c6021 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -503,32 +503,6 @@ else $(call show_config_variable,USER_LIB_PATH) endif -######################################################################## -# Serial monitor (just a screen wrapper) -# -# Quite how to construct the monitor command seems intimately tied -# to the command we're using (here screen). So, read the screen docs -# 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/\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),) - MONITOR_BAUDRATE = 9600 - $(call show_config_variable,MONITOR_BAUDRATE,[ASSUMED]) - else - $(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch)) - endif -else - $(call show_config_variable,MONITOR_BAUDRATE, [SPECIFIED]) -endif - -ifndef MONITOR_CMD - MONITOR_CMD = screen -endif - ######################################################################## # Reset ifndef RESET_CMD @@ -675,6 +649,32 @@ ifndef ARDUINO_LIBS $(shell sed -ne "s/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p" $(LOCAL_SRCS))) endif +######################################################################## +# Serial monitor (just a screen wrapper) +# +# Quite how to construct the monitor command seems intimately tied +# to the command we're using (here screen). So, read the screen docs +# 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/\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),) + MONITOR_BAUDRATE = 9600 + $(call show_config_variable,MONITOR_BAUDRATE,[ASSUMED]) + else + $(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch)) + endif +else + $(call show_config_variable,MONITOR_BAUDRATE, [SPECIFIED]) +endif + +ifndef MONITOR_CMD + MONITOR_CMD = screen +endif + ######################################################################## # Rules for making stuff # From 05ce9fd14b9d925fb7582f872eba9f91afeeac5d Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 30 May 2013 13:08:02 +0200 Subject: [PATCH 04/21] When detecting MONITOR_BAUDRATE, use $(LOCAL_INO_SRCS) Now that this detection code is moved down a bit, it can use the same .ino list as all the other code. --- 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 24c6021..88efb0d 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -658,7 +658,7 @@ endif # 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/\t//g' -e 's/\/\/.*$$//g' -e 's/(/\t/' -e 's/)/\t/' | awk -F '\t' '{print $$2}' ) + SPEED = $(shell grep --max-count=1 --regexp="Serial.begin" $(LOCAL_INO_SRCS) | 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 e1bed904043a79611768a8f98e32d7b79bafb3b3 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 30 May 2013 13:09:15 +0200 Subject: [PATCH 05/21] Let MONITOR_BAUDRATE detection also look in .pde files Before, it would only look in .ino files. If you had no .ino file but only a .pde file, this would cause the build to hang, since grep would be waiting for input on its stdin. --- 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 88efb0d..aed16d6 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -658,7 +658,7 @@ endif # ifndef MONITOR_BAUDRATE #This works only in linux. TODO: Port it to MAC OS also - SPEED = $(shell grep --max-count=1 --regexp="Serial.begin" $(LOCAL_INO_SRCS) | sed -e 's/\t//g' -e 's/\/\/.*$$//g' -e 's/(/\t/' -e 's/)/\t/' | awk -F '\t' '{print $$2}' ) + SPEED = $(shell grep --max-count=1 --regexp="Serial.begin" $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | 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 c64f38ae6d3591e4b94f6ba8659e7ddf30446a14 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 30 May 2013 13:14:20 +0200 Subject: [PATCH 06/21] Check that there is exactly one .pde or .ino file When there are none (and no .cpp files either), the build would stall trying to cat all the .d files together (which would result in cat getting no arguments and thus waiting for input on stdin). When there are multiple .ino and/or .pde files, the build could technically work out, the Arduino IDE concatenates all .ino / .pde files together and compiles them as a single compile unit, so unless we implement that as well, it's better to just error out. --- arduino-mk/Arduino.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index aed16d6..79878f6 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -619,6 +619,10 @@ LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES)) # Dependency files DEPS = $(LOCAL_OBJS:.o=.d) +ifneq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 1) + $(error Need exactly one .pde or .ino file) +endif + # core sources ifeq ($(strip $(NO_CORE)),) ifdef ARDUINO_CORE_PATH From 5ea24373116beffea81675a12363be08e2d0e0c8 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 30 May 2013 15:01:07 +0200 Subject: [PATCH 07/21] Fix raw_upload and reset for normal uploads In commit 90e3c9ad (Fix upload in case of parallelized make), some dependencies were shuffled to (I assume) prevent the reset from happening before or at the same time as the upload when running a parallel make. However, this introduced two problems: - The upload and raw_upload became effectively the same, and both of them did a reset (even though raw_upload should do the upload without a reset). - The reset target does not depend on $(TARGET_HEX) or verify_size, so in a parallel make the reset is executed before / at the same time as the actual compilation (since the reset doesn't seem to be needed for at least the Arduino Uno, apparently avrdude handles this, this probably wasn't noticed by anyone). Because we can't force a specific ordering of dependencies in parallel make and because adding dependencies to the reset target doesn't seem appropriate (you should be able to do a "make reset" without needing to compile everything first), this commit changes the uploading to call $(MAKE) again to do the actual upload. The current approach ensures that: - raw_upload does a compile, size check and upload and upload does the same plus a reset. - A reset is not done if the compilation fails or the size check fails. - verify_size is called only once. --- arduino-mk/Arduino.mk | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 79878f6..1064160 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -951,9 +951,16 @@ $(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) $(DEP_FILE): $(OBJDIR) $(DEPS) cat $(DEPS) > $(DEP_FILE) -upload: raw_upload +upload: $(TARGET_HEX) verify_size + # Use submake so we can guarantee the reset happens + # before the upload, even with make -j + $(MAKE) reset + $(MAKE) do_upload -raw_upload: reset $(TARGET_HEX) verify_size +raw_upload: $(TARGET_HEX) verify_size + $(MAKE) do_upload + +do_upload: $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ $(AVRDUDE_UPLOAD_HEX) From ae10f71dd4eb0143e3ec1740360a4f5c0005eee4 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 30 May 2013 16:09:05 +0200 Subject: [PATCH 08/21] Output configuration info only once Before, the configuration info would be shown again when running a recursive make call, or when make restarted after regenerating the dependencies file. Now, it only shows the info the first time. Closes: #46 --- arduino-mk/Arduino.mk | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 1064160..f068739 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -340,10 +340,16 @@ dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) # the number of bytes indicated by the second argument. space_pad_to = $(shell echo $(1) " " | head -c$(2)) +arduino_output = +# When output is not suppressed and we're in the top-level makefile, +# running for the first time (i.e., not after a restart after +# regenerating the dependency file), then output the configuration. ifndef ARDUINO_QUIET - arduino_output = $(info $(1)) -else - arduino_output = + ifeq ($(MAKE_RESTARTS),) + ifeq ($(MAKELEVEL),0) + arduino_output = $(info $(1)) + endif + endif endif # Call with some text, and a prefix tag if desired (like [AUTODETECTED]), From 1329730dfef14bccf163457d1371abb201d76bf4 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 30 May 2013 16:23:32 +0200 Subject: [PATCH 09/21] Don't try to read version.txt when it does not exist This can happen for example when the arduino directory is a checkout from git instead of a released version. Before, cat would show an error which is now prevented. The version still defaults to 100 just like before. --- 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 f068739..2fb5b10 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -392,7 +392,8 @@ 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 -c3) + VERSION_FILE := $(ARDUINO_DIR)/lib/version.txt + AUTO_ARDUINO_VERSION := $(shell [ -e $(VERSION_FILE) ] && cat $(VERSION_FILE) | 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 97fa5ae161e3aae3fb5f503effc8b8cb0ee65935 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 30 May 2013 13:29:25 +0200 Subject: [PATCH 10/21] Let the Makefile decide which include to use for .pde files Previously, the C preprocessor would pick either Arduino.h or WProgram.h based on a define. Now, the Makefile makes the decision earlier. This prevents having to duplicate the #if line in the next commit. --- arduino-mk/Arduino.mk | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 2fb5b10..f2ec06e 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -686,6 +686,19 @@ ifndef MONITOR_CMD MONITOR_CMD = screen endif +######################################################################## +# Include file to use for old .pde files +# +ifndef PDE_INCLUDE + # We should check for Arduino version, if the file is .pde because a + # .pde file might be used in Arduino 1.0 + ifeq ($(shell expr $(ARDUINO_VERSION) '<' 100), 1) + PDE_INCLUDE=WProgram.h + else + PDE_INCLUDE=Arduino.h + endif +endif + ######################################################################## # Rules for making stuff # @@ -845,11 +858,9 @@ $(OBJDIR)/%.d: %.S $(COMMON_DEPS) $(OBJDIR)/%.d: %.s $(COMMON_DEPS) $(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 $(COMMON_DEPS) - $(ECHO) '#if ARDUINO >= 100\n #include "Arduino.h"\n#else\n #include "WProgram.h"\n#endif\n#line 1' > $@ + $(ECHO) '#include "$(PDE_INCLUDE)"\n#line 1' > $@ $(CAT) $< >> $@ # the ino -> cpp -> o file From 1f043bb819064d786d106d40ffbff5b92b1a0ced Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 30 May 2013 13:35:37 +0200 Subject: [PATCH 11/21] Compile .ino and .pde files directly Before, they were copied to a .cpp file to add the Arduino.h/WProgram.h include. However, this would cause the compiler error messages to not refer to the right filename, making it hard to use the compiler output in an editor like vim to point out errors. By using gcc's -include option, there is no need to modify the ino/pde file before compiling. However, we will need to explicitely tell gcc that the source file is c++, because of the non-standard extensions. --- arduino-mk/Arduino.mk | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index f2ec06e..8ca4026 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -858,21 +858,21 @@ $(OBJDIR)/%.d: %.S $(COMMON_DEPS) $(OBJDIR)/%.d: %.s $(COMMON_DEPS) $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) -# the pde -> cpp -> o file -$(OBJDIR)/%.cpp: %.pde $(COMMON_DEPS) - $(ECHO) '#include "$(PDE_INCLUDE)"\n#line 1' > $@ - $(CAT) $< >> $@ +# the pde -> o file +$(OBJDIR)/%.o: %.pde + $(CXX) -x c++ -include $(PDE_INCLUDE) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -# the ino -> cpp -> o file -$(OBJDIR)/%.cpp: %.ino $(COMMON_DEPS) - $(ECHO) '#include \n#line 1' > $@ - $(CAT) $< >> $@ +# the pde -> d file +$(OBJDIR)/%.d: %.pde + $(CXX) -x c++ -include $(PDE_INCLUDE) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) -$(OBJDIR)/%.o: $(OBJDIR)/%.cpp $(COMMON_DEPS) - $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ +# the ino -> o file +$(OBJDIR)/%.o: %.ino + $(CXX) -x c++ -include Arduino.h -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -$(OBJDIR)/%.d: $(OBJDIR)/%.cpp $(COMMON_DEPS) - $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) +# the ino -> d file +$(OBJDIR)/%.d: %.ino + $(CXX) -x c++ -include Arduino.h -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) # generated assembly $(OBJDIR)/%.s: $(OBJDIR)/%.cpp $(COMMON_DEPS) From 4fdd1765e6db9049b5048dad568954e4c6b6fa21 Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Thu, 5 Jul 2012 04:30:47 +0100 Subject: [PATCH 12/21] Rewrite dependency code Commit originally by: Paul Brook Port to newer version and commit message by: Matthijs Kooijman Instead of generating a big list of dependencies at the start, now dependency files are generated whenever a .o file is compiled. This works, since if the .o file does not exist, it should be compiled and make does not need to know about its dependencies. If the .o (and thus the .d) file does exist, the .d file contains all the dependencies used to compile the .o file. If none of those changed, the .o file does not need a recompile, but also the .d file is still accurate (in particular, the dependency list cannot change without one of the dependent .h files or the .cpp file itself changing). This helps to remove a lot of duplication in the code, since now only a single commandline is needed for both compilation and dependency generation. It will probably also run a bit faster now. Note that this commit breaks the creation of $(OBJDIR) since this "accidentally" always worked before because $(DEPFILE) was created before anything else. That will be fixed next. --- arduino-mk/Arduino.mk | 52 +++++++------------------------------------ 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 8ca4026..30de577 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -710,9 +710,6 @@ TARGET_EEP = $(OBJDIR)/$(TARGET).eep TARGETS = $(OBJDIR)/$(TARGET).* CORE_LIB = $(OBJDIR)/libcore.a -# A list of dependencies -DEP_FILE = $(OBJDIR)/depends.mk - # Names of executables CC = $(AVR_TOOLS_PATH)/avr-gcc CXX = $(AVR_TOOLS_PATH)/avr-g++ @@ -825,54 +822,29 @@ $(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ # normal local sources -# .o rules are for objects, .d for dependency tracking -# there seems to be an awful lot of duplication here!!! COMMON_DEPS := Makefile $(OBJDIR)/%.o: %.c $(COMMON_DEPS) - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ $(OBJDIR)/%.o: %.cc $(COMMON_DEPS) - $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(OBJDIR)/%.o: %.cpp $(COMMON_DEPS) - $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(OBJDIR)/%.o: %.S $(COMMON_DEPS) - $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ + $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ $(OBJDIR)/%.o: %.s $(COMMON_DEPS) $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ -$(OBJDIR)/%.d: %.c $(COMMON_DEPS) - $(CC) -MM $(CPPFLAGS) $(CFLAGS) $< -MF $@ -MT $(@:.d=.o) - -$(OBJDIR)/%.d: %.cc $(COMMON_DEPS) - $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) - -$(OBJDIR)/%.d: %.cpp $(COMMON_DEPS) - $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) - -$(OBJDIR)/%.d: %.S $(COMMON_DEPS) - $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) - -$(OBJDIR)/%.d: %.s $(COMMON_DEPS) - $(CC) -MM $(CPPFLAGS) $(ASFLAGS) $< -MF $@ -MT $(@:.d=.o) - # the pde -> o file $(OBJDIR)/%.o: %.pde - $(CXX) -x c++ -include $(PDE_INCLUDE) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ - -# the pde -> d file -$(OBJDIR)/%.d: %.pde - $(CXX) -x c++ -include $(PDE_INCLUDE) -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) + $(CXX) -x c++ -include $(PDE_INCLUDE) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # the ino -> o file $(OBJDIR)/%.o: %.ino - $(CXX) -x c++ -include Arduino.h -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ - -# the ino -> d file -$(OBJDIR)/%.d: %.ino - $(CXX) -x c++ -include Arduino.h -MM $(CPPFLAGS) $(CXXFLAGS) $< -MF $@ -MT $(@:.d=.o) + $(CXX) -x c++ -include Arduino.h -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # generated assembly $(OBJDIR)/%.s: $(OBJDIR)/%.cpp $(COMMON_DEPS) @@ -966,9 +938,6 @@ $(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) $(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) $(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) -$(DEP_FILE): $(OBJDIR) $(DEPS) - cat $(DEPS) > $(DEP_FILE) - upload: $(TARGET_HEX) verify_size # Use submake so we can guarantee the reset happens # before the upload, even with make -j @@ -1014,10 +983,7 @@ ispload: $(TARGET_EEP) $(TARGET_HEX) verify_size -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} - -depends: $(DEPS) - $(CAT) $(DEPS) > $(DEP_FILE) + $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEPS) $(USER_LIB_OBJS) ${OBJDIR} size: $(OBJDIR) $(TARGET_HEX) $(call avr_size,$(TARGET_ELF),$(TARGET_HEX)) @@ -1046,6 +1012,4 @@ generated_assembly: $(OBJDIR)/$(TARGET).s .PHONY: all upload raw_upload reset reset_stty ispload clean depends size show_boards monitor disasm symbol_sizes generated_assembly verify_size # 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 +-include $(DEPS) From b96e03dde1a47e6f6a61808724fd3abf0eb28c39 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 30 May 2013 19:44:39 +0200 Subject: [PATCH 13/21] Fix creating of $(OBJDIR) in a proper way This adds a dependency on $(OBJDIR) for every rule that creates a file inside $(OBJDIR) but does not already depend on any file within $(OBJDIR). All other dependencies on $(OBJDIR) are removed. These dependencies are added after a | to tell make that this is a "order-only prerequisite". This means that the file inside $(OBJDIR) needs $(OBJDIR) to be present but if $(OBJDIR) changes (which happens whenever a file _inside_ the directory is touched!), there is no need to recompile the file within $(OBJDIR). Implementing this using a generic implicit rule like: $(OBJDIR)/%: | $(OBJDIR) doesn't work, since make doesn't merge the prerequisites of multiple implicit rules like it does for explicit rules. We could use $(LOCAL_OBJS) and friends to create explicit rules to do something like the above, but just adding the dependencies on all rules seems more explicit and future-proof. --- arduino-mk/Arduino.mk | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 30de577..01a3df1 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -805,59 +805,55 @@ $(call show_separator) # easy to change the build options in future # library sources -$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.c - mkdir -p $(dir $@) +$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.c | $(OBJDIR) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ -$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.cpp - mkdir -p $(dir $@) +$(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.cpp | $(OBJDIR) $(CC) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.cpp - mkdir -p $(dir $@) +$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.cpp | $(OBJDIR) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ -$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c - mkdir -p $(dir $@) +$(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c | $(OBJDIR) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ # normal local sources COMMON_DEPS := Makefile -$(OBJDIR)/%.o: %.c $(COMMON_DEPS) +$(OBJDIR)/%.o: %.c $(COMMON_DEPS) | $(OBJDIR) $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ -$(OBJDIR)/%.o: %.cc $(COMMON_DEPS) +$(OBJDIR)/%.o: %.cc $(COMMON_DEPS) | $(OBJDIR) $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -$(OBJDIR)/%.o: %.cpp $(COMMON_DEPS) +$(OBJDIR)/%.o: %.cpp $(COMMON_DEPS) | $(OBJDIR) $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -$(OBJDIR)/%.o: %.S $(COMMON_DEPS) +$(OBJDIR)/%.o: %.S $(COMMON_DEPS) | $(OBJDIR) $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ -$(OBJDIR)/%.o: %.s $(COMMON_DEPS) +$(OBJDIR)/%.o: %.s $(COMMON_DEPS) | $(OBJDIR) $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ # the pde -> o file -$(OBJDIR)/%.o: %.pde +$(OBJDIR)/%.o: %.pde | $(OBJDIR) $(CXX) -x c++ -include $(PDE_INCLUDE) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # the ino -> o file -$(OBJDIR)/%.o: %.ino +$(OBJDIR)/%.o: %.ino | $(OBJDIR) $(CXX) -x c++ -include Arduino.h -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # generated assembly -$(OBJDIR)/%.s: $(OBJDIR)/%.cpp $(COMMON_DEPS) +$(OBJDIR)/%.s: $(OBJDIR)/%.cpp $(COMMON_DEPS) | $(OBJDIR) $(CXX) -S -fverbose-asm $(CPPFLAGS) $(CXXFLAGS) $< -o $@ #$(OBJDIR)/%.lst: $(OBJDIR)/%.s # $(AS) -mmcu=$(MCU) -alhnd $< > $@ # core files -$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c $(COMMON_DEPS) +$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c $(COMMON_DEPS) | $(OBJDIR) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ -$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp $(COMMON_DEPS) +$(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # various object conversions @@ -927,8 +923,14 @@ endif # Explicit targets start here # -all: $(OBJDIR) $(TARGET_EEP) $(TARGET_HEX) verify_size +all: $(TARGET_EEP) $(TARGET_HEX) verify_size +# Rule to create $(OBJDIR) automaticallly. All rules with recipes that +# create a file within it, but do not already depend on a file within it +# should depend on this rule. They should use a "order-only +# prerequisite" (e.g., put "| $(OBJDIR)" at the end of the prequisite +# list) to prevent remaking the target when any file in th directory +# changes. $(OBJDIR): mkdir $(OBJDIR) @@ -985,7 +987,7 @@ ispload: $(TARGET_EEP) $(TARGET_HEX) verify_size clean: $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEPS) $(USER_LIB_OBJS) ${OBJDIR} -size: $(OBJDIR) $(TARGET_HEX) +size: $(TARGET_HEX) $(call avr_size,$(TARGET_ELF),$(TARGET_HEX)) show_boards: From 4ea3ab78849820e4b32b573baf6bb3f8743c20dd Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 20 Feb 2013 17:30:44 +0100 Subject: [PATCH 14/21] Enable dependency tracking for libraries and core This makes sure a library or core file gets rebuild when a header file it depends on is changed, preventing weird surprises when the application is recompiled with the new header values but the library isn't. For most users, this won't be strictly needed, but anyone working on a library or even the Arduino core, this is must to prevent surprises or needing a make clean between every build attempt. --- arduino-mk/Arduino.mk | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 01a3df1..148e6b6 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -623,9 +623,6 @@ LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \ $(LOCAL_INO_SRCS:.ino=.o) $(LOCAL_AS_SRCS:.S=.o) LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES)) -# Dependency files -DEPS = $(LOCAL_OBJS:.o=.d) - ifneq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 1) $(error Need exactly one .pde or .ino file) endif @@ -751,6 +748,9 @@ 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)) +# Dependency files +DEPS = $(LOCAL_OBJS:.o=.d) $(LIB_OBJS:.o=.d) $(USER_LIB_OBJS:.o=.d) $(CORE_OBJS:.o=.d) + # 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) \ @@ -806,16 +806,16 @@ $(call show_separator) # library sources $(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.c | $(OBJDIR) - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ $(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.cpp | $(OBJDIR) - $(CC) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + $(CC) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.cpp | $(OBJDIR) - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ $(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c | $(OBJDIR) - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ # normal local sources COMMON_DEPS := Makefile @@ -851,10 +851,10 @@ $(OBJDIR)/%.s: $(OBJDIR)/%.cpp $(COMMON_DEPS) | $(OBJDIR) # core files $(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c $(COMMON_DEPS) | $(OBJDIR) - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ $(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR) - $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # various object conversions $(OBJDIR)/%.hex: $(OBJDIR)/%.elf $(COMMON_DEPS) From d8bac0fb1414b45c1000862ea57c5fb93f3a01ca Mon Sep 17 00:00:00 2001 From: Sudar Date: Fri, 31 May 2013 09:29:36 +0530 Subject: [PATCH 15/21] Moved all version information and change log into HISTORY.md file --- HISTORY.md | 106 +++++++++++++++++++++++++++++++++ README.md | 94 ++--------------------------- arduino-mk/Arduino.mk | 135 +----------------------------------------- 3 files changed, 113 insertions(+), 222 deletions(-) create mode 100644 HISTORY.md diff --git a/HISTORY.md b/HISTORY.md new file mode 100644 index 0000000..ed99dcb --- /dev/null +++ b/HISTORY.md @@ -0,0 +1,106 @@ +A Makefile for Arduino Sketches +=============================== + +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.10.3 16.xii 2012 gaftech +- Enabling creation of EEPROM file (.eep) +- EEPROM upload: eeprom and raw_eeprom targets +- Auto EEPROM upload with isp mode: ISP_EEPROM option. +- Allow custom OBJDIR + +### 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 +- Allow passing extra flags +- Make listing files more useful +- Add knowledge of device-specific assembler +- Use variables instead of hardcoded commands +- Make disasm more helpful +- Change .sym output +- Provide symbol_sizes and generated_assembly targets. +- Be able to silence configuration output +- 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 17.ix.12 M J Oldfield +- Added installation notes for Fedora (ex Rickard Lindberg). +- Changed size target so that it looks at the ELF object, + not the hexfile (ex Jared Szechy and Scott Howard). +- Fixed ARDUNIO typo in README.md (ex Kalin Kozhuharov). +- Tweaked OBJDIR handling (ex Matthias Urlichs and Scott Howard). +- Changed the name of the Debian/Ubuntu package (ex + Scott Howard). +- Only set AVRDUDE_CONF if it's not set (ex Tom Hall). +- Added support for USB_PID/VID used by the Leonardo (ex Dan + Villiom Podlaski Christiansen and Marc Plano-Lesay). + +### 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. + diff --git a/README.md b/README.md index 35c61eb..5944f81 100644 --- a/README.md +++ b/README.md @@ -57,100 +57,16 @@ 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`. -## Changelog +## Versioning -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. +The current version of the makefile is `0.10.3`. You can find the full history in the [HISTORY.md](HISTORY.md) file -### 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/) +This project adheres to Semantic [Versioning 2.0](http://semver.org/). -### 0.10.1 15.xii.2012 Sudar -- Merged all changes from Upstream and the following changes from https://github.com/rpavlik -- Allow passing extra flags -- Make listing files more useful -- Add knowledge of device-specific assembler -- Use variables instead of hardcoded commands -- Make disasm more helpful -- Change .sym output -- Provide symbol_sizes and generated_assembly targets. -- Be able to silence configuration output -- 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 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. +## Know Issues / TODO's - Doesn't work with Leonardo yet. - More todo's at https://github.com/sudar/Arduino-Makefile/issues/ +- Because of the way the makefile is structured, the configuration parameters gets printed twice. ## 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). diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 148e6b6..b52ed45 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -19,140 +19,9 @@ # # Original Arduino adaptation by mellis, eighthave, oli.keller # -# Version 0.1 17.ii.2009 M J Oldfield +# Current version: 0.10.3 # -# 0.2 22.ii.2009 M J Oldfield -# - fixes so that the Makefile actually works! -# - support for uploading via ISP -# - orthogonal choices of using the Arduino for -# tools, libraries and uploading -# -# 0.3 21.v.2010 M J Oldfield -# - added proper license statement -# - added code from Philip Hands to reset -# Arduino prior to upload -# -# 0.4 25.v.2010 M J Oldfield -# - tweaked reset target on Philip Hands' advice -# -# 0.5 23.iii.2011 Stefan Tomanek -# - added ad-hoc library building -# 17.v.2011 M J Oldfield -# - grabbed said version from Ubuntu -# -# 0.6 22.vi.2011 M J Oldfield -# - added ard-parse-boards supports -# - 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 -# reckons it's good for Ubuntu -# -# 0.8 12.ii.2012 M J Oldfield -# - Patches for Arduino 1.0 IDE: -# support .ino files; -# handle board 'variants'; -# tweaked compile flags. -# - Build a library from all the system -# supplied code rather than linking the .o -# files directly. -# - Let TARGET default to current directory -# as per Daniele Vergini's 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. -# -# 0.9 26.iv.2012 M J Oldfield -# - Allow the punter to specify boards.txt -# file and parser independently (after -# Peplin and Brotchie on github) -# - Support user libraries (Peplin's patch) -# - Remove main.cpp if NO_CORE_MAIN_CPP is -# defined (ex Peplin) -# - Added a monitor target which talks to the -# Arduino serial port (Peplin's suggestion) -# - Rejigged PATH calculations for general -# tidiness (ex Peplin) -# - 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) -# -# -# 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/) -# - 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 -# - Added installation notes for Fedora (ex Rickard Lindberg). -# - Changed size target so that it looks at the ELF object, -# not the hexfile (ex Jared Szechy and Scott Howard). -# - Fixed ARDUNIO typo in README.md (ex Kalin Kozhuharov). -# - Tweaked OBJDIR handling (ex Matthias Urlichs and Scott Howard). -# - Changed the name of the Debian/Ubuntu package (ex -# Scott Howard). -# - Only set AVRDUDE_CONF if it's not set (ex Tom Hall). -# - Added support for USB_PID/VID used by the Leonardo (ex Dan -# Villiom Podlaski Christiansen and Marc Plano-Lesay). -# -# 0.10.1 15.xii.2012 Sudar -# - Merged all changes from Upstream and from https://github.com/rpavlik -# - Allow passing extra flags (https://github.com/rpavlik) -# - Make listing files more useful (https://github.com/rpavlik) -# - Add knowledge of device-specific assembler (https://github.com/rpavlik) -# - Use variables instead of hardcoded commands (https://github.com/rpavlik) -# - Make disasm more helpful (https://github.com/rpavlik) -# - Change .sym output (https://github.com/rpavlik) -# - Provide symbol_sizes and generated_assembly targets. (https://github.com/rpavlik) -# - Be able to silence configuration output (https://github.com/rpavlik) -# - Make everybody depend on the makefile, in case cflags are changed, etc. (https://github.com/rpavlik) -# - Make the makefile error if the arduino port is not present. (https://github.com/rpavlik) -# -# 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) -# -# 0.10.3 16.xii 2012 gaftech -# - Enabling creation of EEPROM file (.eep) -# - EEPROM upload: eeprom and raw_eeprom targets -# - Auto EEPROM upload with isp mode: ISP_EEPROM option. -# - Allow custom OBJDIR +# Refer to HISTORY.md file for complete history of changes # ######################################################################## # From dc3ec57330848e151f9a31017cb572682a30116b Mon Sep 17 00:00:00 2001 From: Sudar Date: Fri, 31 May 2013 09:42:44 +0530 Subject: [PATCH 16/21] Added information about the changes that went in v0.10.4 --- HISTORY.md | 8 ++++++++ README.md | 16 ++++++++++++---- arduino-mk/Arduino.mk | 4 ++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index ed99dcb..d5fa3fc 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,14 @@ A Makefile for Arduino Sketches 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.10.4 (2013-05-31) @matthijskooijman +- Improved BAUD_RATE detection logic +- Added logic to check if there is only .ino or .pde file +- Compile .ino/.pde files directly +- Output configuration only once +- Try to read Version.txt file only if it is present +- Refactored dependency code + ### 0.10.3 16.xii 2012 gaftech - Enabling creation of EEPROM file (.eep) - EEPROM upload: eeprom and raw_eeprom targets diff --git a/README.md b/README.md index 5944f81..a8585db 100644 --- a/README.md +++ b/README.md @@ -59,14 +59,22 @@ is set to `$HOME/sketchbook`. ## Versioning -The current version of the makefile is `0.10.3`. You can find the full history in the [HISTORY.md](HISTORY.md) file +The current version of the makefile is `0.10.4`. You can find the full history in the [HISTORY.md](HISTORY.md) file This project adheres to Semantic [Versioning 2.0](http://semver.org/). +## Contribution + +All contributions (even documentation) are welcome :) Open a pull request and I would be happy to merge them. + +If you are looking for ideas to work on, then check out the following TODO items. + ## Know Issues / TODO's -- Doesn't work with Leonardo yet. -- More todo's at https://github.com/sudar/Arduino-Makefile/issues/ -- Because of the way the makefile is structured, the configuration parameters gets printed twice. + +- Doesn't work with Leonardo yet. There are various fixes (#43, #37, #30) but need to verify them #44. +- Doesn't work with Arduino 1.5.x yet. + +If you find an issue or have an idea for a feature then log them 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). diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index b52ed45..8d43c9b 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -1,6 +1,6 @@ ######################################################################## # -# Arduino command line tools Makefile +# Makefile for compiling Arduino sketches from command line # System part (i.e. project independent) # # Copyright (C) 2012 Sudar , based on @@ -19,7 +19,7 @@ # # Original Arduino adaptation by mellis, eighthave, oli.keller # -# Current version: 0.10.3 +# Current version: 0.10.4 # # Refer to HISTORY.md file for complete history of changes # From cd210f96ca9812ea36dfca7c36d58ac0f754ed05 Mon Sep 17 00:00:00 2001 From: Sudar Date: Fri, 31 May 2013 16:57:25 +0530 Subject: [PATCH 17/21] Added a todo comment for package authors. Fixes #50 --- bin/ard-parse-boards | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/ard-parse-boards b/bin/ard-parse-boards index 2e975bb..fba6e67 100755 --- a/bin/ard-parse-boards +++ b/bin/ard-parse-boards @@ -7,6 +7,9 @@ use Getopt::Long; use Pod::Usage; use YAML; +# TODO: If you writing an installation script or a package for the makefile, +# then you might want to replace the below path based on the environment. +# More discussion at https://github.com/sudar/Arduino-Makefile/issues/50 my %Opt = ( boards_txt => '/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt', From 47b2dca1efbee57218d5a3942f8614974136c0ed Mon Sep 17 00:00:00 2001 From: Sudar Date: Fri, 31 May 2013 17:05:47 +0530 Subject: [PATCH 18/21] Add USB_VID and USB_PID to CPPFLAGS only if the board is Leonardo. Fixes #43 and fixes #51 --- HISTORY.md | 3 +++ arduino-mk/Arduino.mk | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index d5fa3fc..f40fa04 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,9 @@ A Makefile for Arduino Sketches 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.10.5 (in development) +- Add USB_VID and USB_PID to CPPFLAGS only if the board is Leonardo. + ### 0.10.4 (2013-05-31) @matthijskooijman - Improved BAUD_RATE detection logic - Added logic to check if there is only .ino or .pde file diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 8d43c9b..e5d9c76 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -428,11 +428,11 @@ endif ifeq ($(VARIANT),leonardo) # USB IDs for the Leonardo ifndef USB_VID -USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid) +USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid 2>/dev/null) endif ifndef USB_PID -USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid) +USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid 2>/dev/null) endif endif @@ -624,8 +624,13 @@ DEPS = $(LOCAL_OBJS:.o=.d) $(LIB_OBJS:.o=.d) $(USER_LIB_OBJS:.o=.d) $ 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 -Wall \ - -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) \ -ffunction-sections -fdata-sections + +# USB IDs for the Leonardo +ifeq ($(VARIANT),leonardo) + CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) +endif + CFLAGS += -std=gnu99 $(EXTRA_FLAGS) $(EXTRA_CFLAGS) CXXFLAGS += -fno-exceptions $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS) ASFLAGS += -mmcu=$(MCU) -I. -x assembler-with-cpp From d1b6fe3cdf554d1e95ccdd8c380536dcd1434d63 Mon Sep 17 00:00:00 2001 From: Sudar Date: Fri, 31 May 2013 17:43:00 +0530 Subject: [PATCH 19/21] Formatting and typo fixes --- arduino-mk/Arduino.mk | 60 +++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index e5d9c76..3d83809 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -231,7 +231,6 @@ show_config_variable = $(call show_config_info,$(1) = $($(1)) $(3),$(2)) # Just a nice simple visual separator show_separator = $(call arduino_output,-------------------------) - $(call show_separator) $(call arduino_output,Arduino.mk Configuration:) @@ -258,7 +257,6 @@ 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 VERSION_FILE := $(ARDUINO_DIR)/lib/version.txt @@ -299,7 +297,6 @@ ifdef ARDUINO_DIR endif # BUNDLED_AVR_TOOLS_DIR else - $(call show_config_variable,AVR_TOOLS_DIR) endif #ndef AVR_TOOLS_DIR @@ -315,11 +312,9 @@ else endif ifdef AVR_TOOLS_DIR - ifndef AVR_TOOLS_PATH AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin endif - endif ######################################################################## @@ -346,7 +341,7 @@ endif ######################################################################## -# Miscellanea +# Miscellaneous # ifndef ARDUINO_SKETCHBOOK ifneq ($(wildcard $(HOME)/.arduino/preferences.txt),) @@ -381,6 +376,7 @@ endif ######################################################################## # Reset +# ifndef RESET_CMD RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino $(ARD_RESET_OPTS) endif @@ -426,14 +422,14 @@ ifndef F_CPU endif ifeq ($(VARIANT),leonardo) -# USB IDs for the Leonardo -ifndef USB_VID -USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid 2>/dev/null) -endif + # USB IDs for the Leonardo + ifndef USB_VID + USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid 2>/dev/null) + endif -ifndef USB_PID -USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid 2>/dev/null) -endif + ifndef USB_PID + USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid 2>/dev/null) + endif endif # normal programming info @@ -468,11 +464,11 @@ endif # Everything gets built in here (include BOARD_TAG now) ifndef OBJDIR -OBJDIR = build-$(BOARD_TAG) + OBJDIR = build-$(BOARD_TAG) endif ifndef HEX_MAXIMUM_SIZE -HEX_MAXIMUM_SIZE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.maximum_size) + HEX_MAXIMUM_SIZE = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) upload.maximum_size) endif ######################################################################## @@ -493,6 +489,7 @@ LOCAL_OBJ_FILES = $(LOCAL_C_SRCS:.c=.o) $(LOCAL_CPP_SRCS:.cpp=.o) \ LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES)) ifneq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 1) + #TODO: Support more than one file. https://github.com/sudar/Arduino-Makefile/issues/49 $(error Need exactly one .pde or .ino file) endif @@ -534,7 +531,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 + # This works only in linux. TODO: Port it to MAC OS also + # https://github.com/sudar/Arduino-Makefile/issues/52 SPEED = $(shell grep --max-count=1 --regexp="Serial.begin" $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | 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) @@ -555,14 +553,14 @@ endif ######################################################################## # Include file to use for old .pde files # -ifndef PDE_INCLUDE - # We should check for Arduino version, if the file is .pde because a - # .pde file might be used in Arduino 1.0 - ifeq ($(shell expr $(ARDUINO_VERSION) '<' 100), 1) - PDE_INCLUDE=WProgram.h - else - PDE_INCLUDE=Arduino.h - endif +ifndef ARDUINO_HEADER + # We should check for Arduino version, if the file is .pde because a + # .pde file might be used in Arduino 1.0 + ifeq ($(shell expr $(ARDUINO_VERSION) '<' 100), 1) + ARDUINO_HEADER=WProgram.h + else + ARDUINO_HEADER=Arduino.h + endif endif ######################################################################## @@ -658,6 +656,7 @@ ifneq (,$(strip $(ARDUINO_LIBS))) $(call arduino_output,-) $(call show_config_info,ARDUINO_LIBS =) endif + ifneq (,$(strip $(USER_LIB_NAMES))) $(foreach lib,$(USER_LIB_NAMES),$(call show_config_info, $(lib),[USER])) endif @@ -669,7 +668,6 @@ endif # end of config output $(call show_separator) - # Implicit rules for building everything (needed to get everything in # the right directory) # @@ -710,7 +708,7 @@ $(OBJDIR)/%.o: %.s $(COMMON_DEPS) | $(OBJDIR) # the pde -> o file $(OBJDIR)/%.o: %.pde | $(OBJDIR) - $(CXX) -x c++ -include $(PDE_INCLUDE) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ + $(CXX) -x c++ -include $(ARDUINO_HEADER) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # the ino -> o file $(OBJDIR)/%.o: %.ino | $(OBJDIR) @@ -756,11 +754,11 @@ ifndef 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 + 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) From 722238b95ed19e24fae9281bcbb32431424d1c59 Mon Sep 17 00:00:00 2001 From: Sudar Date: Sun, 2 Jun 2013 21:33:42 +0530 Subject: [PATCH 20/21] Reformatted file and changed some wrong tabs into spaces --- arduino-mk/Arduino.mk | 94 +++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index d58ea4a..8eddb14 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -304,12 +304,12 @@ ifdef ARDUINO_DIR $(call show_config_variable,ARDUINO_LIB_PATH,[COMPUTED],(from ARDUINO_DIR)) ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino - ifndef ARDUINO_VAR_PATH - ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants - $(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ARDUINO_DIR)) - else - $(call show_config_variable,ARDUINO_VAR_PATH,[USER]) - endif + ifndef ARDUINO_VAR_PATH + ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/arduino/variants + $(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ARDUINO_DIR)) + else + $(call show_config_variable,ARDUINO_VAR_PATH,[USER]) + endif else @@ -428,14 +428,14 @@ ifndef F_CPU endif ifeq ($(VARIANT),leonardo) - # USB IDs for the Leonardo - ifndef USB_VID - USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid 2>/dev/null) - endif + # USB IDs for the Leonardo + ifndef USB_VID + USB_VID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.vid 2>/dev/null) + endif - ifndef USB_PID - USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid 2>/dev/null) - endif + ifndef USB_PID + USB_PID = $(shell $(PARSE_BOARD_CMD) $(BOARD_TAG) build.pid 2>/dev/null) + endif endif # normal programming info @@ -512,7 +512,7 @@ ifeq ($(strip $(NO_CORE)),) CORE_OBJ_FILES = $(CORE_C_SRCS:.c=.o) $(CORE_CPP_SRCS:.cpp=.o) CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \ - $(OBJDIR)/%,$(CORE_OBJ_FILES)) + $(OBJDIR)/%,$(CORE_OBJ_FILES)) endif else $(call show_config_info,NO_CORE set so core library will not be built,[MANUAL]) @@ -537,17 +537,17 @@ endif # for more information (search for 'character special device'). # ifndef MONITOR_BAUDRATE - # This works only in linux. TODO: Port it to MAC OS also - # https://github.com/sudar/Arduino-Makefile/issues/52 - SPEED = $(shell grep --max-count=1 --regexp="Serial.begin" $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | 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) + # This works only in linux. TODO: Port it to MAC OS also + # https://github.com/sudar/Arduino-Makefile/issues/52 + SPEED = $(shell grep --max-count=1 --regexp="Serial.begin" $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | 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),) - MONITOR_BAUDRATE = 9600 - $(call show_config_variable,MONITOR_BAUDRATE,[ASSUMED]) - else - $(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch)) - endif + ifeq ($(MONITOR_BAUDRATE),) + MONITOR_BAUDRATE = 9600 + $(call show_config_variable,MONITOR_BAUDRATE,[ASSUMED]) + else + $(call show_config_variable,MONITOR_BAUDRATE,[DETECTED], (in sketch)) + endif else $(call show_config_variable,MONITOR_BAUDRATE, [SPECIFIED]) endif @@ -560,13 +560,13 @@ endif # Include file to use for old .pde files # ifndef ARDUINO_HEADER - # We should check for Arduino version, if the file is .pde because a - # .pde file might be used in Arduino 1.0 - ifeq ($(shell expr $(ARDUINO_VERSION) '<' 100), 1) - ARDUINO_HEADER=WProgram.h - else - ARDUINO_HEADER=Arduino.h - endif + # We should check for Arduino version, if the file is .pde because a + # .pde file might be used in Arduino 1.0 + ifeq ($(shell expr $(ARDUINO_VERSION) '<' 100), 1) + ARDUINO_HEADER=WProgram.h + else + ARDUINO_HEADER=Arduino.h + endif endif ######################################################################## @@ -617,22 +617,22 @@ LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(SYS_LIBS))) USER_LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(USER_LIBS))) USER_LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(USER_LIBS))) LIB_OBJS = $(patsubst $(ARDUINO_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(LIB_C_SRCS)) \ - $(patsubst $(ARDUINO_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(LIB_CPP_SRCS)) + $(patsubst $(ARDUINO_LIB_PATH)/%.cpp,$(OBJDIR)/libs/%.o,$(LIB_CPP_SRCS)) 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)) + $(patsubst $(USER_LIB_PATH)/%.c,$(OBJDIR)/libs/%.o,$(USER_LIB_C_SRCS)) # Dependency files DEPS = $(LOCAL_OBJS:.o=.d) $(LIB_OBJS:.o=.d) $(USER_LIB_OBJS:.o=.d) $(CORE_OBJS:.o=.d) # 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 -Wall \ - -ffunction-sections -fdata-sections + -I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ + $(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -Wall \ + -ffunction-sections -fdata-sections # USB IDs for the Leonardo ifeq ($(VARIANT),leonardo) - CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) + CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) endif CFLAGS += -std=gnu99 $(EXTRA_FLAGS) $(EXTRA_CFLAGS) @@ -657,7 +657,6 @@ else $(call show_config_info,Size utility: Basic (not AVR-aware),[AUTODETECTED]) endif - ifneq (,$(strip $(ARDUINO_LIBS))) $(call arduino_output,-) $(call show_config_info,ARDUINO_LIBS =) @@ -765,11 +764,11 @@ ifndef 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 + 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 file endif AVRDUDE_COM_OPTS = -q -V -p $(MCU) @@ -780,25 +779,26 @@ endif AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P $(call get_arduino_port) ifndef ISP_PROG - ISP_PROG = -c stk500v2 + ISP_PROG = -c stk500v2 endif # usb seems to be a reasonable default, at least on linux ifndef ISP_PORT - ISP_PORT = usb + ISP_PORT = usb endif AVRDUDE_ISP_OPTS = -P $(ISP_PORT) $(ISP_PROG) ifndef ISP_EEPROM - ISP_EEPROM = 0 + ISP_EEPROM = 0 endif AVRDUDE_UPLOAD_HEX = -U flash:w:$(TARGET_HEX):i AVRDUDE_UPLOAD_EEP = -U eeprom:w:$(TARGET_EEP):i AVRDUDE_ISPLOAD_OPTS = $(AVRDUDE_UPLOAD_HEX) + ifneq ($(ISP_EEPROM), 0) - AVRDUDE_ISPLOAD_OPTS += $(AVRDUDE_UPLOAD_EEP) + AVRDUDE_ISPLOAD_OPTS += $(AVRDUDE_UPLOAD_EEP) endif ######################################################################## From 11a416e9e996453fe08e2eea468d2c3c48a719d4 Mon Sep 17 00:00:00 2001 From: Sudar Date: Thu, 6 Jun 2013 07:56:08 +0530 Subject: [PATCH 21/21] Fixed some typos in comments --- 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 8eddb14..039365a 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -249,7 +249,7 @@ endif ######################################################################## # -# Default TARGET to cwd (ex Daniele Vergini) +# Default TARGET to pwd (ex Daniele Vergini) ifndef TARGET TARGET = $(notdir $(CURDIR)) endif @@ -808,11 +808,11 @@ endif all: $(TARGET_EEP) $(TARGET_HEX) verify_size -# Rule to create $(OBJDIR) automaticallly. All rules with recipes that +# Rule to create $(OBJDIR) automatically. All rules with recipes that # create a file within it, but do not already depend on a file within it # should depend on this rule. They should use a "order-only -# prerequisite" (e.g., put "| $(OBJDIR)" at the end of the prequisite -# list) to prevent remaking the target when any file in th directory +# prerequisite" (e.g., put "| $(OBJDIR)" at the end of the prerequisite +# list) to prevent remaking the target when any file in the directory # changes. $(OBJDIR): mkdir $(OBJDIR)