Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
21 andfri 1
PRG            = main
2
OBJ            = main.o
3
MCU_TARGET     = atmega8
4
OPTIMIZE       = -O2
5
 
6
DEFS           =
7
LIBS           =
8
 
9
# You should not have to change anything below here.
10
 
11
CC             = avr-gcc
12
 
13
# Override is only needed by avr-lib build system.
14
 
15
override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
16
override LDFLAGS       = -Wl,-Map,$(PRG).map
17
 
18
OBJCOPY        = avr-objcopy
19
OBJDUMP        = avr-objdump
20
UPLOAD         = uisp
21
ULFLAGS        = -dpart=$(MCU_TARGET) -dprog=avr910 -dserial=/dev/ttyS0 -dspeed=115200 --erase --upload --verify if=$(PRG).hex
22
 
23
default: $(PRG).elf lst
24
 
25
all: $(PRG).elf lst text eeprom
26
 
27
$(PRG).elf: $(OBJ)
28
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
29
 
30
clean:
31
	rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak 
32
	rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
33
 
34
lst:  $(PRG).lst
35
 
36
%.lst: %.elf
37
	$(OBJDUMP) -h -S $< > $@
38
 
39
# Rules for building the .text rom images
40
 
41
text: hex bin srec
42
 
43
hex:  $(PRG).hex
44
bin:  $(PRG).bin
45
srec: $(PRG).srec
46
 
47
%.hex: %.elf
48
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
49
 
50
%.srec: %.elf
51
	$(OBJCOPY) -j .text -j .data -O srec $< $@
52
 
53
%.bin: %.elf
54
	$(OBJCOPY) -j .text -j .data -O binary $< $@
55
 
56
# Rules for uploading rom images to flash
57
 
58
install: hex
59
	$(UPLOAD) $(ULFLAGS)
60
 
61
# Rules for building the .eeprom rom images
62
 
63
eeprom: ehex ebin esrec
64
 
65
ehex:  $(PRG)_eeprom.hex
66
ebin:  $(PRG)_eeprom.bin
67
esrec: $(PRG)_eeprom.srec
68
 
69
%_eeprom.hex: %.elf
70
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
71
 
72
%_eeprom.srec: %.elf
73
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
74
 
75
%_eeprom.bin: %.elf
76
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
77
 
78
# Every thing below here is used by avr-libc's build system and can be ignored
79
# by the casual user.
80
 
81
FIG2DEV                 = fig2dev
82
EXTRA_CLEAN_FILES       = *.hex *.bin *.srec
83
 
84
dox: eps png pdf
85
 
86
eps: $(PRG).eps
87
png: $(PRG).png
88
pdf: $(PRG).pdf
89
 
90
%.eps: %.fig
91
	$(FIG2DEV) -L eps $< $@
92
 
93
%.pdf: %.fig
94
	$(FIG2DEV) -L pdf $< $@
95
 
96
%.png: %.fig
97
	$(FIG2DEV) -L png $< $@
98