pax_global_header00006660000000000000000000000064122741620460014516gustar00rootroot0000000000000052 comment=e48ae82fbdf32271229c3d0c0bfd6ae9ee70ea66 Arduino-Makefile-1.3.1/000077500000000000000000000000001227416204600146345ustar00rootroot00000000000000Arduino-Makefile-1.3.1/.gitignore000066400000000000000000000000301227416204600166150ustar00rootroot00000000000000*.o build-cli /.project Arduino-Makefile-1.3.1/Arduino.mk000066400000000000000000001235171227416204600165770ustar00rootroot00000000000000######################################################################## # # Makefile for compiling Arduino sketches from command line # 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. # # 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 # License, or (at your option) any later version. # # Adapted from Arduino 0011 Makefile by M J Oldfield # # Original Arduino adaptation by mellis, eighthave, oli.keller # # Current version: 1.3.1 # # Refer to HISTORY.md file for complete history of changes # ######################################################################## # # PATHS YOU NEED TO SET UP # # We need to worry about three different sorts of file: # # 1. The directory where the *.mk files are stored # => 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/share/arduino # 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'd rather not see the configuration output, define ARDUINO_QUIET. # ######################################################################## # # DEPENDENCIES # # The Perl programs need a couple of libraries: # Device::SerialPort # ######################################################################## # # STANDARD ARDUINO WORKFLOW # # Given a normal sketch directory, all you need to do is to create # a small Makefile which defines a few things, and then includes this one. # # For example: # # ARDUINO_LIBS = Ethernet SPI # BOARD_TAG = uno # MONITOR_PORT = /dev/cu.usb* # # include /usr/share/arduino/Arduino.mk # # 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 # or your sketchbook's libraries directory) # # MONITOR_PORT - The port where the Arduino can be found (only needed # when uploading) # # BOARD_TAG - The tag for the board e.g. uno or mega # 'make show_boards' shows a list # # 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 # # In any case, once this file has been created the typical workflow is just # # $ make upload # # All of the object files are created in the build-{BOARD_TAG} subdirectory # All sources should be in the current directory and can include: # - at most one .pde or .ino file which will be treated as C++ after # the standard Arduino header and footer have been affixed. # - any number of .c, .cpp, .s and .h files # # Included libraries are built in the build-{BOARD_TAG}/libs subdirectory. # # Besides make upload, there are a couple of other targets that are available. # Do make help to get the complete list of targets and their description # ######################################################################## # # SERIAL MONITOR # # The serial monitor just invokes the GNU screen program with suitable # 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! # # The fairly useful thing to know is that you can bind another key to # escape too, by creating $HOME{.screenrc} containing e.g. # # 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 # from the sketch, then it defaults to 9600 baud. # ######################################################################## # # ARDUINO WITH ISP # # You need to specify some details of your ISP programmer and might # also need to specify the fuse values: # # ISP_PROG = stk500v2 # ISP_PORT = /dev/ttyACM0 # # 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 # ISP_LOW_FUSE = 0xff # ISP_EXT_FUSE = 0x01 # # You can specify to also upload the EEPROM file: # ISP_EEPROM = 1 # # 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 # # ######################################################################## # # ALTERNATIVE CORES # # To use alternative cores for platforms such as ATtiny, you need to # specify a few more variables, depending on the core in use. # # The HLT (attiny-master) core can be used just by specifying # ALTERNATE_CORE, assuming your core is in your ~/sketchbook/hardware # directory. For example: # # ISP_PORT = /dev/ttyACM0 # BOARD_TAG = attiny85 # ALTERNATE_CORE = attiny-master # # To use the more complex arduino-tiny and TinyCore2 cores, you must # also set ARDUINO_CORE_PATH and ARDUINO_VAR_PATH to the core # directory, as these cores essentially replace the main Arduino core. # For example: # # ISP_PORT = /dev/ttyACM0 # BOARD_TAG = attiny85at8 # ALTERNATE_CORE = arduino-tiny # ARDUINO_VAR_PATH = ~/sketchbook/hardware/arduino-tiny/cores/tiny # ARDUINO_CORE_PATH = ~/sketchbook/hardware/arduino-tiny/cores/tiny # # or.... # # ISP_PORT = /dev/ttyACM0 # BOARD_TAG = attiny861at8 # ALTERNATE_CORE = tiny2 # ARDUINO_VAR_PATH = ~/sketchbook/hardware/tiny2/cores/tiny # ARDUINO_CORE_PATH = ~/sketchbook/hardware/tiny2/cores/tiny # ######################################################################## 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 ifeq ($(MAKE_RESTARTS),) ifeq ($(MAKELEVEL),0) arduino_output = $(info $(1)) endif endif endif ######################################################################## # Makefile distribution path ifndef ARDMK_DIR # presume it's the same path to our own file ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))) else # show_config_variable macro is defined in Common.mk file and is not available yet. # Let's define a variable to know that user specified ARDMK_DIR ARDMK_DIR_MSG = USER endif # include Common.mk now we know where it is include $(ARDMK_DIR)/Common.mk # show_config_variable macro is available now. So let's print config details for ARDMK_DIR ifndef ARDMK_DIR_MSG $(call show_config_variable,ARDMK_DIR,[COMPUTED],(relative to $(notdir $(lastword $(MAKEFILE_LIST))))) else $(call show_config_variable,ARDMK_DIR,[USER]) endif ######################################################################## # Arduino Directory ifndef 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_variable,ARDUINO_DIR,[AUTODETECTED]) else echo $(error "ARDUINO_DIR is not defined") endif else $(call show_config_variable,ARDUINO_DIR,[USER]) endif ######################################################################## # Default TARGET to pwd (ex Daniele Vergini) ifndef TARGET TARGET = $(notdir $(CURDIR)) 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 AUTO_ARDUINO_VERSION := $(shell [ -e $(VERSION_FILE) ] && cat $(VERSION_FILE) | sed -e 's/^[0-9]://g' -e 's/[.]//g' -e 's/$$/0000/' | head -c3) ifdef AUTO_ARDUINO_VERSION ARDUINO_VERSION = $(AUTO_ARDUINO_VERSION) $(call show_config_variable,ARDUINO_VERSION,[AUTODETECTED]) else ARDUINO_VERSION = 100 $(call show_config_variable,ARDUINO_VERSION,[DEFAULT]) endif else $(call show_config_variable,ARDUINO_VERSION,[USER]) endif ######################################################################## # Arduino Sketchbook folder ifndef ARDUINO_SKETCHBOOK ifndef ARDUINO_PREFERENCES_PATH AUTO_ARDUINO_PREFERENCES := $(firstword \ $(call dir_if_exists,$(HOME)/.arduino/preferences.txt) \ $(call dir_if_exists,$(HOME)/Library/Arduino/preferences.txt) ) ifdef AUTO_ARDUINO_PREFERENCES ARDUINO_PREFERENCES_PATH = $(AUTO_ARDUINO_PREFERENCES) $(call show_config_variable,ARDUINO_PREFERENCES_PATH,[AUTODETECTED]) endif else $(call show_config_variable,ARDUINO_PREFERENCES_PATH,[USER]) endif ifneq ($(ARDUINO_PREFERENCES_PATH),) ARDUINO_SKETCHBOOK = $(shell grep --max-count=1 --regexp="sketchbook.path=" \ $(ARDUINO_PREFERENCES_PATH) | \ sed -e 's/sketchbook.path=//' ) endif ifneq ($(ARDUINO_SKETCHBOOK),) $(call show_config_variable,ARDUINO_SKETCHBOOK,[AUTODETECTED],(from arduino preferences file)) else ARDUINO_SKETCHBOOK = $(HOME)/sketchbook $(call show_config_variable,ARDUINO_SKETCHBOOK,[DEFAULT]) endif else $(call show_config_variable,ARDUINO_SKETCHBOOK,[USER]) endif ######################################################################## # Arduino and system paths ifndef CC_NAME CC_NAME = avr-gcc endif ifndef CXX_NAME CXX_NAME = avr-g++ endif ifndef OBJCOPY_NAME OBJCOPY_NAME = avr-objcopy endif ifndef OBJDUMP_NAME OBJDUMP_NAME = avr-objdump endif ifndef AR_NAME AR_NAME = avr-ar endif ifndef SIZE_NAME SIZE_NAME = avr-size endif ifndef NM_NAME NM_NAME = avr-nm endif 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) $(call show_config_variable,AVR_TOOLS_DIR,[BUNDLED],(in Arduino distribution)) # In Linux distribution of Arduino, the path to avrdude and avrdude.conf are different # More details at https://github.com/sudar/Arduino-Makefile/issues/48 and # https://groups.google.com/a/arduino.cc/d/msg/developers/D_m97jGr8Xs/uQTt28KO_8oJ ifeq ($(CURRENT_OS),LINUX) ifndef AVRDUDE AVRDUDE = $(AVR_TOOLS_DIR)/../avrdude endif ifndef AVRDUDE_CONF AVRDUDE_CONF = $(AVR_TOOLS_DIR)/../avrdude.conf endif else ifndef AVRDUDE_CONF AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf endif endif else SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which $(CC_NAME)))/..)) ifdef SYSTEMPATH_AVR_TOOLS_DIR AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR) $(call show_config_variable,AVR_TOOLS_DIR,[AUTODETECTED],(found in $$PATH)) else echo $(error No AVR tools directory found) endif # SYSTEMPATH_AVR_TOOLS_DIR endif # BUNDLED_AVR_TOOLS_DIR else $(call show_config_variable,AVR_TOOLS_DIR,[USER]) endif #ndef AVR_TOOLS_DIR ifndef AVR_TOOLS_PATH AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin endif ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries $(call show_config_variable,ARDUINO_LIB_PATH,[COMPUTED],(from ARDUINO_DIR)) ifndef ARDUINO_CORE_PATH ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/arduino/cores/arduino $(call show_config_variable,ARDUINO_CORE_PATH,[DEFAULT]) else $(call show_config_variable,ARDUINO_CORE_PATH,[USER]) endif # Third party hardware and core like ATtiny or ATmega 16 ifdef ALTERNATE_CORE $(call show_config_variable,ALTERNATE_CORE,[USER]) ifndef ALTERNATE_CORE_PATH ALTERNATE_CORE_PATH = $(ARDUINO_SKETCHBOOK)/hardware/$(ALTERNATE_CORE) endif endif ifdef ALTERNATE_CORE_PATH ifdef ALTERNATE_CORE $(call show_config_variable,ALTERNATE_CORE_PATH,[COMPUTED], (from ARDUINO_SKETCHBOOK and ALTERNATE_CORE)) else $(call show_config_variable,ALTERNATE_CORE_PATH,[USER]) endif ifndef ARDUINO_VAR_PATH ARDUINO_VAR_PATH = $(ALTERNATE_CORE_PATH)/variants $(call show_config_variable,ARDUINO_VAR_PATH,[COMPUTED],(from ALTERNATE_CORE_PATH)) endif ifndef BOARDS_TXT BOARDS_TXT = $(ALTERNATE_CORE_PATH)/boards.txt $(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ALTERNATE_CORE_PATH)) endif else 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 BOARDS_TXT BOARDS_TXT = $(ARDUINO_DIR)/hardware/arduino/boards.txt $(call show_config_variable,BOARDS_TXT,[COMPUTED],(from ARDUINO_DIR)) else $(call show_config_variable,BOARDS_TXT,[USER]) endif endif ######################################################################## # Miscellaneous ifndef USER_LIB_PATH USER_LIB_PATH = $(ARDUINO_SKETCHBOOK)/libraries $(call show_config_variable,USER_LIB_PATH,[DEFAULT],(in user sketchbook)) else $(call show_config_variable,USER_LIB_PATH,[USER]) endif ######################################################################## # boards.txt parsing ifndef BOARD_TAG BOARD_TAG = uno $(call show_config_variable,BOARD_TAG,[DEFAULT]) else # Strip the board tag of any extra whitespace, since it was causing the makefile to fail # https://github.com/sudar/Arduino-Makefile/issues/57 BOARD_TAG := $(strip $(BOARD_TAG)) $(call show_config_variable,BOARD_TAG,[USER]) endif ifndef PARSE_BOARD # result = $(call READ_BOARD_TXT, 'boardname', 'parameter') PARSE_BOARD = $(shell grep -v "^\#" $(BOARDS_TXT) | grep $(1).$(2) | cut -d = -f 2 ) endif # If NO_CORE is set, then we don't have to parse boards.txt file # But the user might have to define MCU, F_CPU etc ifeq ($(strip $(NO_CORE)),) # Which variant ? This affects the include path ifndef VARIANT VARIANT = $(call PARSE_BOARD,$(BOARD_TAG),build.variant) endif # see if we are a caterina device like leonardo or micro CATERINA = $(findstring caterina,$(call PARSE_BOARD,$(BOARD_TAG),bootloader.path)) # processor stuff ifndef MCU MCU = $(call PARSE_BOARD,$(BOARD_TAG),build.mcu) endif ifndef F_CPU F_CPU = $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu) endif ifneq ($(CATERINA),) # USB IDs for the caterina devices like leonardo or micro ifndef USB_VID USB_VID = $(call PARSE_BOARD,$(BOARD_TAG),build.vid) endif ifndef USB_PID USB_PID = $(call PARSE_BOARD,$(BOARD_TAG),build.pid) endif endif # normal programming info ifndef AVRDUDE_ARD_PROGRAMMER AVRDUDE_ARD_PROGRAMMER = $(call PARSE_BOARD,$(BOARD_TAG),upload.protocol) endif ifndef AVRDUDE_ARD_BAUDRATE AVRDUDE_ARD_BAUDRATE = $(call PARSE_BOARD,$(BOARD_TAG),upload.speed) endif # fuses if you're using e.g. ISP ifndef ISP_LOCK_FUSE_PRE ISP_LOCK_FUSE_PRE = $(call PARSE_BOARD,$(BOARD_TAG),bootloader.unlock_bits) endif ifndef ISP_HIGH_FUSE ISP_HIGH_FUSE = $(call PARSE_BOARD,$(BOARD_TAG),bootloader.high_fuses) endif ifndef ISP_LOW_FUSE ISP_LOW_FUSE = $(call PARSE_BOARD,$(BOARD_TAG),bootloader.low_fuses) endif ifndef ISP_EXT_FUSE ISP_EXT_FUSE = $(call PARSE_BOARD,$(BOARD_TAG),bootloader.extended_fuses) endif ifndef BOOTLOADER_PATH BOOTLOADER_PATH = $(call PARSE_BOARD,$(BOARD_TAG),bootloader.path) endif ifndef BOOTLOADER_FILE BOOTLOADER_FILE = $(call PARSE_BOARD,$(BOARD_TAG),bootloader.file) endif ifndef ISP_LOCK_FUSE_POST ISP_LOCK_FUSE_POST = $(call PARSE_BOARD,$(BOARD_TAG),bootloader.lock_bits) endif ifndef HEX_MAXIMUM_SIZE HEX_MAXIMUM_SIZE = $(call PARSE_BOARD,$(BOARD_TAG),upload.maximum_size) endif endif # Everything gets built in here (include BOARD_TAG now) ifndef OBJDIR OBJDIR = build-$(BOARD_TAG) $(call show_config_variable,OBJDIR,[COMPUTED],(from BOARD_TAG)) else $(call show_config_variable,OBJDIR,[USER]) endif ######################################################################## # Reset ifndef RESET_CMD ARD_RESET_ARDUINO := $(shell which ard-reset-arduino 2> /dev/null) ifndef ARD_RESET_ARDUINO # same level as *.mk in bin directory when checked out from git # or in $PATH when packaged ARD_RESET_ARDUINO = $(ARDMK_DIR)/bin/ard-reset-arduino endif ifneq ($(CATERINA),) RESET_CMD = $(ARD_RESET_ARDUINO) --caterina $(ARD_RESET_OPTS) $(call get_monitor_port) else RESET_CMD = $(ARD_RESET_ARDUINO) $(ARD_RESET_OPTS) $(call get_monitor_port) endif endif ifneq ($(CATERINA),) ERROR_ON_CATERINA = $(error On $(BOARD_TAG), raw_xxx operation is not supported) else ERROR_ON_CATERINA = endif ######################################################################## # 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_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) LOCAL_OBJS = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES)) ifeq ($(words $(LOCAL_SRCS)), 0) $(error Atleast one source file (*.ino, *.pde, *.cpp, *c, *cc, *.S) is needed) endif ifeq ($(strip $(NO_CORE)),) # Ideally, this should just check if there are more than one file ifneq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 1) ifeq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 0) $(call show_config_info,No .pde or .ino files found. If you are compiling .c or .cpp files then you need to explicitly include Arduino header files) else #TODO: Support more than one file. https://github.com/sudar/Arduino-Makefile/issues/49 $(error Need exactly one .pde or .ino file. This makefile doesn't support multiple .ino/.pde files yet) endif endif endif # 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) ifneq ($(strip $(NO_CORE_MAIN_CPP)),) CORE_CPP_SRCS := $(filter-out %main.cpp, $(CORE_CPP_SRCS)) $(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) $(CORE_AS_SRCS:.S=.o) CORE_OBJS = $(patsubst $(ARDUINO_CORE_PATH)/%, \ $(OBJDIR)/%,$(CORE_OBJ_FILES)) endif 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))) ARDUINO_LIBS += $(filter $(notdir $(wildcard $(USER_LIB_PATH)/*)), \ $(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'). ifeq ($(strip $(NO_CORE)),) ifndef MONITOR_BAUDRATE ifeq ($(words $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS)), 1) SPEED = $(shell egrep -h 'Serial.begin\([0-9]+\)' $(LOCAL_PDE_SRCS) $(LOCAL_INO_SRCS) | sed -e 's/[^0-9]//g'| head -n1) MONITOR_BAUDRATE = $(findstring $(SPEED),300 1200 2400 4800 9600 14400 19200 28800 38400 57600 115200) 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, [USER]) endif ifndef MONITOR_CMD MONITOR_CMD = screen endif endif ######################################################################## # Include Arduino Header file ifndef ARDUINO_HEADER # We should check for Arduino version, not just the file extension # because, a .pde file can be used in Arduino 1.0 as well ifeq ($(shell expr $(ARDUINO_VERSION) '<' 100), 1) ARDUINO_HEADER=WProgram.h else ARDUINO_HEADER=Arduino.h endif endif ######################################################################## # Rules for making stuff # 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 # Names of executables - chipKIT needs to override all to set paths to PIC32 # tools, and we can't use "?=" assignment because these are already implicitly # defined by Make (e.g. $(CC) == cc). ifndef OVERRIDE_EXECUTABLES CC = $(AVR_TOOLS_PATH)/$(CC_NAME) CXX = $(AVR_TOOLS_PATH)/$(CXX_NAME) AS = $(AVR_TOOLS_PATH)/$(AS_NAME) OBJCOPY = $(AVR_TOOLS_PATH)/$(OBJCOPY_NAME) OBJDUMP = $(AVR_TOOLS_PATH)/$(OBJDUMP_NAME) AR = $(AVR_TOOLS_PATH)/$(AR_NAME) SIZE = $(AVR_TOOLS_PATH)/$(SIZE_NAME) NM = $(AVR_TOOLS_PATH)/$(NM_NAME) endif REMOVE = rm -rf MV = mv -f CAT = cat ECHO = printf MKDIR = mkdir -p # General arguments 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_LIBS := $(wildcard $(SYS_LIBS) $(addsuffix /utility,$(SYS_LIBS))) USER_LIBS := $(wildcard $(USER_LIBS) $(addsuffix /utility,$(USER_LIBS))) SYS_INCLUDES = $(patsubst %,-I%,$(SYS_LIBS)) USER_INCLUDES = $(patsubst %,-I%,$(USER_LIBS)) LIB_C_SRCS = $(wildcard $(patsubst %,%/*.c,$(SYS_LIBS))) LIB_CPP_SRCS = $(wildcard $(patsubst %,%/*.cpp,$(SYS_LIBS))) 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)) 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) # Optimization level for the compiler. # You can get the list of options at http://www.nongnu.org/avr-libc/user-manual/using_tools.html#gcc_optO # Also read http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_optflags ifndef OPTIMIZATION_LEVEL OPTIMIZATION_LEVEL=s $(call show_config_variable,OPTIMIZATION_LEVEL,[DEFAULT]) else $(call show_config_variable,OPTIMIZATION_LEVEL,[USER]) endif ifndef DEBUG_FLAGS DEBUG_FLAGS = -O0 -g endif # SoftwareSerial requires -Os (some delays are tuned for this optimization level) %SoftwareSerial.o : OPTIMIZATION_FLAGS = -Os ifndef MCU_FLAG_NAME MCU_FLAG_NAME = mmcu $(call show_config_variable,MCU_FLAG_NAME,[DEFAULT]) else $(call show_config_variable,MCU_FLAG_NAME,[USER]) endif # Using += instead of =, so that CPPFLAGS can be set per sketch level CPPFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \ -I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \ $(SYS_INCLUDES) $(USER_INCLUDES) -Wall -ffunction-sections \ -fdata-sections ifdef DEBUG OPTIMIZATION_FLAGS= $(DEBUG_FLAGS) else OPTIMIZATION_FLAGS = -O$(OPTIMIZATION_LEVEL) endif CPPFLAGS += $(OPTIMIZATION_FLAGS) # USB IDs for the Caterina devices like leonardo or micro ifneq ($(CATERINA),) CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID) endif ifndef CFLAGS_STD CFLAGS_STD = -std=gnu99 $(call show_config_variable,CFLAGS_STD,[DEFAULT]) else $(call show_config_variable,CFLAGS_STD,[USER]) endif CFLAGS += $(EXTRA_FLAGS) $(EXTRA_CFLAGS) CXXFLAGS += -fno-exceptions $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS) ASFLAGS += -x assembler-with-cpp LDFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -Wl,--gc-sections -O$(OPTIMIZATION_LEVEL) $(EXTRA_FLAGS) $(EXTRA_CXXFLAGS) $(EXTRA_LDFLAGS) SIZEFLAGS ?= --mcu=$(MCU) -C # for backwards compatibility, grab ARDUINO_PORT if the user has it set MONITOR_PORT ?= $(ARDUINO_PORT) ifeq ($(CURRENT_OS), WINDOWS) # Expect MONITOR_PORT to be '1' or 'com1' for COM1 in Windows. Split it up # into the two styles required: /dev/ttyS* for ard-reset-arduino and com* # for avrdude. This also could work with /dev/com* device names and be more # consistent, but the /dev/com* is not recommended by Cygwin and doesn't # always show up. COM_PORT_ID = $(subst com,,$(MONITOR_PORT)) COM_STYLE_MONITOR_PORT = com$(COM_PORT_ID) DEVICE_PATH = /dev/ttyS$(shell awk 'BEGIN{ print $(COM_PORT_ID) - 1 }') else DEVICE_PATH = $(MONITOR_PORT) endif # Returns the Arduino port (first wildcard expansion) if it exists, otherwise it errors. get_monitor_port = $(if $(wildcard $(DEVICE_PATH)),$(firstword $(wildcard $(DEVICE_PATH))),$(error Arduino port $(DEVICE_PATH) not found!)) # Returns the ISP port (first wildcard expansion) if it exists, otherwise it errors. get_isp_port = $(if $(wildcard $(ISP_PORT)),$(firstword $(wildcard $(ISP_PORT))),$(error ISP port $(ISP_PORT) not found!)) # 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) $(SIZEFLAGS) --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 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 ifneq (,$(strip $(SYS_LIB_NAMES))) $(foreach lib,$(SYS_LIB_NAMES),$(call show_config_info, $(lib),[SYSTEM])) endif # either calculate parent dir from arduino dir, or user-defined path ifndef BOOTLOADER_PARENT BOOTLOADER_PARENT = $(ARDUINO_DIR)/hardware/arduino/bootloaders $(call show_config_variable,BOOTLOADER_PARENT,[COMPUTED],(from ARDUINO_DIR)) else $(call show_config_variable,BOOTLOADER_PARENT,[USER]) endif # end of config output $(call show_separator) # Implicit rules for building everything (needed to get everything in # the right directory) # # Rather than mess around with VPATH there are quasi-duplicate rules # here for building e.g. a system C++ file and a local C++ # file. Besides making things simpler now, this would also make it # easy to change the build options in future # library sources $(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.c @$(MKDIR) $(dir $@) $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ $(OBJDIR)/libs/%.o: $(ARDUINO_LIB_PATH)/%.cpp @$(MKDIR) $(dir $@) $(CC) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.cpp @$(MKDIR) $(dir $@) $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ $(OBJDIR)/libs/%.o: $(USER_LIB_PATH)/%.c @$(MKDIR) $(dir $@) $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ ifdef COMMON_DEPS COMMON_DEPS := $(COMMON_DEPS) $(MAKEFILE_LIST) else COMMON_DEPS := $(MAKEFILE_LIST) endif # normal local sources $(OBJDIR)/%.o: %.c $(COMMON_DEPS) | $(OBJDIR) @$(MKDIR) $(dir $@) $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ $(OBJDIR)/%.o: %.cc $(COMMON_DEPS) | $(OBJDIR) @$(MKDIR) $(dir $@) $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(OBJDIR)/%.o: %.cpp $(COMMON_DEPS) | $(OBJDIR) @$(MKDIR) $(dir $@) $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(OBJDIR)/%.o: %.S $(COMMON_DEPS) | $(OBJDIR) @$(MKDIR) $(dir $@) $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ $(OBJDIR)/%.o: %.s $(COMMON_DEPS) | $(OBJDIR) @$(MKDIR) $(dir $@) $(CC) -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ # the pde -> o file $(OBJDIR)/%.o: %.pde $(COMMON_DEPS) | $(OBJDIR) @$(MKDIR) $(dir $@) $(CXX) -x c++ -include $(ARDUINO_HEADER) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # the ino -> o file $(OBJDIR)/%.o: %.ino $(COMMON_DEPS) | $(OBJDIR) @$(MKDIR) $(dir $@) $(CXX) -x c++ -include $(ARDUINO_HEADER) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ # generated assembly $(OBJDIR)/%.s: %.pde $(COMMON_DEPS) | $(OBJDIR) @$(MKDIR) $(dir $@) $(CXX) -x c++ -include $(ARDUINO_HEADER) -MMD -S -fverbose-asm $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(OBJDIR)/%.s: %.ino $(COMMON_DEPS) | $(OBJDIR) @$(MKDIR) $(dir $@) $(CXX) -x c++ -include $(ARDUINO_HEADER) -MMD -S -fverbose-asm $(CPPFLAGS) $(CXXFLAGS) $< -o $@ #$(OBJDIR)/%.lst: $(OBJDIR)/%.s # $(AS) -$(MCU_FLAG_NAME)=$(MCU) -alhnd $< > $@ # core files $(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.c $(COMMON_DEPS) | $(OBJDIR) @$(MKDIR) $(dir $@) $(CC) -MMD -c $(CPPFLAGS) $(CFLAGS) $< -o $@ $(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR) @$(MKDIR) $(dir $@) $(CXX) -MMD -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.S $(COMMON_DEPS) | $(OBJDIR) @$(MKDIR) $(dir $@) $(CC) -MMD -c $(CPPFLAGS) $(ASFLAGS) $< -o $@ # various object conversions $(OBJDIR)/%.hex: $(OBJDIR)/%.elf $(COMMON_DEPS) @$(MKDIR) $(dir $@) $(OBJCOPY) -O ihex -R .eeprom $< $@ @$(ECHO) '\n' $(call avr_size,$<,$@) ifneq ($(strip $(HEX_MAXIMUM_SIZE)),) @if [ `$(SIZE) $@ | awk 'FNR == 2 {print $$2}'` -le $(HEX_MAXIMUM_SIZE) ]; then touch $@.sizeok; fi else @$(ECHO) "Maximum flash memory of $(BOARD_TAG) is not specified. Make sure the size of $@ is less than $(BOARD_TAG)\'s flash memory" @touch $@.sizeok endif $(OBJDIR)/%.eep: $(OBJDIR)/%.elf $(COMMON_DEPS) @$(MKDIR) $(dir $@) -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ --change-section-lma .eeprom=0 -O ihex $< $@ $(OBJDIR)/%.lss: $(OBJDIR)/%.elf $(COMMON_DEPS) @$(MKDIR) $(dir $@) $(OBJDUMP) -h --source --demangle --wide $< > $@ $(OBJDIR)/%.sym: $(OBJDIR)/%.elf $(COMMON_DEPS) @$(MKDIR) $(dir $@) $(NM) --size-sort --demangle --reverse-sort --line-numbers $< > $@ ######################################################################## # Avrdude # If avrdude is installed separately, it can find its own config file ifndef AVRDUDE AVRDUDE = $(AVR_TOOLS_PATH)/avrdude endif # Default avrdude options # -V Do not verify # -q - suppress progress output # -D - Disable auto erase for flash memory # (-D is needed for Mega boards. See https://github.com/sudar/Arduino-Makefile/issues/114#issuecomment-25011005) ifndef AVRDUDE_OPTS AVRDUDE_OPTS = -q -V -D endif AVRDUDE_COM_OPTS = $(AVRDUDE_OPTS) -p $(MCU) ifdef AVRDUDE_CONF AVRDUDE_COM_OPTS += -C $(AVRDUDE_CONF) endif AVRDUDE_ARD_OPTS = -c $(AVRDUDE_ARD_PROGRAMMER) -b $(AVRDUDE_ARD_BAUDRATE) -P ifeq ($(CURRENT_OS), WINDOWS) # get_monitor_port checks to see if the monitor port exists, assuming it is # a file. In Windows, avrdude needs the port in the format 'com1' which is # not a file, so we have to add the COM-style port directly. AVRDUDE_ARD_OPTS += $(COM_STYLE_MONITOR_PORT) else AVRDUDE_ARD_OPTS += $(call get_monitor_port) endif ifndef ISP_PROG ifneq ($(strip $(AVRDUDE_ARD_PROGRAMMER)),) ISP_PROG = $(AVRDUDE_ARD_PROGRAMMER) else ISP_PROG = stk500v1 endif endif ifndef AVRDUDE_ISP_BAUDRATE ifneq ($(strip $(AVRDUDE_ARD_BAUDRATE)),) AVRDUDE_ISP_BAUDRATE = $(AVRDUDE_ARD_BAUDRATE) else AVRDUDE_ISP_BAUDRATE = 19200 endif endif # Fuse settings copied from Arduino IDE. # https://github.com/arduino/Arduino/blob/master/app/src/processing/app/debug/AvrdudeUploader.java#L254 # Pre fuse settings ifndef AVRDUDE_ISP_FUSES_PRE ifneq ($(strip $(ISP_LOCK_FUSE_PRE)),) AVRDUDE_ISP_FUSES_PRE += -U lock:w:$(ISP_LOCK_FUSE_PRE):m endif ifneq ($(strip $(ISP_EXT_FUSE)),) AVRDUDE_ISP_FUSES_PRE += -U efuse:w:$(ISP_EXT_FUSE):m endif ifneq ($(strip $(ISP_HIGH_FUSE)),) AVRDUDE_ISP_FUSES_PRE += -U hfuse:w:$(ISP_HIGH_FUSE):m endif ifneq ($(strip $(ISP_LOW_FUSE)),) AVRDUDE_ISP_FUSES_PRE += -U lfuse:w:$(ISP_LOW_FUSE):m endif endif # Bootloader file settings ifndef AVRDUDE_ISP_BURN_BOOTLOADER ifneq ($(strip $(BOOTLOADER_PATH)),) ifneq ($(strip $(BOOTLOADER_FILE)),) AVRDUDE_ISP_BURN_BOOTLOADER += -U flash:w:$(BOOTLOADER_PARENT)/$(BOOTLOADER_PATH)/$(BOOTLOADER_FILE):i endif endif endif # Post fuse settings ifndef AVRDUDE_ISP_FUSES_POST ifneq ($(strip $(ISP_LOCK_FUSE_POST)),) AVRDUDE_ISP_FUSES_POST += -U lock:w:$(ISP_LOCK_FUSE_POST):m endif endif AVRDUDE_ISP_OPTS = -c $(ISP_PROG) -b $(AVRDUDE_ISP_BAUDRATE) ifneq ($(strip $(ISP_PROG)),$(filter $(ISP_PROG), usbasp usbtiny)) AVRDUDE_ISP_OPTS += -P $(call get_isp_port) endif ifndef ISP_EEPROM 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) endif ######################################################################## # Explicit targets start here all: $(TARGET_EEP) $(TARGET_HEX) # 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 prerequisite # list) to prevent remaking the target when any file in the directory # changes. $(OBJDIR): $(MKDIR) $(OBJDIR) $(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) $(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) -lc -lm $(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) $(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) error_on_caterina: $(ERROR_ON_CATERINA) # Use submake so we can guarantee the reset happens # before the upload, even with make -j upload: $(TARGET_HEX) verify_size $(MAKE) reset $(MAKE) do_upload raw_upload: $(TARGET_HEX) verify_size $(MAKE) error_on_caterina $(MAKE) do_upload do_upload: $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ $(AVRDUDE_UPLOAD_HEX) do_eeprom: $(TARGET_EEP) $(TARGET_HEX) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ $(AVRDUDE_UPLOAD_EEP) eeprom: $(TARGET_HEX) verify_size $(MAKE) reset $(MAKE) do_eeprom raw_eeprom: $(TARGET_HEX) verify_size $(MAKE) error_on_caterina $(MAKE) do_eeprom reset: $(call arduino_output,Resetting Arduino...) $(RESET_CMD) # 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: for STTYF in 'stty -F' 'stty --file' 'stty -f' 'stty <' ; \ do $$STTYF /dev/tty >/dev/null 2>&1 && break ; \ done ; \ $$STTYF $(call get_monitor_port) hupcl ; \ (sleep 0.1 2>/dev/null || sleep 1) ; \ $$STTYF $(call get_monitor_port) -hupcl ispload: $(TARGET_EEP) $(TARGET_HEX) verify_size $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) \ $(AVRDUDE_ISPLOAD_OPTS) burn_bootloader: ifneq ($(strip $(AVRDUDE_ISP_FUSES_PRE)),) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e $(AVRDUDE_ISP_FUSES_PRE) endif ifneq ($(strip $(AVRDUDE_ISP_BURN_BOOTLOADER)),) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_BURN_BOOTLOADER) endif ifneq ($(strip $(AVRDUDE_ISP_FUSES_POST)),) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_FUSES_POST) endif set_fuses: ifneq ($(strip $(AVRDUDE_ISP_FUSES_PRE)),) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) -e $(AVRDUDE_ISP_FUSES_PRE) endif ifneq ($(strip $(AVRDUDE_ISP_FUSES_POST)),) $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ISP_OPTS) $(AVRDUDE_ISP_FUSES_POST) endif clean: $(REMOVE) $(LOCAL_OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CORE_LIB) $(TARGETS) $(DEPS) $(USER_LIB_OBJS) ${OBJDIR} size: $(TARGET_HEX) $(call avr_size,$(TARGET_ELF),$(TARGET_HEX)) show_boards: @$(CAT) $(BOARDS_TXT) | grep -E "^[[:alnum:]]" | cut -d . -f 1 | uniq monitor: $(MONITOR_CMD) $(call get_monitor_port) $(MONITOR_BAUDRATE) disasm: $(OBJDIR)/$(TARGET).lss @$(ECHO) "The compiled ELF file has been disassembled to $(OBJDIR)/$(TARGET).lss" symbol_sizes: $(OBJDIR)/$(TARGET).sym @$(ECHO) "A symbol listing sorted by their size have been dumped to $(OBJDIR)/$(TARGET).sym" verify_size: ifeq ($(strip $(HEX_MAXIMUM_SIZE)),) @$(ECHO) "\nMaximum flash memory of $(BOARD_TAG) is not specified. Make sure the size of $(TARGET_HEX) is less than $(BOARD_TAG)\'s flash memory\n\n" endif @if [ ! -f $(TARGET_HEX).sizeok ]; then echo >&2 "\nThe size of the compiled binary file is greater than the $(BOARD_TAG)'s flash memory. \ See http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it."; false; fi generate_assembly: $(OBJDIR)/$(TARGET).s @$(ECHO) "Compiler-generated assembly for the main input source has been dumped to $(OBJDIR)/$(TARGET).s" generated_assembly: generate_assembly @$(ECHO) "\"generated_assembly\" target is deprecated. Use \"generate_assembly\" target instead" help_vars: @$(CAT) $(ARDMK_DIR)/arduino-mk-vars.md help: @$(ECHO) "\nAvailable targets:\n\ make - no upload\n\ make upload - upload\n\ make clean - remove all our dependencies\n\ make depends - update dependencies\n\ make reset - reset the Arduino by tickling DTR on the serial port\n\ make raw_upload - upload without first resetting\n\ make show_boards - list all the boards defined in boards.txt\n\ make monitor - connect to the Arduino's serial port\n\ make size - show the size of the compiled output (relative to\n\ resources, if you have a patched avr-size)\n\ make disasm - generate a .lss file in build-cli that contains\n\ disassembly of the compiled file interspersed\n\ with your original source code.\n\ make verify_size - Verify that the size of the final file is less than\n\ the capacity of the micro controller.\n\ make eeprom - upload the eep file\n\ make raw_eeprom - upload the eep file without first resetting\n\ make burn_bootloader - burn bootloader and fuses\n\ make set_fuses - set fuses without burning bootloader\n\ make help_vars - print all variables that can be overridden\n\ make help - show this help\n\ " @$(ECHO) "Please refer to $(ARDMK_DIR)/Arduino.mk for more details.\n" .PHONY: all upload raw_upload raw_eeprom error_on_caterina reset reset_stty ispload \ clean depends size show_boards monitor disasm symbol_sizes generated_assembly \ generate_assembly verify_size burn_bootloader help # added - in the beginning, so that we don't get an error if the file is not present -include $(DEPS) Arduino-Makefile-1.3.1/CONTRIBUTING.md000066400000000000000000000036401227416204600170700ustar00rootroot00000000000000# Contributing To Arduino Makefile Community made patches, localizations, bug reports, documentation and contributions are always welcome and are crucial to the success of this project. When contributing please ensure you follow the guidelines below so that we can keep on top of things. ## Getting Started Submit a ticket for your issue, assuming one does not already exist. - Raise it on our [Issue Tracker](https://github.com/sudar/Arduino-Makefile/issues) - Clearly describe the issue including steps to reproduce the bug. - Make sure you fill in the earliest version that you know has the issue as well as the following - Your operating system (Mac, Linux/Unix, Windows) - Your Arduino IDE version - Snippet of your makefile ## Making Changes - Fork the repository on GitHub - Make the changes to your forked repository - Update the [changelog file](HISTORY.md) and add a note about your change. If possible prefix it with either Fix, Tweak or New - If you are adding or changing the behavior of any variable, then update the corresponding documentation in the [arduino-mk-vars.md](arduino-mk-vars.md) file as well - When committing, reference your issue (if present) and include a note about the fix - If possible (and if makes sense) do atomic commits - Try to follow [this guideline](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) while choosing the git commit message - Push the changes to your fork and submit a pull request to the 'master' branch of the this repository At this point you're waiting on us to merge your pull request. We'll review all pull requests, and make suggestions and changes if necessary. # Additional Resources - [General GitHub Documentation](http://help.github.com/) - [GitHub Pull Request documentation](http://help.github.com/send-pull-requests/) - [Guide about contributing code in GitHub](http://sudarmuthu.com/blog/contributing-to-project-hosted-in-github) Arduino-Makefile-1.3.1/Common.mk000066400000000000000000000026001227416204600164130ustar00rootroot00000000000000# 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. space_pad_to = $(shell echo $(1) " " | head -c$(2)) # Call with some text, and a prefix tag if desired (like [AUTODETECTED]), 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 = $(call arduino_output,-------------------------) $(call show_separator) $(call arduino_output,Arduino.mk Configuration:) ######################################################################## # # Detect OS ifeq ($(OS),Windows_NT) CURRENT_OS = WINDOWS else UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Linux) CURRENT_OS = LINUX endif ifeq ($(UNAME_S),Darwin) CURRENT_OS = MAC endif endif $(call show_config_variable,CURRENT_OS,[AUTODETECTED]) Arduino-Makefile-1.3.1/HISTORY.md000066400000000000000000000264431227416204600163300ustar00rootroot00000000000000A 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. ### 1.3.1 (2014-02-04) - Fix: BUNDLED_AVR_TOOLS_DIR is now set properly when using only arduino-core and not the whole arduino package. (https://github.com/sej7278) - New: Document all variables that can be overridden. (https://github.com/sej7278) - New: Add a new `help_vars` target to display information about variables that can be overridden. ### 1.3.0 (2014-01-29) - Fix: Use more reliable serial device naming in Windows. Fix issue #139 and #155 (https://github.com/peplin) - Fix: Document that ARDUINO_DIR must be a relative path in Windows. Fix issue #156 (https://github.com/peplin) - Tweak: Don't hard code MONITOR_PORT in examples, for more flexible testing. (Issue #157) (https://github.com/peplin) - Tweak: Silence the stderr output from call to `which`. (Issue #158) (https://github.com/peplin) - Fix: Override complete compiler tool paths for chipKIT. (Issue #159) (https://github.com/peplin) - New: The makefile is compatible with Windows - New: Update `README.md` file about usage and Windows compatibility ### 1.2.0 (2014-01-14) - Add: Add RPM SPECfile and new `package` directory to store package instructions and files (https://github.com/sej7278) - Fix: Remove use of arduino-mk subdirectory in git. Fix issue #151, #152 and #147 (https://github.com/sej7278) - Fix: Remove `arduino-mk` directory from all examples. Fix #154 ### 1.1.0 (2013-12-26) - Don't append port details to avrdude for usbasp. See #123 - Ignore commented lines while parsing boards.txt file. See #124 - In ISP mode, read baudrate and programmer from boards.txt. See #125 - Add `burn_bootloader` target. See #85 - Show correct path to `arduino.mk` file in help message. Fix #120 - Change echo for printf. Fix #129 (https://github.com/thomassigurdsen) - Add support for ChipKiT 2013. Fix #136 (https://github.com/peplin) - Auto detect and include libraries specified in `USER_LIB_PATH`. Fix #135 (https://github.com/tinyladi) - Use `MAKEFILE_LIST` to get the name of the make file. Fix #130 (https://github.com/cantora) - New: Add option to set fuses without burning a bootloader. Fix #141 (https://github.com/sej7278) - Tweak: Don't append port details to avrdude for usbtiny. Fix #140 and #138 (https://github.com/PPvG) - Fix: Handle relative paths of bootloader file while burning bootloaders. Fix #126 and #142 (https://github.com/sej7278) - New: Add `CONTRIBUTING.md` explaining how to contribute to the project. - New: Force -Os optimization for SoftwareSerial. Add `OPTIMIZATION_FLAGS` and `DEBUG_FLAGS`. (https://github.com/mahoy) - Fix: Use `ARDUINO_HEADER` variable instead of hardcoded file names. Fix #131 ### 1.0.1 (2013-09-25) - Unconditionally add -D in avrdude options. See #114 ### 1.0.0 (2013-09-22) - Add $OBJDIR to the list of configuration that gets printed. Fix issue #77 - Add support for specifying optimization level. Fix issue #81 - Add support for reseting "Micro" Arduino. Fix issue #80 (https://github.com/sej7278) - Remove "utility" from example makefiles. Fix issue #84 - Auto detect alternate core path from sketchbook folder. Fix issue #86 - Remove redundant checks for ARDUINO_DIR - Improve avrdude and avrdude.conf path auto detection. Fix issue #48 - Move binary sketch size verification logic inside makefile. Fix issue #54 - Remove dependency on wait-connection-leonardo shell script. Fix issue #95 - Add support for the Digilent chipKIT platform. (https://github.com/peplin) - Implement ard-parse-boards with shell scripting instead of Perl (https://github.com/peplin) - Compile with debugging symbols only when DEBUG=1 (https://github.com/peplin) - Replace Leonardo detection with Caterina detection (https://github.com/sej7278) - Autodetect baudrate only if either a .ino/.pde is present - Allow building with Arduino core, without a .ino/.pde file - Ability to support different Arduino cores (https://github.com/sej7278) ### 0.12.0 (2013-06-20) - Fix "generated_assembly" target, which got broken earlier. Fix issue #76 (https://github.com/matthijskooijman) - Deprecate "generated_assembly" target in favour of "generate_assembly". Fix issue #79 ### 0.11.0 (2013-06-15) - Replace hardcoded executables with variable - Fix whitespace issues - Add a warning when HEX_MAXIMUM_SIZE is not specified - Add the ability to configure avrdude options. Fix issue #53 - Handle cases where certain fuse bits are not present. Fix issue #61 - Add support for compiling plain AVR C files. Fix issue #63 - Add an example to show how to compile AVR C files. Fix issue #73 ### 0.10.6 (2013-06-14) - Fix whitespace and add /dev/null redirection (https://github.com/sej7278) - Change the way AUTO_ARDUINO_VERSION is computed (https://github.com/sej7278) - Make serial monitor baudrate detection work in Mac as well(https://github.com/sej7278) - Fix directory creation for library source files (https://github.com/matthijskooijman) - Rewrite ard-leonardo-reset script in perl (https://github.com/sej7278) ### 0.10.5 (2013-06-11) - Add USB_VID and USB_PID to CPPFLAGS only if the board is Leonardo. - Allow adding extra common dependencies (COMMON_DEPS) (https://github.com/gaftech) - Added ifndef ARDUINO_VAR_PATH for compiling for the attiny (https://github.com/danielesteban) - Strip extra whitespace from the `BOARD_TAG` variable - Enhanced support for programming using Arduino as ISP - Added example to show how to program using Arduino as ISP - Add support for Leonardo boards. Took code from (https://github.com/guicho271828) ### 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 - 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. Arduino-Makefile-1.3.1/README.md000066400000000000000000000172751227416204600161270ustar00rootroot00000000000000# A Makefile for Arduino Sketches This is a very simple Makefile which knows how to build Arduino sketches. It defines 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. ## Features - Very robust - Highly customizable - Supports all official AVR-based Arduino boards - Supports chipKIT - Works on all three major OS (Mac, Linux, Windows) - Auto detects serial baud rate and libraries used - Support for `*.ino` and `*.pde` sketches as well as raw `*.c` and `*.cpp` - Support for Arduino Software versions 1.0.x as well as 0.x. Support for Arduino 1.5.x is still work in progress - Automatic dependency tracking. Referred libraries are automatically included in the build process. Changes in `*.h` files lead to recompilation of sources which include them ## Installation ### Through package If you're using FreeBSD, Debian or Ubuntu, you can find this in the `arduino-mk` package and can be installed using `apt-get` or `aptitude`. ### From source - Download the latest release - Or clone it from Github using the command `git clone git@github.com:sudar/Arduino-Makefile.git` - Check the [usage section](https://github.com/sudar/Arduino-Makefile#usage) in this readme about setting usage options ## Requirements You need to have the Arduino IDE. You can either install it through the installer or download the distribution zip file and extract it. 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: apt-get install libdevice-serialport-perl On Fedora: yum install perl-Device-SerialPort On openSUSE: zypper install perl-Device-SerialPort On Mac using MacPorts: sudo port install p5-device-serialport and use /opt/local/bin/perl5 instead of /usr/bin/perl On other systems: cpan Device::SerialPort ## Usage You can also find more [detailed instructions in this guide](http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile) or also checkout the sample makefiles inside the examples/ folder Download a copy of this repo some where in your system or install it through a package. On the Mac you might want to set: ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java ARDMK_DIR = /usr/local AVR_TOOLS_DIR = /usr MONITOR_PORT = /dev/ttyACM0 BOARD_TAG = mega2560 On Linux (if you have installed through package), you shouldn't need to set anything other than your board type and port: BOARD_TAG = mega2560 MONITOR_PORT = /dev/ttyACM0 On Windows (using cygwin), you might want to set: ARDUINO_DIR = ../../arduino ARDMK_DIR = path/to/mkfile MONITOR_PORT = com3 BOARD_TAG = mega2560 - `BOARD_TAG` - Type of board, for a list see boards.txt or `make show_boards` - `MONITOR_PORT` - The port where your Arduino is plugged in, usually `/dev/ttyACM0` or `/dev/ttyUSB0` in Linux or Mac OS X and `com3`, `com4`, etc. in Windows. - `ARDUINO_DIR` - Path to Arduino installation. In Cygwin in Windows this path must be relative, not absolute (e.g. "../../arduino" and not "/c/cygwin/Arduino"). - `ARDMK_DIR` - Path where the `*.mk` are present. If you installed the package, then it is usually `/usr/share/arduino` - `AVR_TOOLS_DIR` - Path where the avr tools chain binaries are present. If you are going to use the binaries that came with Arduino installation, then you don't have to set it. The list of all variables that can be overridden is available at [arduino-mk-vars.md](arduino-mk-vars.md) file. ## Including Libraries You can specify space separated list of libraries that are needed for your sketch to the variable `ARDUINO_LIBS`. `ARDUINO_LIBS = Wire SoftwareSerial` The libraries will be searched in the following places in the following order. - `/libraries` folder inside your sketchbook folder. Sketchbook folder will be auto detected from your Arduino preference file. You can also manually set it through `ARDUINO_SKETCHBOOK`. - `/libraries` folder inside your Arduino folder, which is read from `ARDUINO_DIR`. The libraries inside user folder will take precedence over libraries present in Arduino core folder. The makefile can autodetect the libraries that are included from your sketch and can include them automatically. But it can't detect libraries that are included from other libraries. (see [issue #93](https://github.com/sudar/Arduino-Makefile/issues/93)) ## avrdude To upload compiled files, `avrdude` is used. This Makefile tries to find `avrdude` and it's config (`avrdude.conf`) below `ARDUINO_DIR`. If you like to use the one installed on your system instead of the one which came with Arduino, you can try to set the variables `AVRDUDE` and `AVRDUDE_CONF`. On a typical Linux system these could be set to AVRDDUDE = /usr/bin/avrdude AVRDUDE_CONF = /etc/avrdude.conf ## Colorgcc It is possible to use [`colorgcc`](https://github.com/colorgcc/colorgcc) with this makefile. Check out [this comment](http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile#comment-1408) to find usage instructions. ## Versioning The current version of the makefile is `1.3.1`. You can find the full history in the [HISTORY.md](HISTORY.md) file This project adheres to Semantic [Versioning 2.0](http://semver.org/). ## License This makefile and the related documentation and examples are 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 License, or (at your option) any later version. ## Contribution All contributions (even documentation) are welcome :) Open a pull request and I would be happy to merge them. Also checkout the [contribution guide](CONTRIBUTING.md) for more details. If you are looking for ideas to work on, then check out the following TODO items or the [issue tracker](https://github.com/sudar/Arduino-Makefile/issues/). ## Limitations / Know Issues / TODO's - Doesn't work with Arduino 1.5.x yet. Follow [issue #45](https://github.com/sudar/Arduino-Makefile/issues/45) for progress. - Since it doesn't do any pre processing like Arduino IDE, you have to declare all methods before you use them ([issue #59](https://github.com/sudar/Arduino-Makefile/issues/59)) - More than one .ino or .pde file is not supported yet ([issue #49](https://github.com/sudar/Arduino-Makefile/issues/49)) - When you compile for the first time, it builds all libs inside Arduino directory even if it is not needed. But while linking only the relevant files are linked. ([issue #29](https://github.com/sudar/Arduino-Makefile/issues/29)). Even Arduino IDE does the same thing though. If you find an issue or have an idea for a feature then log them in the [issue tracker](https://github.com/sudar/Arduino-Makefile/issues/) ## Credits 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/tutorials/compiling-arduino-sketches-using-makefile) ## 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. Arduino-Makefile-1.3.1/arduino-mk-vars.md000066400000000000000000000225671227416204600202110ustar00rootroot00000000000000# Documentation of variables The following are the different variables that can be overwritten in the user makefiles. - [Global variables](#global-variables) - [Installation/Directory variables](#installationdirectory-variables) - [Arduino IDE variables](#arduino-ide-variables) - [Sketch related variables](#sketch-related-variables) - [ISP programming variables](#isp-programming-variables) - [Compiler/Executable variables](#compilerexecutable-variables) - [Avrdude setting variables](#avrdude-setting-variables) - [Bootloader variables](#bootloader-variables) - [ChipKIT variables](#chipkit-variables) ## Global variables ### ARDUINO_QUIET Suppress printing of Arduino-Makefile configuration. Defaults to unset/disabled. *Example*: 1 Optional. ## Installation/Directory variables ### ARDMK_DIR Directory where the `*.mk` files are stored. Usually can be auto-detected as `AUTO_ARDUINO_DIR` (parent of Arduino.mk). *Example*: /usr/share/arduino Optional. ### AVR_TOOLS_DIR Directory where tools such as avrdude, avr-g++, avr-gcc etc. are stored in the bin/ subdirectory. Usually can be auto-detected from `$PATH` as `SYSTEMPATH_AVR_TOOLS_DIR` or as `BUNDLED_AVR_TOOLS_DIR` within the Arduino distribution. *Example*: /usr or /usr/share/arduino/hardware/tools/avr Optional. ### RESET_CMD Command to reset the MCU. Defaults to ard-reset-arduino with the extra --caterina flag for atmega32u4 boards. *Example*: ~/gertduino/reset Optional. ## Arduino IDE variables ### ARDUINO_DIR Directory where the Arduino IDE and/or core files are stored. *Example*: /usr/share/arduino (Linux) or /Applications/Arduino.app/Contents/Resources/Java (OSX) Optional. ### ARDUINO_VERSION Version string for Arduino IDE and/or core. Usually can be auto-detected as `AUTO_ARDUINO_VERSION` from /usr/share/arduino/lib/version.txt *Example*: 105 Optional. ### ARDUINO_SKETCHBOOK Path to sketchbook directory. Usually can be auto-detected from the Arduino preferences.txt file or the default ~/sketchbook *Example*: ~/sketches Optional. ### ARDUINO_PREFERENCES_PATH Path to Arduino preferences.txt file. Usually can be auto-detected as `AUTO_ARDUINO_PREFERENCES` from the defaults ~/.arduino/preferences.txt (Linux) or ~/Library/Arduino/preferences.txt (OSX) *Example*: ~/sketches/preferences.txt Optional. ### ARDUINO_CORE_PATH Path to standard Arduino core files. *Example*: /usr/share/arduino/hardware/arduino/cores/arduino Optional. ## Sketch related variables ### ARDUINO_LIBS Any libraries you intend to include. Usually can be auto-detected from the sketch. Separated by spaces. If the library has a /utility folder (like SD or Wire library), then the utility folder should also be specified. *Example*: SD SD/utility Wire Wire/utility Optional. ### BOARD_TAG Device type as listed in boards.txt or `make show_boards`. *Example*: uno or mega2560 Mandatory. ### MONITOR_PORT Path to serial (USB) device used for uploading/serial comms. *Example*: /dev/ttyUSB0 or /dev/ttyACM0 (Linux) or /dev/cu.usb* (OSX) or com3 (Windows) Mandatory. ### USER_LIB_PATH Directory where additional libraries are stored. Defaults to 'libraries' directory within user's sketchbook. *Example*: ~/sketchbook/libraries (Linux) Optional. ### ALTERNATE_CORE Non-standard core for Arduino-unsupported chips like the ATtiny. *Example*: attiny-master or arduino-tiny or tiny2 Optional. ### ARDUINO_VAR_PATH Path to non-standard core's variant files. *Example*: ~/sketchbook/hardware/arduino-tiny/cores/tiny Optional. ### VARIANT Variant of a standard board design. Usually can be auto-detected as build.variant from boards.txt *Example*: leonardo Optional. ### USB_VID Override USB VID for atmega32u4 boards. Usually can be auto-detected as build.vid from boards.txt *Example*: 0x2341 Optional. ### USB_PID Override USB PID for atmega32u4 boards. Usually can be auto-detected as build.pid from boards.txt *Example*: 0x8039 Optional. ### F_CPU CPU speed in Hz Usually can be auto-detected as build.f_cpu from boards.txt *Example*: 8000000L Optional. ### HEX_MAXIMUM_SIZE Maximum hex file size Usually can be auto-detected as upload.maximum_size from boards.txt *Example*: 14336 Optional. ### MCU Microcontroller model. Usually can be auto-detected as build.mcu from boards.txt *Example*: atmega32u4 Optional. ### MCU_FLAG_NAME Override default MCU flags. Defaults to mmcu *Example*: mprocessor Optional. ### MONITOR_BAUDRATE Baudrate of the serial monitor. Defaults to 9600 if it can't find it in the sketch Serial.begin() *Example*: 57600 Optional. ## ISP programming variables ### ISP_PROG Type of ISP. Either a USB device or ArduinoISP protocol. *Example*: usbasp or usbtiny or stk500v2 or stk500v1 Optional. ### ISP_PORT Device path to ArduinoISP. Not needed for hardware ISP's. *Example*: /dev/ttyACM0 (Linux) Optional. ### ISP_LOCK_FUSE_PRE Bootloader unlock bits. Usually can be auto-detected from boards.txt *Example*: 0x3f Optional. ### ISP_LOCK_FUSE_POST Bootloader lock bits. Usually can be auto-detected from boards.txt *Example*: 0xcf Optional. ### ISP_HIGH_FUSE SP_LOW_FUSE/ISP_EXT_FUSE - high/low/extended fuse bits. Usually can be auto-detected from boards.txt *Example*: 0xdf or 0xff or 0x01 Optional. ### ISP_EEPROM Whether to upload the EEPROM file or not. Defaults to 0 *Example*: 1 Optional. ## Compiler/Executable variables ### CC_NAME C compiler. Defaults to avr-gcc *Example*: pic32-gcc Optional. ### CXX_NAME C++ compiler. Defaults to avr-g++ *Example*: pic32-g++ Optional. ### OBJCOPY_NAME Objcopy utility. Defaults to avr-objcopy *Example*: pic32-objcopy Optional. ### OBJDUMP_NAME Objdump utility. Defaults to avr-objdump *Example*: pic32-objdump Optional. ### AR_NAME Archive utility. Defaults to avr-ar *Example*: pic32-ar Optional. ### SIZE_NAME Size utility. Defaults to avr-size *Example*: pic32-size Optional. ### NM_NAME Nm utility. Defaults to avr-nm *Example*: pic32-nm Optional. ### OPTIMIZATION_LEVEL Linker's -O flag Defaults to s, which shouldn't really be changed as it breaks SoftwareSerial and usually results in bigger hex files. *Example*: 3 Optional. ### CFLAGS_STD Flags to pass to the C compiler. Defaults to -std=gnu99 *Example*: Optional. ### OVERRIDE_EXECUTABLES Override the default build tools. If set to 1 each tool (CC, CXX, AS, OBJCOPY, OBJDUMP, AR, SIZE, NM) must have its path explicitly defined. See chipKIT.mk *Example*: 1 Optional. ### MONITOR_CMD Command to run the serial monitor. Defaults to screen *Example*: minicom Optional. ## Avrdude setting variables ### AVRDUDE Path to avrdude utility Usually can be auto-detected within the parent of `AVR_TOOLS_DIR` or in the $PATH *Example*: /usr/bin/avrdude Optional. ### AVRDUDE_CONF Path to avrdude.conf file Usually can be auto-detected within the parent of `AVR_TOOLS_DIR` *Example*: /etc/avrdude.conf or /usr/share/arduino/hardware/tools/avrdude.conf Optional. ### AVR_TOOLS_PATH Directory where tools such as avrdude, avr-g++, avr-gcc etc. are stored. Usually can be auto-detected from AVR_TOOLS_DIR/bin *Example*: /usr/bin or /usr/share/arduino/hardware/tools/avr/bin Optional. ### ARDUINO_LIB_PATH Directory where the standard Arduino libraries are stored. Defaults to ARDUINO_DIR/libraries *Example*: /usr/share/arduino/libraries (Linux) Optional. ### ARDUINO_CORE_PATH Directory where the standard Arduino cores are stored. Defaults to ARDUINO_DIR/hardware/arduino/cores/arduino *Example*: /usr/share/arduino/hardware/arduino/cores/robot Optional. ### ALTERNATE_CORE_PATH Path to non-standard cores. Defaults to ARDUINO_SKETCHBOOK/hardware/ALTERNATE_CORE *Example*: ~/sketchbook/hardware/arduino-tiny/cores/tiny Optional. ### BOARDS_TXT Path to boards.txt Defaults to ARDUINO_DIR/hardware/arduino/boards.txt *Example*: ~/sketchbook/hardware/boards.txt or /usr/share/arduino/hardware/arduino/boards.txt (Linux) Optional. ### AVRDUDE_ARD_BAUDRATE Upload speed Usually can be auto-detected as upload.speed from boards.txt *Example*: 19200 Optional. ### AVRDUDE_ARD_PROGRAMMER Upload protocol Usually can be auto-detected as upload.protocol from boards.txt *Example*: stk500v1 Optional. ### AVRDUDE_ISP_BAUDRATE ISP speed if different to upload.speed Defaults to same as `AVRDUDE_ARD_BAUDRATE` or 19200 *Example*: 19200 Optional. ### AVRDUDE_OPTS Options to pass to avrdude. Defaults to '-q -V -D' (quiet, don't verify, don't auto-erase). User values are not ANDed to the defaults, you have to set each option you require. *Example*: -v Optional. ## Bootloader variables ### BOOTLOADER_FILE File for bootloader. Usually can be auto-detected as bootloader.file from boards.txt *Example*: optiboot_atmega328.hex Optional. ### BOOTLOADER_PATH Path to bootloader file. Usually can be auto-detected as a relative bootloader.path from boards.txt *Example*: optiboot or arduino:atmega or /usr/share/arduino/hardware/arduino/bootloaders/caterina/Caterina-Esplora.hex Optional. ## ChipKIT variables ### MPIDE_DIR Path to chipKIT MP IDE Usually can be auto-detected as `AUTO_MPIDE_DIR` from the defaults /usr/share/mpide (Linux) or /Applications/Mpide.app/Contents/Resources/Java (OSX) *Example*: ~/mpide Optional. ### MPIDE_PREFERENCES_PATH Path to chipKIT preferences.txt file. Usually can be auto-detected as `AUTO_MPIDE_PREFERENCES_PATH` from the defaults ~/.mpide/preferences.txt (Linux) or ~/Library/Mpide/preferences.txt (OSX) *Example*: ~/chipkit/preferences.txt Optional. Arduino-Makefile-1.3.1/bin/000077500000000000000000000000001227416204600154045ustar00rootroot00000000000000Arduino-Makefile-1.3.1/bin/ard-reset-arduino000077500000000000000000000055441227416204600206670ustar00rootroot00000000000000#!/usr/bin/env perl use strict; use warnings; use Device::SerialPort; use Getopt::Long; use Pod::Usage; my %Opt = ( period => 0.1, ); GetOptions(\%Opt, "period=f", # width of reset pulse in seconds "verbose!", "help!", "info!", "caterina!", ); if ($Opt{help} || $Opt{info}) { usage(); } die "No Arduinos found!\n" unless @ARGV; foreach my $dev (@ARGV) { my $p = Device::SerialPort->new($dev) or die "Unable to open $dev: $!\n"; if ($Opt{caterina}) { $p->baudrate(1200); $p->write_settings; $p->close; print STDERR "Forcing reset using 1200bps open/close on port $dev\n" if $Opt{verbose}; # wait for it to come back sleep 1; while( ! -e $dev ) { print STDERR "Waiting for $dev to come back\n" if $Opt{verbose}; sleep 1; } print STDERR "$dev has come back after reset\n" if $Opt{verbose}; } else { my $dt = $Opt{period}; print STDERR "Setting DTR high for ${dt}s on $dev\n" if $Opt{verbose}; die "Invalid pulse width ($dt), " unless $dt > 0.0; $p->pulse_dtr_on($dt * 1000.0); } } ## here endeth the main sub usage { pod2usage(-verbose => 2); } __END__ =head1 NAME ard-reset-arduino - Reset an Arduino =head1 USAGE $ ard-reset-arduino /dev/cu.usb* $ ard-reset-arduino --verbose --period=0.1 /dev/cu.usb* $ ard-reset-arduino --verbose --caterina /dev/ttyUSB0 =head1 DESCRIPTION To reset (most) Arduinos, it's enough to just pulse the DTR line. You can do that from the shell with stty, but there's an interesting diversity of command flags. This little program gives a uniform interface at the cost of requiring C. =head1 OPTIONS =over =item --verbose Watch what's going on on STDERR. =item --period=0.25 Specify the DTR pulse width in seconds. =item --caterina Reset a Leonardo, Micro, Robot or LilyPadUSB. =back =head1 BUGS AND LIMITATIONS There are no known bugs in this application. Please report problems to the author. Patches are welcome. =head1 AUTHOR Martin Oldfield, ex-atelier@mjo.tc Support for Leonardo/Micro added by sej7278, https://github.com/sej7278 Thanks to Daniele Vergini who suggested this to me, and supplied a command line version. =head1 LICENCE AND COPYRIGHT Copyright (c) 2012, Martin Oldfield. All rights reserved. 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 License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Arduino-Makefile-1.3.1/chipKIT.mk000066400000000000000000000065341227416204600164700ustar00rootroot00000000000000# # chipKIT extensions for Arduino Makefile # System part (i.e. project independent) # # Copyright (C) 2011, 2012, 2013 Christopher Peplin # , based on work that is Copyright Martin # Oldfield # # 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 # License, or (at your option) any later version. # # Modified by John Wallbank for Visual Studio # # Development changes, John Wallbank, # # - made inclusion of WProgram.h optional so that # including it in the source doesn't mess up compile error line numbers # - parameterised the routine used to reset the serial port # ######################################################################## # Makefile distribution path # # The show_config_variable is unavailable before we include the common makefile, # so we defer logging the ARDMK_DIR info until it happens in Arduino.mk ifndef ARDMK_DIR # presume it's the same path to our own file ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))) endif include $(ARDMK_DIR)/Common.mk ifndef MPIDE_DIR AUTO_MPIDE_DIR := $(firstword \ $(call dir_if_exists,/usr/share/mpide) \ $(call dir_if_exists,/Applications/Mpide.app/Contents/Resources/Java) ) ifdef AUTO_MPIDE_DIR MPIDE_DIR = $(AUTO_MPIDE_DIR) $(call show_config_variable,MPIDE_DIR,[autodetected]) else echo $(error "mpide_dir is not defined") endif else $(call show_config_variable,MPIDE_DIR,[USER]) endif ifndef MPIDE_PREFERENCES_PATH AUTO_MPIDE_PREFERENCES_PATH := $(firstword \ $(call dir_if_exists,$(HOME)/.mpide/preferences.txt) \ $(call dir_if_exists,$(HOME)/Library/Mpide/preferences.txt) ) ifdef AUTO_MPIDE_PREFERENCES_PATH MPIDE_PREFERENCES_PATH = $(AUTO_MPIDE_PREFERENCES_PATH) $(call show_config_variable,MPIDE_PREFERENCES_PATH,[autodetected]) endif endif ifeq ($(CURRENT_OS),LINUX) BUNDLED_AVR_TOOLS_DIR = $(call dir_if_exists,$(MPIDE_DIR)/hardware/tools) endif PIC32_TOOLS_DIR = $(ARDUINO_DIR)/hardware/pic32/compiler/pic32-tools PIC32_TOOLS_PATH = $(PIC32_TOOLS_DIR)/bin ALTERNATE_CORE = pic32 ALTERNATE_CORE_PATH = $(MPIDE_DIR)/hardware/pic32 ARDUINO_CORE_PATH = $(ALTERNATE_CORE_PATH)/cores/$(ALTERNATE_CORE) ARDUINO_PREFERENCES_PATH = $(MPIDE_PREFERENCES_PATH) ARDUINO_DIR = $(MPIDE_DIR) CORE_AS_SRCS = $(ARDUINO_CORE_PATH)/vector_table.S ARDUINO_VERSION = 23 CC_NAME = pic32-gcc CXX_NAME = pic32-g++ AR_NAME = pic32-ar OBJDUMP_NAME = pic32-objdump OBJCOPY_NAME = pic32-objcopy SIZE_NAME = pic32-size NM_NAME = pic32-nm OVERRIDE_EXECUTABLES = 1 CC = $(PIC32_TOOLS_PATH)/$(CC_NAME) CXX = $(PIC32_TOOLS_PATH)/$(CXX_NAME) AS = $(PIC32_TOOLS_PATH)/$(AS_NAME) OBJCOPY = $(PIC32_TOOLS_PATH)/$(OBJCOPY_NAME) OBJDUMP = $(PIC32_TOOLS_PATH)/$(OBJDUMP_NAME) AR = $(PIC32_TOOLS_PATH)/$(AR_NAME) SIZE = $(PIC32_TOOLS_PATH)/$(SIZE_NAME) NM = $(PIC32_TOOLS_PATH)/$(NM_NAME) LDSCRIPT = $(call PARSE_BOARD,$(BOARD_TAG),ldscript) LDSCRIPT_FILE = $(ARDUINO_CORE_PATH)/$(LDSCRIPT) MCU_FLAG_NAME=mprocessor LDFLAGS += -T$(ARDUINO_CORE_PATH)/$(LDSCRIPT) LDFLAGS += -T$(ARDUINO_CORE_PATH)/chipKIT-application-COMMON.ld CPPFLAGS += -mno-smart-io -fno-short-double CFLAGS_STD = include $(ARDMK_DIR)/Arduino.mk Arduino-Makefile-1.3.1/examples/000077500000000000000000000000001227416204600164525ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/.gitignore000066400000000000000000000000101227416204600204310ustar00rootroot00000000000000build-* Arduino-Makefile-1.3.1/examples/ATtinyBlink/000077500000000000000000000000001227416204600206425ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/ATtinyBlink/ATtinyBlink.ino000066400000000000000000000013221227416204600235370ustar00rootroot00000000000000/* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ // Connect a LED to Pin 3. It might be different in different ATtiny micro controllers int led = 3; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } Arduino-Makefile-1.3.1/examples/ATtinyBlink/Makefile000066400000000000000000000010031227416204600222740ustar00rootroot00000000000000# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile # if you have placed the alternate core in your sketchbook directory, then you can just mention the core name alone. ALTERNATE_CORE = attiny # If not, you might have to include the full path. #ALTERNATE_CORE_PATH = /home/sudar/Dropbox/code/arduino-sketches/hardware/attiny/ BOARD_TAG = attiny85-8 ISP_PORT = /dev/ttyACM* include $(ARDMK_DIR)/Arduino.mk # !!! Important. You have to use make ispload to upload when using ISP programmer Arduino-Makefile-1.3.1/examples/AnalogInOutSerial/000077500000000000000000000000001227416204600217725ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/AnalogInOutSerial/AnalogInOutSerial.ino000066400000000000000000000032351227416204600260240ustar00rootroot00000000000000/* Analog input, analog output, serial output Reads an analog input pin, maps the result to a range from 0 to 255 and uses the result to set the pulsewidth modulation (PWM) of an output pin. Also prints the results to the serial monitor. The circuit: * potentiometer connected to analog pin 0. Center pin of the potentiometer goes to the analog pin. side pins of the potentiometer go to +5V and ground * LED connected from digital pin 9 to ground created 29 Dec. 2008 modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. */ // These constants won't change. They're used to give names // to the pins used: const int analogInPin = A0; // Analog input pin that the potentiometer is attached to const int analogOutPin = 9; // Analog output pin that the LED is attached to int sensorValue = 0; // value read from the pot int outputValue = 0; // value output to the PWM (analog out) void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); } void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); // map it to the range of the analog out: outputValue = map(sensorValue, 0, 1023, 0, 255); // change the analog out value: analogWrite(analogOutPin, outputValue); // print the results to the serial monitor: Serial.print("sensor = " ); Serial.print(sensorValue); Serial.print("\t output = "); Serial.println(outputValue); // wait 10 milliseconds before the next loop // for the analog-to-digital converter to settle // after the last reading: delay(10); } Arduino-Makefile-1.3.1/examples/AnalogInOutSerial/Makefile000066400000000000000000000000741227416204600234330ustar00rootroot00000000000000BOARD_TAG = uno ARDUINO_LIBS = include ../../Arduino.mk Arduino-Makefile-1.3.1/examples/Blink/000077500000000000000000000000001227416204600175115ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/Blink/Blink.ino000066400000000000000000000007751227416204600212700ustar00rootroot00000000000000/* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); // set the LED on delay(1000); // wait for a second digitalWrite(13, LOW); // set the LED off delay(1000); // wait for a second } Arduino-Makefile-1.3.1/examples/Blink/Makefile000066400000000000000000000000751227416204600211530ustar00rootroot00000000000000BOARD_TAG = uno ARDUINO_LIBS = include ../../Arduino.mk Arduino-Makefile-1.3.1/examples/BlinkChipKIT/000077500000000000000000000000001227416204600206655ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/BlinkChipKIT/BlinkChipKIT.pde000066400000000000000000000007751227416204600236030ustar00rootroot00000000000000/* Blink Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); // set the LED on delay(1000); // wait for a second digitalWrite(13, LOW); // set the LED off delay(1000); // wait for a second } Arduino-Makefile-1.3.1/examples/BlinkChipKIT/Makefile000066400000000000000000000001041227416204600223200ustar00rootroot00000000000000BOARD_TAG = mega_pic32 ARDUINO_LIBS = include ../../chipKIT.mk Arduino-Makefile-1.3.1/examples/BlinkInAVRC/000077500000000000000000000000001227416204600204545ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/BlinkInAVRC/Makefile000066400000000000000000000006011227416204600221110ustar00rootroot00000000000000# This sample Makefile, explains how you can compile plain AVR C file. # # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile NO_CORE = Yes BOARD_TAG = atmega16 MCU = atmega16 F_CPU = 8000000L ISP_PROG = stk500v1 AVRDUDE_ISP_BAUDRATE = 19200 include $(ARDMK_DIR)/Arduino.mk # !!! Important. You have to use make ispload to upload when using ISP programmer Arduino-Makefile-1.3.1/examples/BlinkInAVRC/blink.c000066400000000000000000000010671227416204600217230ustar00rootroot00000000000000/* * © Anil Kumar Pugalia, 2010. Email: email@sarika-pugs.com * * ATmega48/88/168, ATmega16/32 * * Example Blink. Toggles all IO pins at 1Hz */ #include #include void init_io(void) { // 1 = output, 0 = input DDRB = 0b11111111; // All outputs DDRC = 0b11111111; // All outputs DDRD = 0b11111110; // PORTD (RX on PD0). Just for demo } int main(void) { init_io(); while (1) { PORTC = 0xFF; PORTB = 0xFF; PORTD = 0xFF; _delay_ms(500); PORTC = 0x00; PORTB = 0x00; PORTD = 0x00; _delay_ms(500); } return 0; } Arduino-Makefile-1.3.1/examples/BlinkWithoutDelay/000077500000000000000000000000001227416204600220545ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/BlinkWithoutDelay/BlinkWithoutDelay.ino000066400000000000000000000036001227416204600261640ustar00rootroot00000000000000/* Blink without Delay Turns on and off a light emitting diode(LED) connected to a digital pin, without using the delay() function. This means that other code can run at the same time without being interrupted by the LED code. The circuit: * LED attached from pin 13 to ground. * Note: on most Arduinos, there is already an LED on the board that's attached to pin 13, so no hardware is needed for this example. created 2005 by David A. Mellis modified 8 Feb 2010 by Paul Stoffregen This example code is in the public domain. http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay */ // constants won't change. Used here to // set pin numbers: const int ledPin = 13; // the number of the LED pin // Variables will change: int ledState = LOW; // ledState used to set the LED long previousMillis = 0; // will store last time LED was updated // the follow variables is a long because the time, measured in miliseconds, // will quickly become a bigger number than can be stored in an int. long interval = 1000; // interval at which to blink (milliseconds) void setup() { // set the digital pin as output: pinMode(ledPin, OUTPUT); } void loop() { // here is where you'd put code that needs to be running all the time. // check to see if it's time to blink the LED; that is, if the // difference between the current time and last time you blinked // the LED is bigger than the interval at which you want to // blink the LED. unsigned long currentMillis = millis(); if(currentMillis - previousMillis > interval) { // save the last time you blinked the LED previousMillis = currentMillis; // if the LED is off turn it on and vice-versa: if (ledState == LOW) ledState = HIGH; else ledState = LOW; // set the LED with the ledState of the variable: digitalWrite(ledPin, ledState); } } Arduino-Makefile-1.3.1/examples/BlinkWithoutDelay/Makefile000066400000000000000000000000741227416204600235150ustar00rootroot00000000000000BOARD_TAG = uno ARDUINO_LIBS = include ../../Arduino.mk Arduino-Makefile-1.3.1/examples/Fade/000077500000000000000000000000001227416204600173115ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/Fade/Fade.ino000066400000000000000000000014111227416204600206540ustar00rootroot00000000000000/* Fade This example shows how to fade an LED on pin 9 using the analogWrite() function. This example code is in the public domain. */ int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by void setup() { // declare pin 9 to be an output: pinMode(9, OUTPUT); } void loop() { // set the brightness of pin 9: analogWrite(9, brightness); // change the brightness for next time through the loop: brightness = brightness + fadeAmount; // reverse the direction of the fading at the ends of the fade: if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; } // wait for 30 milliseconds to see the dimming effect delay(30); } Arduino-Makefile-1.3.1/examples/Fade/Makefile000066400000000000000000000000741227416204600207520ustar00rootroot00000000000000BOARD_TAG = uno ARDUINO_LIBS = include ../../Arduino.mk Arduino-Makefile-1.3.1/examples/HelloWorld/000077500000000000000000000000001227416204600205255ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/HelloWorld/HelloWorld.ino000066400000000000000000000027411227416204600233130ustar00rootroot00000000000000/* LiquidCrystal Library - Hello World Demonstrates the use a 16x2 LCD display. The LiquidCrystal library works with all LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface. This sketch prints "Hello World!" to the LCD and shows the time. The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 * LCD D4 pin to digital pin 5 * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) Library originally added 18 Apr 2008 by David A. Mellis library modified 5 Jul 2009 by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe modified 22 Nov 2010 by Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/Tutorial/LiquidCrystal */ // include the library code: #include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); } void loop() { // set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(0, 1); // print the number of seconds since reset: lcd.print(millis()/1000); } Arduino-Makefile-1.3.1/examples/HelloWorld/Makefile000066400000000000000000000001121227416204600221570ustar00rootroot00000000000000BOARD_TAG = uno ARDUINO_LIBS = LiquidCrystal include ../../Arduino.mk Arduino-Makefile-1.3.1/examples/README.md000066400000000000000000000005311227416204600177300ustar00rootroot00000000000000This folder contains the list of example Arduino sketches and makefile showing the different usage patterns - Blink - Shows normal usage - HelloWorld - Shows how to include Arduino libraries - BlinkInAVRC - Shows how to use plain AVR C code - BlinkChipKIT - Shows how to use ChipKIT - ATtinyBlink - Shows how to use different cores like ATtiny Arduino-Makefile-1.3.1/examples/TinySoftWareSerial/000077500000000000000000000000001227416204600222105ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/TinySoftWareSerial/Makefile000066400000000000000000000010111227416204600236410ustar00rootroot00000000000000# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile # if you have placed the alternate core in your sketchbook directory, then you can just mention the core name alone. ALTERNATE_CORE = attiny # If not, you might have to include the full path. #ALTERNATE_CORE_PATH = /home/sudar/Dropbox/code/arduino-sketches/hardware/attiny/ BOARD_TAG = attiny85-8 ARDUINO_LIBS = SoftwareSerial include $(ARDMK_DIR)/Arduino.mk # !!! Important. You have to use make ispload to upload when using ISP programmer Arduino-Makefile-1.3.1/examples/TinySoftWareSerial/TinySoftwareSerial.ino000066400000000000000000000002671227416204600265220ustar00rootroot00000000000000#include SoftwareSerial mySerial(3, 4); // RX, TX void setup() { mySerial.begin(9600); } void loop() { mySerial.println(millis()); delay(1000); } Arduino-Makefile-1.3.1/examples/WebServer/000077500000000000000000000000001227416204600203565ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/WebServer/Makefile000066400000000000000000000002221227416204600220120ustar00rootroot00000000000000# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile BOARD_TAG = uno ARDUINO_LIBS = Ethernet SPI include ../../Arduino.mk Arduino-Makefile-1.3.1/examples/WebServer/WebServer.ino000066400000000000000000000044041227416204600227730ustar00rootroot00000000000000/* Web Server A simple web server that shows the value of the analog input pins. using an Arduino Wiznet Ethernet shield. Circuit: * Ethernet shield attached to pins 10, 11, 12, 13 * Analog inputs attached to pins A0 through A5 (optional) created 18 Dec 2009 by David A. Mellis modified 4 Sep 2010 by Tom Igoe */ #include #include // Enter a MAC address and IP address for your controller below. // The IP address will be dependent on your local network: byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress ip(192,168,1, 178); // Initialize the Ethernet server library // with the IP address and port you want to use // (port 80 is default for HTTP): EthernetServer server(80); void setup() { // start the Ethernet connection and the server: Ethernet.begin(mac, ip); server.begin(); } void loop() { // listen for incoming clients EthernetClient client = server.available(); if (client) { // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); // if you've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so you can send a reply if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(); // output the value of each analog input pin for (int analogChannel = 0; analogChannel < 6; analogChannel++) { client.print("analog input "); client.print(analogChannel); client.print(" is "); client.print(analogRead(analogChannel)); client.println("
"); } break; } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } // give the web browser time to receive the data delay(1); // close the connection: client.stop(); } } Arduino-Makefile-1.3.1/examples/master_reader/000077500000000000000000000000001227416204600212675ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/master_reader/Makefile000066400000000000000000000002121227416204600227220ustar00rootroot00000000000000# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile BOARD_TAG = uno ARDUINO_LIBS = Wire include ../../Arduino.mk Arduino-Makefile-1.3.1/examples/master_reader/master_reader.ino000066400000000000000000000013371227416204600246170ustar00rootroot00000000000000// Wire Master Reader // by Nicholas Zambetti // Demonstrates use of the Wire library // Reads data from an I2C/TWI slave device // Refer to the "Wire Slave Sender" example for use with this // Created 29 March 2006 // This example code is in the public domain. #include void setup() { Wire.begin(); // join i2c bus (address optional for master) Serial.begin(9600); // start serial for output } void loop() { Wire.requestFrom(2, 6); // request 6 bytes from slave device #2 while(Wire.available()) // slave may send less than requested { char c = Wire.read(); // receive a byte as character Serial.print(c); // print the character } delay(500); } Arduino-Makefile-1.3.1/examples/toneMelody/000077500000000000000000000000001227416204600205715ustar00rootroot00000000000000Arduino-Makefile-1.3.1/examples/toneMelody/Makefile000066400000000000000000000000741227416204600222320ustar00rootroot00000000000000BOARD_TAG = uno ARDUINO_LIBS = include ../../Arduino.mk Arduino-Makefile-1.3.1/examples/toneMelody/pitches.h000066400000000000000000000037221227416204600224050ustar00rootroot00000000000000/************************************************* * Public Constants *************************************************/ #define NOTE_B0 31 #define NOTE_C1 33 #define NOTE_CS1 35 #define NOTE_D1 37 #define NOTE_DS1 39 #define NOTE_E1 41 #define NOTE_F1 44 #define NOTE_FS1 46 #define NOTE_G1 49 #define NOTE_GS1 52 #define NOTE_A1 55 #define NOTE_AS1 58 #define NOTE_B1 62 #define NOTE_C2 65 #define NOTE_CS2 69 #define NOTE_D2 73 #define NOTE_DS2 78 #define NOTE_E2 82 #define NOTE_F2 87 #define NOTE_FS2 93 #define NOTE_G2 98 #define NOTE_GS2 104 #define NOTE_A2 110 #define NOTE_AS2 117 #define NOTE_B2 123 #define NOTE_C3 131 #define NOTE_CS3 139 #define NOTE_D3 147 #define NOTE_DS3 156 #define NOTE_E3 165 #define NOTE_F3 175 #define NOTE_FS3 185 #define NOTE_G3 196 #define NOTE_GS3 208 #define NOTE_A3 220 #define NOTE_AS3 233 #define NOTE_B3 247 #define NOTE_C4 262 #define NOTE_CS4 277 #define NOTE_D4 294 #define NOTE_DS4 311 #define NOTE_E4 330 #define NOTE_F4 349 #define NOTE_FS4 370 #define NOTE_G4 392 #define NOTE_GS4 415 #define NOTE_A4 440 #define NOTE_AS4 466 #define NOTE_B4 494 #define NOTE_C5 523 #define NOTE_CS5 554 #define NOTE_D5 587 #define NOTE_DS5 622 #define NOTE_E5 659 #define NOTE_F5 698 #define NOTE_FS5 740 #define NOTE_G5 784 #define NOTE_GS5 831 #define NOTE_A5 880 #define NOTE_AS5 932 #define NOTE_B5 988 #define NOTE_C6 1047 #define NOTE_CS6 1109 #define NOTE_D6 1175 #define NOTE_DS6 1245 #define NOTE_E6 1319 #define NOTE_F6 1397 #define NOTE_FS6 1480 #define NOTE_G6 1568 #define NOTE_GS6 1661 #define NOTE_A6 1760 #define NOTE_AS6 1865 #define NOTE_B6 1976 #define NOTE_C7 2093 #define NOTE_CS7 2217 #define NOTE_D7 2349 #define NOTE_DS7 2489 #define NOTE_E7 2637 #define NOTE_F7 2794 #define NOTE_FS7 2960 #define NOTE_G7 3136 #define NOTE_GS7 3322 #define NOTE_A7 3520 #define NOTE_AS7 3729 #define NOTE_B7 3951 #define NOTE_C8 4186 #define NOTE_CS8 4435 #define NOTE_D8 4699 #define NOTE_DS8 4978 Arduino-Makefile-1.3.1/examples/toneMelody/toneMelody.ino000066400000000000000000000021501227416204600234150ustar00rootroot00000000000000/* Melody Plays a melody circuit: * 8-ohm speaker on digital pin 8 created 21 Jan 2010 modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. http://arduino.cc/en/Tutorial/Tone */ #include "pitches.h" // notes in the melody: int melody[] = { NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4}; // note durations: 4 = quarter note, 8 = eighth note, etc.: int noteDurations[] = { 4, 8, 8, 4,4,4,4,4 }; void setup() { // iterate over the notes of the melody: for (int thisNote = 0; thisNote < 8; thisNote++) { // to calculate the note duration, take one second // divided by the note type. //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. int noteDuration = 1000/noteDurations[thisNote]; tone(8, melody[thisNote],noteDuration); // to distinguish the notes, set a minimum time between them. // the note's duration + 30% seems to work well: int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); // stop the tone playing: noTone(8); } } void loop() { // no need to repeat the melody. } Arduino-Makefile-1.3.1/licence.txt000066400000000000000000000636421227416204600170120ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library 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 License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! Arduino-Makefile-1.3.1/packaging/000077500000000000000000000000001227416204600165605ustar00rootroot00000000000000Arduino-Makefile-1.3.1/packaging/debian/000077500000000000000000000000001227416204600200025ustar00rootroot00000000000000Arduino-Makefile-1.3.1/packaging/debian/README.md000066400000000000000000000013701227416204600212620ustar00rootroot00000000000000# How to compile a Deb package Use these instructions to build your own Deb package from your local sources. For the latest official packages go to [Debian](http://packages.debian.org/arduino-mk) or [Ubuntu](https://launchpad.net/ubuntu/+source/arduino-mk) or use apt. First install the dependencies for building/running the package, as root: apt-get build-dep arduino-mk apt-get install arduino-core libdevice-serialport-perl help2man build-essential dpkg-dev fakeroot perl-doc devscripts Fetch the Debian source: apt-get source arduino-mk Make any local changes to want within the arduino-mk-* directory and update the package version: cd arduino-mk-* dch -i Then compile. This will create a binary Deb: dpkg-buildpackage -b Arduino-Makefile-1.3.1/packaging/fedora/000077500000000000000000000000001227416204600200205ustar00rootroot00000000000000Arduino-Makefile-1.3.1/packaging/fedora/README.md000066400000000000000000000015441227416204600213030ustar00rootroot00000000000000# How to compile an RPM First install the dependencies as root: yum install arduino-core perl-Device-SerialPort help2man rpm-build From the top-level Arduino-Makefile directory you've checked out of github, run the following (as unprivileged user) to create a compressed tarball using the naming conventions required by rpmbuild: git archive HEAD --prefix=arduino-mk-1.3.1/ -o ../arduino-mk-1.3.1.tar.gz If you don't already have a rpmbuild setup (e.g. you've not installed the SRPM) you will need to create the directories: mkdir -p ~/rpmbuild/{SOURCES,SPECS} Then copy the tarball and specfile into those directories: cp ../arduino-mk-1.3.1.tar.gz ~/rpmbuild/SOURCES/ cp packaging/fedora/arduino-mk.spec ~/rpmbuild/SPECS/ Then compile. This will create a binary and source RPM: cd ~/rpmbuild/SPECS/ rpmbuild -ba arduino-mk.spec Arduino-Makefile-1.3.1/packaging/fedora/arduino-mk.spec000066400000000000000000000042701227416204600227450ustar00rootroot00000000000000Name: arduino-mk Version: 1.3.1 Release: 1%{dist} Summary: Program your Arduino from the command line Packager: Simon John URL: https://github.com/sudar/Arduino-Makefile Source: %{name}-%{version}.tar.gz Group: Development/Tools License: LGPLv2+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch Requires: arduino-core, perl-Device-SerialPort BuildRequires: arduino-core, perl-Device-SerialPort, help2man %description Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. This package will install a Makefile to allow for CLI programming of the Arduino platform. %prep %setup -q %install mkdir -p %{buildroot}/%{_datadir}/arduino mkdir -p %{buildroot}/%{_bindir} mkdir -p %{buildroot}/%{_mandir}/man1 mkdir -p %{buildroot}/%{_docdir}/%{name}/examples install -m 755 -d %{buildroot}/%{_docdir}/%{name} install -m 755 -d %{buildroot}/%{_docdir}/%{name}/examples for dir in `find examples -type d` ; do install -m 755 -d %{buildroot}/%{_docdir}/%{name}/$dir ; done for file in `find examples -type f ! -name .gitignore` ; do install -m 644 $file %{buildroot}/%{_docdir}/%{name}/$file ; done install -m 644 *.mk %{buildroot}/%{_datadir}/arduino install -m 644 licence.txt %{buildroot}/%{_docdir}/%{name} install -m 755 bin/ard-reset-arduino %{buildroot}/%{_bindir}/ard-reset-arduino help2man %{buildroot}/%{_bindir}/ard-reset-arduino -n "Reset Arduino board" -s 1 -m "Arduino CLI Reset" --version-string=%{version} -N -o %{buildroot}/%{_mandir}/man1/ard-reset-arduino.1 %clean rm -rf %{buildroot} %files %defattr(-,root,root,-) %{_bindir}/ard-reset-arduino %{_mandir}/man1/ard-reset-arduino.1* %{_datadir}/arduino/*.mk %doc %{_docdir}/%{name}/licence.txt %docdir %{_docdir}/%{name}/examples %{_docdir}/%{name}/examples %changelog * Sat Feb 01 2014 Simon John - Updated version. * Mon Jan 13 2014 Simon John - Removed arduino-mk subdirectory * Mon Dec 30 2013 Simon John - Initial release.