TARGET = atmega328p ACPU = m328p TTY = /dev/ttyACM0 DEFS = LIBS = CC = avr-gcc CXX = avr-g++ override CFLAGS = -g -Wall -O2 -mmcu=$(TARGET) $(DEFS) OBJCOPY = avr-objcopy OBJDUMP = avr-objdump all: @echo "Make options:" @echo " $ make program.hex (compile program.[c|cc|cpp] to .hex file)" @echo " $ make program.flash (make .hex file and flash it)" clean: rm -rf *.o *.elf *.hex rm -rf *.lst *.map %.elf: %.o $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) %.hex: %.elf $(OBJCOPY) -j .text -j .data -O ihex $< $@ %.flash: %.hex avrdude -p $(ACPU) -c arduino -P $(TTY) -b 115200 -U flash:w:$^