OC=avr-objcopy
CC=avr-gcc
AD=avrdude

MCU=attiny13
F_CPU=9600000
PROG=bsd

CDEFS=-DF_CPU=$(F_CPU)UL
CFLAGS=-Os -mcall-prologues -Wall -mmcu=$(MCU)

dummy:
	@echo "targets include 'build', 'program' and 'clean'"

build: beacon.ihex

sinetable.h: sinetable.php
	sinetable.php > sinetable.h

message.h: message.txt varicode.php
	varicode.php message.txt > message.h

beacon.ihex: beacon.c sinetable.h message.h Makefile
	$(CC) $(CFLAGS) $(CDEFS) beacon.c -o beacon.out
	$(OC) -j .text -O ihex beacon.out beacon.ihex

program: beacon.ihex
	$(AD) -p $(MCU) -c $(PROG) -e -U flash:w:beacon.ihex -U lfuse:w:0x7A:m

clean:
	rm -f message.h sinetable.h *.out *.ihex
