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

MCU=attiny13
F_CPU=1200000
PROG=bsd

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

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

build: morse-beacon.ihex

message.h: message.txt morse.php
	morse.php message.txt > message.h

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

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

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