Subversion Repositories HomeAutomation

Rev

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

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