#MCU := attiny861
#PART := t861

#MCU := atmega88
#PART := m88

MCU := atmega168
PART := m168

#CFLAGS := -O2 -Wall
CFLAGS := -mmcu=$(MCU) -Wall -W -g -Os -mcall-prologues
#ASFLAGS = -a
CFLAGS  += -I../lib_avr/
LDFLAGS += -L../lib_avr/

SRC += $(filter-out Tes%.c,$(wildcard *.c))
SRC := $(sort $(SRC))		# remove possible duplicates

OBJ := $(SRC:.c=.o)


all:	wascator_c240.hex

load:	wascator_c240.load_time

wascator_c240.out:	$(OBJ) ../lib_avr/$(MCU).a

%.hex:	%.out
	avr-size $<
	avr-objcopy -R .eeprom -O ihex $< $@

%.out:	%.o
	avr-gcc -mmcu=$(MCU) -o $@ -Wl,-Map,$*.map -lm $^

%.o:	%.c
	avr-gcc -mmcu=$(MCU) $(CFLAGS) -Wa,-a=$*.list -c $<

%.load_time:	%.hex
	avrdude -p $(PART) -c bsd -q -e -E noreset,novcc -U flash:w:$<
	touch %@

dep:
	avr-gcc $(CFLAGS) -MM *.c > depend.mk

clean:
	-rm -f *.o *~ *.hex *.out *.list *.map clean > /dev/null

-include depend.mk
