Subversion Repositories HomeAutomation

Rev

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

Rev 232 Rev 235
1
PRG            = main
1
PRG            = main
2
OBJ            = main.o
2
OBJ            = main.o
3
MCU_TARGET     = atmega88
3
MCU_TARGET     = atmega88
4
OPTIMIZE       = -Os -mcall-prologues
4
OPTIMIZE       = -Os -mcall-prologues
5
# grep bios.map for __bios_ram_end to retreive this value
5
# grep bios.map for __bios_ram_end to retreive this value
6
# In the future, this should be automatically inserted into *_app.ld at every bios compilation
6
# In the future, this should be automatically inserted into *_app.ld at every bios compilation
7
BIOS_RAM_END   = 0x0080015d
7
BIOS_RAM_END   = 0x0080015d
8
#uncomment this line if you're using m88, remove line when gcc-bug fixed
8
#uncomment this line if you're using m88, remove line when gcc-bug fixed
9
#EXTRA_LD        = avr-ld -m avr4 -o $(PRG).elf /usr/avr/lib/avr4/crtm88.o -L/usr/lib/gcc/avr/4.1.0/avr4 -L/usr/lib/gcc/avr/4.1.0/avr4 -L/usr/avr/lib/avr4 -Map $(PRG).map -L../AVR-Bios --defsym __bios_ram_end=0x0080015d -T$(MCU_TARGET)_app.ld $(PRG).o -lgcc -lc -lgcc
9
EXTRA_LD        = avr-ld -m avr4 -o $(PRG).elf /usr/avr/lib/avr4/crtm88.o -L/usr/lib/gcc/avr/4.1.0/avr4 -L/usr/lib/gcc/avr/4.1.0/avr4 -L/usr/avr/lib/avr4 -Map $(PRG).map -L../AVR-Bios --defsym __bios_ram_end=$(BIOS_RAM_END) -T$(MCU_TARGET)_app.ld $(PRG).o -lgcc -lc -lgcc
10
 
10
 
11
DEFS           = -I../AVR-Bios
11
DEFS           = -I../AVR-Bios
12
LIBS           =
12
LIBS           =
13
 
13
 
14
# You should not have to change anything below here.
14
# You should not have to change anything below here.
15
 
15
 
16
CC             = avr-gcc
16
CC             = avr-gcc
17
 
17
 
18
# Override is only needed by avr-lib build system.
18
# Override is only needed by avr-lib build system.
19
 
19
 
20
override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
20
override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
21
override LDFLAGS       = -v -Wl,-Map,$(PRG).map,-L../AVR-Bios,--defsym,__bios_ram_end=$(BIOS_RAM_END),-T$(MCU_TARGET)_app.ld
21
override LDFLAGS       = -v -Wl,-Map,$(PRG).map,-L../AVR-Bios,--defsym,__bios_ram_end=$(BIOS_RAM_END),-T$(MCU_TARGET)_app.ld
22
override ASFLAGS       = -x assembler-with-cpp -Wa,-gstabs -mmcu=$(MCU_TARGET) $(DEFS)
22
override ASFLAGS       = -x assembler-with-cpp -Wa,-gstabs -mmcu=$(MCU_TARGET) $(DEFS)
23
 
23
 
24
OBJCOPY        = avr-objcopy
24
OBJCOPY        = avr-objcopy
25
OBJDUMP        = avr-objdump
25
OBJDUMP        = avr-objdump
26
SIZE           = avr-size
26
SIZE           = avr-size
27
SZFLAGS        = 
27
SZFLAGS        = 
28
UPLOAD         = avrdude
28
UPLOAD         = avrdude
29
ULFLAGS        = -p $(MCU_TARGET) -D -P /dev/ttyUSB0 -c avrispv2 -b 115200 -U flash:w:$(PRG).hex
29
ULFLAGS        = -p $(MCU_TARGET) -D -P /dev/ttyUSB0 -c avrispv2 -b 115200 -U flash:w:$(PRG).hex
30
# -D disables erase!
30
# -D disables erase!
31
 
31
 
32
default: $(PRG).elf lst
32
default: $(PRG).elf lst
33
	@$(SIZE) $(SZFLAGS) $(PRG).elf
33
	@$(SIZE) $(SZFLAGS) $(PRG).elf
34
 
34
 
