-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
111 lines (68 loc) · 2.53 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
SRC = $(wildcard *.c)
OBJS = $(SRC:%.c=%.o)
HEADERS = $(SRC:%.c=%.h)
PRG = main
OBJ = program.o
MCU_TARGET = atmega32
OPTIMIZE = -O2
#OPTIMIZE =
# DEFS = -W1,-u,vprintf -lprintf_flt -lm
DEFS =
LIBS =
# You should not have to change anything below here.
CC = avr-gcc
CXX = avr-g++
# Override is only needed by avr-lib build system.
# override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) -I/usr/local/avr/include
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) -I/usr/local/avr/avr/include
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) -I/usr/lib/avr/include/avr
override CXXFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override LDFLAGS = -Wl,-Map,$(PRG).map
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
all: $(PRG).elf lst text eeprom size
$(PRG).elf: $(SRC) $(HEADERS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(PRG).elf $(SRC) $(LIBS)
clean:
rm -rf *.o $(PRG).elf
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
install:
avrdude -c pony-stk200 -p m32 -e -U flash:w:$(PRG).hex
usbinstall:
avrdude -c avrisp2 -P usb -p m32 -e -U flash:w:$(PRG).hex
aspinstall:
avrdude -c usbasp -P usb -p m32 -e -U flash:w:$(PRG).hex
usbfuseint:
avrdude -c avrisp2 -P usb -p m32 -U hfuse:w:0xD9:m -U lfuse:w:0xE1:m
usbfuseext:
avrdude -c avrisp2 -P usb -p m32 -U hfuse:w:0xD9:m -U lfuse:w:0xEF:m
lst: $(PRG).lst
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
# Rules for building the .text rom images
text: hex bin srec
hex: $(PRG).hex
bin: $(PRG).bin
srec: $(PRG).srec
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.srec: %.elf
$(OBJCOPY) -j .text -j .data -O srec $< $@
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@
# Rules for building the .eeprom rom images
eeprom: ehex ebin esrec
ehex: $(PRG)_eeprom.hex
ebin: $(PRG)_eeprom.bin
esrec: $(PRG)_eeprom.srec
%_eeprom.hex: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
%_eeprom.srec: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
%_eeprom.bin: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
# Every thing below here is used by avr-libc's build system and can be ignored
# by the casual user.
EXTRA_CLEAN_FILES = *.hex *.bin *.srec
size: ${PRG}.elf
avr-size -C --mcu=${MCU_TARGET} ${PRG}.elf