Rev 66 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 66 | Rev 73 | ||
|---|---|---|---|
| 1 | PRG = main |
1 | PRG = main |
| 2 | OBJ = main.o |
2 | OBJ = main.o |
| 3 | MCU_TARGET = atmega8 |
3 | MCU_TARGET = atmega8 |
| 4 | OPTIMIZE = -O2 |
4 | OPTIMIZE = -O2 |
| 5 | 5 | ||
| 6 | DEFS = |
6 | DEFS = |
| 7 | LIBS = |
7 | LIBS = |
| 8 | 8 | ||
| 9 | # You should not have to change anything below here. |
9 | # You should not have to change anything below here. |
| 10 | 10 | ||
| 11 | CC = avr-gcc |
11 | CC = avr-gcc |
| 12 | 12 | ||
| 13 | # Override is only needed by avr-lib build system. |
13 | # Override is only needed by avr-lib build system. |
| 14 | 14 | ||
| 15 | override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) |
15 | override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) |
| 16 | override LDFLAGS = -Wl,-Map,$(PRG).map |
16 | override LDFLAGS = -Wl,-Map,$(PRG).map |
| 17 | 17 | ||
| 18 | OBJCOPY = avr-objcopy |
18 | OBJCOPY = avr-objcopy |
| 19 | OBJDUMP = avr-objdump |
19 | OBJDUMP = avr-objdump |
| 20 | SIZE = avr-size |
20 | SIZE = avr-size |
| 21 | SZFLAGS = |
21 | SZFLAGS = |
| 22 | UPLOAD = uisp |
22 | UPLOAD = uisp |
| 23 | ULFLAGS = -dpart=$(MCU_TARGET) -dprog=avr910 -dserial=/dev/ttyS0 -dspeed=115200 --erase --upload --verify if=$(PRG).hex |
23 | ULFLAGS = -dpart=$(MCU_TARGET) -dprog=avr910 -dserial=/dev/ttyS0 -dspeed=115200 --erase --upload --verify if=$(PRG).hex |
| 24 | 24 | ||
| 25 | default: $(PRG).elf lst |
25 | default: $(PRG).elf lst |
| 26 | @$(SIZE) $(SZFLAGS) $(PRG).elf |
26 | @$(SIZE) $(SZFLAGS) $(PRG).elf |
| 27 | 27 | ||
| 28 | all: $(PRG).elf lst text eeprom |
28 | all: $(PRG).elf lst text eeprom |
| 29 | 29 | ||
| 30 | $(PRG).elf: $(OBJ) |
30 | $(PRG).elf: $(OBJ) |
| 31 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
31 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
| 32 | 32 | ||
| 33 | clean: |
33 | clean: |
| 34 | rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak |
34 | rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak |
| 35 | rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) |
35 | rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) |
| 36 | 36 | ||
| 37 | lst: $(PRG).lst |
37 | lst: $(PRG).lst |
| 38 | 38 | ||
| 39 | %.lst: %.elf |
39 | %.lst: %.elf |
| 40 | $(OBJDUMP) -h -S $< > $@ |
40 | $(OBJDUMP) -h -S $< > $@ |
| 41 | 41 | ||
| 42 | # Rules for building the .text rom images |
42 | # Rules for building the .text rom images |
| 43 | 43 | ||
| 44 | text: hex bin srec |
44 | text: hex bin srec |
| 45 | 45 | ||
| 46 | hex: $(PRG).hex |
46 | hex: $(PRG).hex |
| 47 | bin: $(PRG).bin |
47 | bin: $(PRG).bin |
| 48 | srec: $(PRG).srec |
48 | srec: $(PRG).srec |
| 49 | 49 | ||
| 50 | %.hex: %.elf |
50 | %.hex: %.elf |
| 51 | $(OBJCOPY) -j .text -j .data -O ihex $< $@ |
51 | $(OBJCOPY) -j .text -j .data -O ihex $< $@ |
| 52 | 52 | ||
| 53 | %.srec: %.elf |
53 | %.srec: %.elf |
| 54 | $(OBJCOPY) -j .text -j .data -O srec $< $@ |
54 | $(OBJCOPY) -j .text -j .data -O srec $< $@ |
| 55 | 55 | ||
| 56 | %.bin: %.elf |
56 | %.bin: %.elf |
| 57 | $(OBJCOPY) -j .text -j .data -O binary $< $@ |
57 | $(OBJCOPY) -j .text -j .data -O binary $< $@ |
| 58 | 58 | ||
| 59 | # Rules for uploading rom images to flash |
59 | # Rules for uploading rom images to flash |
| 60 | 60 | ||
| 61 | install: hex |
61 | install: hex |
| 62 | $(UPLOAD) $(ULFLAGS) |
62 | $(UPLOAD) $(ULFLAGS) |
| 63 | 63 | ||
| 64 | # Rules for building the .eeprom rom images |
64 | # Rules for building the .eeprom rom images |
| 65 | 65 | ||
| 66 | eeprom: ehex ebin esrec |
66 | eeprom: ehex ebin esrec |
| 67 | 67 | ||
| 68 | ehex: $(PRG)_eeprom.hex |
68 | ehex: $(PRG)_eeprom.hex |
| 69 | ebin: $(PRG)_eeprom.bin |
69 | ebin: $(PRG)_eeprom.bin |
| 70 | esrec: $(PRG)_eeprom.srec |
70 | esrec: $(PRG)_eeprom.srec |
| 71 | 71 | ||
| 72 | %_eeprom.hex: %.elf |
72 | %_eeprom.hex: %.elf |
| 73 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ |
73 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ |
| 74 | 74 | ||
| 75 | %_eeprom.srec: %.elf |
75 | %_eeprom.srec: %.elf |
| 76 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ |
76 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ |
| 77 | 77 | ||
| 78 | %_eeprom.bin: %.elf |
78 | %_eeprom.bin: %.elf |
| 79 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ |
79 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ |
| 80 | 80 | ||
| 81 | # Every thing below here is used by avr-libc's build system and can be ignored |
81 | # Every thing below here is used by avr-libc's build system and can be ignored |
| 82 | # by the casual user. |
82 | # by the casual user. |
| 83 | 83 | ||
| 84 | FIG2DEV = fig2dev |
84 | FIG2DEV = fig2dev |
| 85 | EXTRA_CLEAN_FILES = *.hex *.bin *.srec |
85 | EXTRA_CLEAN_FILES = *.hex *.bin *.srec |
| 86 | 86 | ||
| 87 | dox: eps png pdf |
87 | dox: eps png pdf |
| 88 | 88 | ||
| 89 | eps: $(PRG).eps |
89 | eps: $(PRG).eps |
| 90 | png: $(PRG).png |
90 | png: $(PRG).png |
| 91 | pdf: $(PRG).pdf |
91 | pdf: $(PRG).pdf |
| 92 | 92 | ||
| 93 | %.eps: %.fig |
93 | %.eps: %.fig |
| 94 | $(FIG2DEV) -L eps $< $@ |
94 | $(FIG2DEV) -L eps $< $@ |
| 95 | 95 | ||
| 96 | %.pdf: %.fig |
96 | %.pdf: %.fig |
| 97 | $(FIG2DEV) -L pdf $< $@ |
97 | $(FIG2DEV) -L pdf $< $@ |
| 98 | 98 | ||
| 99 | %.png: %.fig |
99 | %.png: %.fig |
| 100 | $(FIG2DEV) -L png $< $@ |
100 | $(FIG2DEV) -L png $< $@ |
| 101 | 101 | ||