1 # (1) Project Information
3 PROJECT_LIBS = SPI RF24 ;
5 # (2) Board Information
7 UPLOAD_PROTOCOL ?= stk500v1 ;
8 UPLOAD_SPEED ?= 57600 ;
13 ARDUINO_VERSION ?= 100 ;
17 PORTS = p4 p6 p9 u0 u1 u2 ;
18 PORT_p6 = /dev/tty.usbserial-A600eHIs ;
19 PORT_p4 = /dev/tty.usbserial-A40081RP ;
20 PORT_p9 = /dev/tty.usbserial-A9007LmI ;
21 PORT_u0 = /dev/ttyUSB0 ;
22 PORT_u1 = /dev/ttyUSB1 ;
23 PORT_u2 = /dev/ttyUSB2 ;
25 # (4) Location of AVR tools
27 # This configuration assumes using avr-tools that were obtained separate from the Arduino
32 AVR_BIN = /usr/local/avrtools/bin ;
33 AVR_ETC = /usr/local/avrtools/etc ;
34 AVR_INCLUDE = /usr/local/avrtools/include ;
39 AVR_INCLUDE = /usr/lib/avr/include ;
43 # (5) Directories where Arduino core and libraries are located
45 ARDUINO_DIR ?= /opt/Arduino ;
46 ARDUINO_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/$(CORE) $(ARDUINO_DIR)/hardware/arduino/variants/$(VARIANT) ;
47 ARDUINO_LIB = $(ARDUINO_DIR)/libraries ;
48 SKETCH_LIB = $(HOME)/Source/Arduino/libraries ;
51 # --------------------------------------------------
52 # Below this line usually never needs to be modified
57 CC = $(AVR_BIN)/avr-gcc ;
58 C++ = $(AVR_BIN)/avr-g++ ;
59 LINK = $(AVR_BIN)/avr-gcc ;
60 OBJCOPY = $(AVR_BIN)/avr-objcopy ;
61 AVRDUDE = $(AVR_BIN)/avrdude ;
65 DEFINES += F_CPU=$(F_CPU)L ARDUINO=$(ARDUINO_VERSION) VERSION_H ;
67 CCFLAGS = -Wall -Wextra -mmcu=$(MCU) -ffunction-sections -fdata-sections ;
68 C++FLAGS = $(CCFLAGS) -fno-exceptions -fno-strict-aliasing ;
69 LINKFLAGS = $(OPTIM) -lm -Wl,--gc-sections -mmcu=$(MCU) ;
70 AVRDUDEFLAGS = -V -F -D -C $(AVR_ETC)/avrdude.conf -p $(MCU) -c $(UPLOAD_PROTOCOL) -b $(UPLOAD_SPEED) ;
72 # Search everywhere for headers
74 HDRS = $(PWD) $(AVR_INCLUDE) $(ARDUINO_CORE) $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) ;
78 LOCATE_TARGET = $(F_CPU) ;
79 LOCATE_SOURCE = $(F_CPU) ;
93 echo "const char program_version[] = \"\\" > $(<)
94 git log -1 --pretty=format:%h >> $(<)
98 GitVersion version.h ;
102 Depends $(<) : $(>) ;
103 MakeLocate $(<) : $(LOCATE_SOURCE) ;
107 if ( $(ARDUINO_VERSION) < 100 )
109 ARDUINO_H = WProgram.h ;
113 ARDUINO_H = Arduino.h ;
118 echo "#include <$(ARDUINO_H)>" > $(<)
119 echo "#line 1 \"$(>)\"" >> $(<)
125 local _CPP = $(>:B).cpp ;
134 case .ino : C++Pde $(<) : $(>) ;
135 case .pde : C++Pde $(<) : $(>) ;
143 for _i in [ FGristFiles $(<) ]
145 local _b = $(_i:B)$(SUFOBJ) ;
146 local _o = $(_b:G=$(SOURCE_GRIST:E)) ;
147 Object $(_o) : $(_i) ;
148 Depends obj : $(_o) ;
154 MainFromObjects $(<) : $(>:B)$(SUFOBJ) ;
160 Depends $(<) : $(>) ;
161 MakeLocate $(<) : $(LOCATE_TARGET) ;
168 $(OBJCOPY) -O ihex -R .eeprom $(>) $(<)
173 Depends $(1) : $(2) ;
174 Depends $(2) : $(3) ;
178 UploadAction $(2) : $(3) ;
183 $(AVRDUDE) $(AVRDUDEFLAGS) -P $(<) $(AVRDUDE_WRITE_FLASH) -U flash:w:$(>):i
190 # Grab everything from the core directory
191 CORE_MODULES = [ GLOB $(ARDUINO_CORE) : *.c *.cpp ] ;
193 # Grab everything from libraries. To avoid this "grab everything" behaviour, you
194 # can specify specific modules to pick up in PROJECT_MODULES
195 LIB_MODULES = [ GLOB $(ARDUINO_LIB)/$(PROJECT_LIBS) $(ARDUINO_LIB)/$(PROJECT_LIBS)/utility $(SKETCH_LIB)/$(PROJECT_LIBS) : *.cpp *.c ] ;
197 # Grab everything from the current dir
198 PROJECT_MODULES += [ GLOB $(PWD) : *.c *.cpp *.pde *.ino ] ;
200 # Main output executable
201 MAIN = $(PWD:B).elf ;
203 Main $(MAIN) : $(CORE_MODULES) $(LIB_MODULES) $(PROJECT_MODULES) ;
204 Hex $(MAIN:B).hex : $(MAIN) ;
209 Upload $(_p) : $(PORT_$(_p)) : $(MAIN:B).hex ;