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 |
||
| 232 | arune | 7 | BIOS_RAM_END = 0x0080015d |
| 236 | arune | 8 | ifeq ($(MCU_TARGET),atmega88) |
| 9 | #uncomment this line if you're using m88, remove line when gcc-bug fixed |
||
| 10 | 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 |
||
| 11 | endif |
||
| 183 | andfri | 12 | |
| 223 | andfri | 13 | DEFS = -I../AVR-Bios |
| 183 | andfri | 14 | LIBS = |
| 15 | |||
| 16 | # You should not have to change anything below here. |
||
| 17 | |||
| 18 | CC = avr-gcc |
||
| 19 | |||
| 20 | # Override is only needed by avr-lib build system. |
||
| 231 | arune | 21 | |
| 183 | andfri | 22 | override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) |
| 229 | andfri | 23 | override LDFLAGS = -v -Wl,-Map,$(PRG).map,-L../AVR-Bios,--defsym,__bios_ram_end=$(BIOS_RAM_END),-T$(MCU_TARGET)_app.ld |
| 24 | override ASFLAGS = -x assembler-with-cpp -Wa,-gstabs -mmcu=$(MCU_TARGET) $(DEFS) |
||
| 183 | andfri | 25 | |
| 26 | OBJCOPY = avr-objcopy |
||
| 27 | OBJDUMP = avr-objdump |
||
| 28 | SIZE = avr-size |
||
| 29 | SZFLAGS = |
||
| 231 | arune | 30 | UPLOAD = avrdude |
| 31 | ULFLAGS = -p $(MCU_TARGET) -D -P /dev/ttyUSB0 -c avrispv2 -b 115200 -U flash:w:$(PRG).hex |
||
| 32 | # -D disables erase! |
||
| 183 | andfri | 33 | |
| 236 | arune | 34 | default: $(PRG).elf lst text |
| 183 | andfri | 35 | @$(SIZE) $(SZFLAGS) $(PRG).elf |
| 36 | |||
| 37 | all: $(PRG).elf lst text eeprom |
||
| 38 | |||
| 39 | $(PRG).elf: $(OBJ) |
||
| 40 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
||
| 232 | arune | 41 | $(EXTRA_LD) |
| 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 |