Subversion Repositories HomeAutomation

Rev

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

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