Created
November 13, 2012 05:15
-
-
Save letoh/4064035 to your computer and use it in GitHub Desktop.
makefile for avr project
This file contains hidden or 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
| MCU ?= attiny2313 | |
| PROJ = test | |
| TARGET = $(PROJ).hex # $(PROJ).bin | |
| INC = | |
| LIBS = | |
| include ../000_common/make.rules | |
This file contains hidden or 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
| INC += -I../000_common | |
| CFLAGS = -I/usr/cross/avr/include -mmcu=$(MCU) -Os \ | |
| -fpack-struct -fshort-enums \ | |
| -funsigned-bitfields -funsigned-char \ | |
| -Wall -Wstrict-prototypes \ | |
| -Wa,-ahlms=$(firstword $(filter %.lst, $(<:.c=.lst))) | |
| LDFLAGS = -Wl,-Map,$(PROJ).map,--cref -mmcu=$(MCU) -nostdlib $(LIBS) # -lm | |
| #ASMFLAGS =-I. $(INC) -mmcu=$(MCU) \ | |
| # -x assembler-with-cpp \ | |
| # -Wa,-gstabs,-ahlms=$(firstword $(<:.S=.lst) $(<.asm=.lst)) | |
| ASMFLAGS +=-I. $(INC) -mmcu=$(MCU) \ | |
| -x assembler-with-cpp \ | |
| -Wa,-I../000_common,-ahlms=$(firstword $(<:.S=.lst) $(<.asm=.lst)) | |
| # avr-objdump -h -S -D --stabs --disassemble-zeroes xxx.elf > xxx.lst | |
| CC = avr-gcc | |
| AS = avr-as | |
| LD = avr-ld | |
| OBJCOPY = avr-objcopy | |
| OBJDUMP = avr-objdump | |
| SIZE = avr-size | |
| AVRDUDE = avrdude.delay | |
| ISP = $(AVRDUDE) -c avrisp -p $(MCU) -b 19200 -P /dev/ttyUSB0 -e | |
| .SUFFIXES: | |
| .SUFFIXES: .c .o .elf .hex .bin .S .asm | |
| .c.o: | |
| @echo $^' -> '$@ | |
| @echo 'generate listing...' | |
| @$(CC) -c $(CFLAGS) -o $@ $^ | |
| .S.o: | |
| @echo $^' -> '$@ | |
| @$(CC) -c $(ASMFLAGS) -o $@ $^ | |
| .asm.S: | |
| @echo $^' -> '$@ | |
| @cp $^ $@ | |
| # @$(CC) -c $(ASMFLAGS) -o $@ $^ | |
| .o.elf: | |
| @echo $^' -> '$@ | |
| @echo 'generate map file...' | |
| @$(CC) $(LDFLAGS) -o $@ $^ | |
| @$(OBJDUMP) -h -S -D --stabs --disassemble-zeroes $@ > $@.lst | |
| @$(SIZE) $@ | |
| .elf.hex: | |
| @echo $^' -> '$@ | |
| @$(OBJCOPY) -j .text -j .data -O ihex $^ $@ | |
| .elf.bin: | |
| @echo $^' -> '$@ | |
| @$(OBJCOPY) -j .text -j .data -O binary $^ $@ | |
| .PHONY: | |
| .PHONY: all clean isp | |
| all: $(TARGET) | |
| isp: $(PROJ).hex | |
| $(ISP) -U flash:w:$^ | |
| clean: | |
| @echo "clean..." | |
| @rm -f *.o *.hex *.bin *.map *.elf *.lst | |
| # vim: ft=make | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment