CC = avr-gcc OBJECTS = Ringbuffer.o TWISlave.o TWIMaster.o F_CPU ?= 16000000L CFLAGS += -Wall -O3 -std=gnu99 -mmcu=atmega8 -DF_CPU=$(F_CPU) all: keyboard.hex keyboard.elf: $(OBJECTS) main.o $(CC) $(CFLAGS) -o $@.new $^ && mv $@.new $@ TWISlave.o: TWISlave.c TWISlave.h Ringbuffer.h TWIMaster.o: TWIMaster.c TWIMaster.h Ringbuffer.h Ringbuffer.o: Ringbuffer.c Ringbuffer.h main.o: main.c TWISlave.h %.hex: %.elf avr-objcopy -j .text -j .data -O ihex $^ $@ clean: rm -f keyboard.hex keyboard.elf $(OBJECTS) main.o distclean: clean upload: keyboard.hex sudo avrdude -p m8 -c usbtiny -U flash:w:$<