Created
October 1, 2016 14:21
-
-
Save naotaco/1ce1f274504b5bf5cf28b8fb4db65fe5 to your computer and use it in GitHub Desktop.
Makefile sample for AVR program with USBasp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET = atmega88 | |
COMPILE = avr-gcc -Wall -O2 -I. -mmcu=$(TARGET) # -DDEBUG_LEVEL=2 | |
OBJECTS = main.o | |
all: main.hex | |
.c.o: | |
$(COMPILE) -c $< -o $@ | |
.S.o: | |
$(COMPILE) -x assembler-with-cpp -c $< -o $@ | |
.c.s: | |
$(COMPILE) -S $< -o $@ | |
clean: | |
rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o main.s | |
main.bin: $(OBJECTS) | |
$(COMPILE) -o main.bin $(OBJECTS) -Wl,-Map,main.map | |
main.hex: main.bin | |
rm -f main.hex main.eep.hex | |
avr-objcopy -j .text -j .data -O ihex main.bin main.hex | |
cpp: | |
$(COMPILE) -E main.c | |
flash: | |
avrdude -c usbasp -p $(TARGET) -U flash:w:main.hex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment