Subversion Repositories HomeAutomation

Rev

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

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