35
all: $(PRG).elf lst text eeprom
35
all: $(PRG).elf lst text eeprom
36
 
36
 
37
$(PRG).elf: $(OBJ)
37
$(PRG).elf: $(OBJ)
38
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
38
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
39
	$(EXTRA_LD)
39
	$(EXTRA_LD)
40
 
40
 
41
clean:
41
clean:
42
	rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak 
42
	rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak 
43
	rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
43
	rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
44
 
44
 
45
lst:  $(PRG).lst
45
lst:  $(PRG).lst
46
 
46
 
47
%.lst: %.elf
47
%.lst: %.elf
48
	$(OBJDUMP) -h -S $< > $@
48
	$(OBJDUMP) -h -S $< > $@
49
 
49
 
50
# Rules for building the .text rom images
50
# Rules for building the .text rom images
51
 
51
 
52
text: hex bin srec
52
text: hex bin srec
53
 
53
 
54
hex:  $(PRG).hex
54
hex:  $(PRG).hex
55
bin:  $(PRG).bin
55
bin:  $(PRG).bin
56
srec: $(PRG).srec
56
srec: $(PRG).srec
57
 
57
 
58
%.hex: %.elf
58
%.hex: %.elf
59
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
59
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
60
 
60
 
61
%.srec: %.elf
61
%.srec: %.elf
62
	$(OBJCOPY) -j .text -j .data -O srec $< $@
62
	$(OBJCOPY) -j .text -j .data -O srec $< $@
63
 
63
 
64
%.bin: %.elf
64
%.bin: %.elf
65
	$(OBJCOPY) -j .text -j .data -O binary $< $@
65
	$(OBJCOPY) -j .text -j .data -O binary $< $@
66
 
66
 
67
# Rules for uploading rom images to flash
67
# Rules for uploading rom images to flash
68
 
68
 
69
install: hex
69
install: hex
70
	$(UPLOAD) $(ULFLAGS)
70
	$(UPLOAD) $(ULFLAGS)
71
 
71
 
72
# Rules for building the .eeprom rom images
72
# Rules for building the .eeprom rom images
73
 
73
 
74
eeprom: ehex ebin esrec
74
eeprom: ehex ebin esrec
75
 
75
 
76
ehex:  $(PRG)_eeprom.hex
76
ehex:  $(PRG)_eeprom.hex
77
ebin:  $(PRG)_eeprom.bin
77
ebin:  $(PRG)_eeprom.bin
78
esrec: $(PRG)_eeprom.srec
78
esrec: $(PRG)_eeprom.srec
79
 
79
 
80
%_eeprom.hex: %.elf
80
%_eeprom.hex: %.elf
81
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
81
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
82
 
82
 
83
%_eeprom.srec: %.elf
83
%_eeprom.srec: %.elf
84
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
84
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
85
 
85
 
86
%_eeprom.bin: %.elf
86
%_eeprom.bin: %.elf
87
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
87
	$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
88
 
88
 
89
# Every thing below here is used by avr-libc's build system and can be ignored
89
# Every thing below here is used by avr-libc's build system and can be ignored
90
# by the casual user.
90
# by the casual user.
91
 
91
 
92
FIG2DEV                 = fig2dev
92
FIG2DEV                 = fig2dev
93
EXTRA_CLEAN_FILES       = *.hex *.bin *.srec
93
EXTRA_CLEAN_FILES       = *.hex *.bin *.srec
94
 
94
 
95
dox: eps png pdf
95
dox: eps png pdf
96
 
96
 
97
eps: $(PRG).eps
97
eps: $(PRG).eps
98
png: $(PRG).png
98
png: $(PRG).png
99
pdf: $(PRG).pdf
99
pdf: $(PRG).pdf
100
 
100
 
101
%.eps: %.fig
101
%.eps: %.fig
102
	$(FIG2DEV) -L eps $< $@
102
	$(FIG2DEV) -L eps $< $@
103
 
103
 
104
%.pdf: %.fig
104
%.pdf: %.fig
105
	$(FIG2DEV) -L pdf $< $@
105
	$(FIG2DEV) -L pdf $< $@
106
 
106
 
107
%.png: %.fig
107
%.png: %.fig
108
	$(FIG2DEV) -L png $< $@
108
	$(FIG2DEV) -L png $< $@
109
 
109