Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 183 | andfri | 1 | PRG = main |
| 2 | OBJ = main.o |
||
| 232 | arune | 3 | MCU_TARGET = atmega88 |
| 183 | andfri | 4 | OPTIMIZE = -Os -mcall-prologues |
| 229 | andfri | 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 |
||
| 313 | andfri | 7 | BIOS_RAM_END = 0x0080012a |
| 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 | |
| 236 | arune | 30 | default: $(PRG).elf lst text |
| 183 | andfri | 31 | @$(SIZE) $(SZFLAGS) $(PRG).elf |
| 32 | |||
| 33 | all: $(PRG).elf lst text eeprom |
||
| 34 | |||
| 35 | $(PRG).elf: $(OBJ) |
||
| 313 | andfri | 36 | ifeq ($(MCU_TARGET),atmega88) |
| 37 | #remove this workaround when gcc-bug fixed |
||
| 38 | 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 |
||
| 39 | else |
||
| 183 | andfri | 40 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
| 313 | andfri | 41 | endif |
| 183 | andfri | 42 | |
| 43 | clean: |
||
| 44 | rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak |
||
| 45 | rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) |
||
| 46 | |||
| 47 | lst: $(PRG).lst |
||
| 48 | |||
| 49 | %.lst: %.elf |
||
| 50 | $(OBJDUMP) -h -S $< > $@ |
||
| 51 | |||
| 52 | # Rules for building the .text rom images |
||
| 53 | |||
| 54 | text: hex bin srec |
||
| 55 | |||
| 56 | hex: $(PRG).hex |
||
| 57 | bin: $(PRG).bin |
||
| 58 | srec: $(PRG).srec |
||
| 59 | |||
| 60 | %.hex: %.elf |
||
| 61 | $(OBJCOPY) -j .text -j .data -O ihex $< $@ |
||
| 62 | |||
| 63 | %.srec: %.elf |
||
| 64 | $(OBJCOPY) -j .text -j .data -O srec $< $@ |
||
| 65 | |||
| 66 | %.bin: %.elf |
||
| 67 | $(OBJCOPY) -j .text -j .data -O binary $< $@ |
||
| 68 | |||
| 69 | # Rules for uploading rom images to flash |
||
| 70 | |||
| 71 | install: hex |
||
| 72 | $(UPLOAD) $(ULFLAGS) |
||
| 73 | |||
| 74 | # Rules for building the .eeprom rom images |
||
| 75 | |||
| 76 | eeprom: ehex ebin esrec |
||
| 77 | |||
| 78 | ehex: $(PRG)_eeprom.hex |
||
| 79 | ebin: $(PRG)_eeprom.bin |
||
| 80 | esrec: $(PRG)_eeprom.srec |
||
| 81 | |||
| 82 | %_eeprom.hex: %.elf |
||
| 83 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ |
||
| 84 | |||
| 85 | %_eeprom.srec: %.elf |
||
| 86 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ |
||
| 87 | |||
| 88 | %_eeprom.bin: %.elf |
||
| 89 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ |
||
| 90 | |||
| 91 | # Every thing below here is used by avr-libc's build system and can be ignored |
||
| 92 | # by the casual user. |
||
| 93 | |||
| 94 | FIG2DEV = fig2dev |
||
| 95 | EXTRA_CLEAN_FILES = *.hex *.bin *.srec |
||
| 96 | |||
| 97 | dox: eps png pdf |
||
| 98 | |||
| 99 | eps: $(PRG).eps |
||
| 100 | png: $(PRG).png |
||
| 101 | pdf: $(PRG).pdf |
||
| 102 | |||
| 103 | %.eps: %.fig |
||
| 104 | $(FIG2DEV) -L eps $< $@ |
||
| 105 | |||
| 106 | %.pdf: %.fig |
||
| 107 | $(FIG2DEV) -L pdf $< $@ |
||
| 108 | |||
| 109 | %.png: %.fig |
||
| 110 | $(FIG2DEV) -L png $< $@ |
||
| 111 |