Subversion Repositories HomeAutomation

Rev

Rev 21 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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