# Name: Makefile
# Author: Ken Staton
# Copyright: 2008
# License: 

# WinAVR AvrBuild.bat
#"C:\Program Files\Atmel\AVR Tools\AvrAssembler2\avrasm2.exe" -S "C:\AVR_Programming\amforth-3.1\amForth\labels.tmp" -fI -W+ie -o "C:\AVR_Programming\amforth-3.1\amForth\amForth.hex" -d "C:\AVR_Programming\amforth-3.1\amForth\amForth.obj" -e "C:\AVR_Programming\amforth-3.1\amForth\amForth.eep" -m "C:\AVR_Programming\amforth-3.1\amForth\amForth.map" "C:\AVR_Programming\amforth-3.1\core\template.asm"

DEVICE     = atmega128
CLOCK      = 16000000
PROGRAMMER = -c stk500v2 -P usb:76:33
OBJECTS    = main.o
FUSES      = -U hfuse:w:0xc9:m -U lfuse:w:0xff:m
# http://palmavr.sourceforge.net/cgi-bin/fc.cgi
# BOOTSZ=00 + CKOPT=0 + BODLEVEL=1 + CKSEL=1111, SUT=11


# Tune the lines below only if you know what you are doing:

AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
ASSEMBLE = wine /Users/ken/.wine/drive_c/Program\ Files/Atmel/AVR\ Tools/AvrAssembler2/avrasm2.exe -S labels.tmp -fI -W+ie -o amForth.hex -d amForth.obj -e amForth.eep.hex -m amForth.map ../core/template.asm

# symbolic targets:
help:
	@echo "This Makefile has no default rule. Use one of the following:"
	@echo "make hex ....... to build main.hex"
	@echo "make program ... to flash fuses and firmware"
	@echo "make fuse ...... to flash the fuses"
	@echo "make flash ..... to flash the firmware (use this on metaboard)"
	@echo "make clean ..... to delete objects and hex file"

hex:	
	$(ASSEMBLE)


flash:	
	$(AVRDUDE) -U flash:w:amForth.hex:i
	$(AVRDUDE) -U eeprom:w:amForth.eep.hex:i

fuse:
	$(AVRDUDE) $(FUSES)

program: flash fuse

# if you use a bootloader, change the command below appropriately:
#load: all
#	bootloadHID main.hex

clean:
	rm -f amForth.hex amForth.eep.hex amForth.map amForth.obj amForth.aws labels.tmp



