# # This makefile will # - download the specified version of the Arduino IDE # - compile the necessary files and create a library out of them # - create a header file for including in your Arduino programs # - install the header and library on your system # # To do all this, put this makefile in an empty directory and type # "make install". Type "make deinstall" to undo. # # Only tested with Arduino Duemilanove with ATmega328p. May work with # others, but then again, it may not. # # You will need: # - avr-gcc # - avr-binutils # - wget # - sed # - m4 # # Contact: avf [at] eldamar.org.uk # # Your board MCU = atmega328p F_CPU = 16000000 # Version of Arduino IDE to use VER = 0017 # Where your AVR include and lib directories live DEST = /usr/local/avr ############### URL = http://www.arduino.cc/files/arduino-$(VER).tgz DIR = arduino-$(VER)/hardware/cores/arduino OBJ = $(DIR)/WInterrupts.o $(DIR)/pins_arduino.o \ $(DIR)/wiring.o $(DIR)/wiring_analog.o \ $(DIR)/wiring_digital.o $(DIR)/wiring_pulse.o \ $(DIR)/wiring_shift.o $(DIR)/HardwareSerial.o \ $(DIR)/Print.o $(DIR)/WMath.o LIB = libarduino.a HDR = arduino.h CC = avr-gcc CXX = avr-g++ AR = avr-ar CPP = avr-cpp INSTALL = install CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -gstabs -I. -Os -Wall CXXFLAGS= $(CFLAGS) ############### all: header lib download: test -d arduino-$(VER) || wget -q -O - $(URL) | tar xvzf - lib: $(LIB) $(LIB): download $(OBJ) $(AR) r $(LIB) *.o header: $(HDR) $(HDR): download cp $(DIR)/WProgram.h $(HDR) while (grep -q '#include "' $(HDR)); do (echo 'changequote([,])define([inc],[include($(DIR)/$$1)])dnl'; sed 's/#include "\(.*\)"$$/inc([\1])/' $(HDR)) | m4 > $(HDR).tmp && mv $(HDR).tmp $(HDR); done install: lib header $(INSTALL) -c -m 644 $(LIB) $(DEST)/lib $(INSTALL) -c -m 644 $(HDR) $(DEST)/include uninstall: deinstall deinstall: rm -f $(DEST)/lib/$(LIB) $(DEST)/include/$(HDR) clean: rm -rf *.o distclean: clean rm -rf $(LIB) $(HDR) arduino-$(VER)