Subversion Repositories HomeAutomation

Rev

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

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