# Arduino Makefile (for Windows 2000)
# Nick Zambetti and David A. Mellis
# $Id$

# Windows 2000 seems to need backslashes in certain commands
# (e.g. bin\rm in the compile rule below) where Windows XP
# wants forward slashes.  Hence this makefile.

# By default, this makefile uses the serial device specified by
# Wiring (either in the Tools | Serial Port menu or the Wiring
# preferences file in the sketchbook directory) and passed as
# an argument to make.  To override this value, uncomment the
# following line and change the value to the desired device.
# SERIAL=com1

# The Wiring Lite IDE runs the "compile" rule when you click the play button.
compile:
	-bin\rm tmp/*
	bin\cat include/wiringlite.inc > tmp/prog.c
	bin\cat ../build/*.c >> tmp/prog.c
	bin\cp include/* tmp
	bin\cp ../../cyg*.dll tmp
	bin\gnumake -s -C tmp

# The IDE runs the "program" rule when you hit the export button.
# The string after the colon determines the method used to 
# program the microcontroller: program-using-bootloader,
# program-with-isp, or program-over-parallel-port.
program: program-using-bootloader-avrdude

# This rule is for uploading code using a bootloader already on
# the microcontroller.  It should run at the baud rate specified
# in the bootloader's code, currently 9600 baud.
program-using-bootloader-avrdude:
	bin/avrdude -p atmega8 -P ${SERIAL} -c stk500@9600 -V -U flash:w:tmp/prog.hex

# This rule is for uploading code using a bootloader already on
# the microcontroller.  It should run at the baud rate specified
# in the bootloader's code, currently 9600 baud.
program-using-bootloader:
	cp ../../cyg*.dll .
	bin/uisp -dprog=stk500 -dspeed=9600 -dserial=${SERIAL} -dpart=ATmega8 if=tmp/prog.hex --upload

# This rule is for uploading code using an in-system programmer,
# e.g. the one sold by Atmel.  In this case, you want to erase the
# microcontroller, upload the code, and then verify it.
# Atmel's isp follows the stk500 protocol and works at 115200 baud.
program-with-isp:
	cp ../../cyg*.dll .
	bin/uisp -dprog=stk500 -dspeed=115200 -dserial=${SERIAL} -dpart=ATmega8 if=tmp/prog.hex --erase --upload --verify

# This rule is for uploading code using a parallel port programmer.
program-over-parallel-port:
	cp ../../cyg*.dll .
	bin/uisp -dprog=dapa -dpart=ATmega8 if=tmp/prog.hex -dlpt=0x378 --erase --upload
