| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 6 | kaklik | #---------------------------------------------------------------------------------- |
| 2 | # GCC-AVR standard Makefile part 3 |
||
| 3 | # Based on Volker Oth's makefiles of jan.2000 |
||
| 4 | # Modified and merged by AVRfreaks.net for smoother integration with AVR Studio, |
||
| 5 | # and easier comprehension for the average user (nov.2001). Minor errors corrected. |
||
| 6 | # --------------------------------------------------------------------------------- |
||
| 7 | |||
| 8 | ###### BLOCK 1) define some variables based on the AVR base path in $(AVR) ####### |
||
| 9 | |||
| 10 | CC = avr-gcc |
||
| 11 | AS = avr-gcc -x assembler-with-cpp |
||
| 12 | RM = rm -f |
||
| 13 | RN = mv |
||
| 14 | CP = cp |
||
| 15 | BIN = avr-objcopy |
||
| 16 | SIZE = avr-size |
||
| 17 | INCDIR = . |
||
| 18 | # LIBDIR = $(AVR)/avr/lib |
||
| 19 | # SHELL = $(AVR)/bin/sh.exe |
||
| 20 | |||
| 21 | |||
| 22 | ###### BLOCK 2) output format can be srec, ihex (avrobj is always created) ####### |
||
| 23 | |||
| 24 | FORMAT = ihex |
||
| 25 | |||
| 26 | |||
| 27 | ###### BLOCK 3) define all project specific object files ###### |
||
| 28 | |||
| 29 | SRC += $(AVRLIBSRC) |
||
| 30 | OBJ = $(ASRC:.s=.o) $(SRC:.c=.o) |
||
| 31 | CPFLAGS += -mmcu=$(MCU) |
||
| 32 | ASFLAGS += -mmcu=$(MCU) |
||
| 33 | LDFLAGS += -mmcu=$(MCU) |
||
| 34 | |||
| 35 | ###### BLOCK 4) this defines the aims of the make process ###### |
||
| 36 | |||
| 37 | #all: $(TRG).obj $(TRG).elf $(TRG).hex $(TRG).cof $(TRG).eep $(TRG).ok |
||
| 38 | all: $(TRG).elf $(TRG).cof $(TRG).hex $(TRG).eep $(TRG).ok |
||
| 39 | |||
| 40 | |||
| 41 | ###### BLOCK 5) compile: instructions to create assembler and/or object files from C source ###### |
||
| 42 | |||
| 43 | %.o : %.c |
||
| 44 | $(CC) -c $(CPFLAGS) -I$(INCDIR) $< -o $@ |
||
| 45 | |||
| 46 | %.s : %.c |
||
| 47 | $(CC) -S $(CPFLAGS) -I$(INCDIR) $< -o $@ |
||
| 48 | |||
| 49 | |||
| 50 | ###### BLOCK 6) assemble: instructions to create object file from assembler files ###### |
||
| 51 | |||
| 52 | %.o : %.s |
||
| 53 | $(AS) -c $(ASFLAGS) -I$(INCDIR) $< -o $@ |
||
| 54 | |||
| 55 | |||
| 56 | ###### BLOCK 7) link: instructions to create elf output file from object files ###### |
||
| 57 | %.elf: $(OBJ) |
||
| 58 | $(CC) $(OBJ) $(LIB) $(LDFLAGS) -o $@ |
||
| 59 | |||
| 60 | ###### BLOCK 8) create avrobj file from elf output file ###### |
||
| 61 | |||
| 62 | #%.obj: %.elf |
||
| 63 | # $(BIN) -O avrobj -R .eeprom $< $@ |
||
| 64 | |||
| 65 | |||
| 66 | ###### BLOCK 9) create bin (.hex and .eep) files from elf output file ###### |
||
| 67 | |||
| 68 | %.hex: %.elf |
||
| 69 | $(BIN) -O $(FORMAT) -R .eeprom $< $@ |
||
| 70 | |||
| 71 | %.eep: %.elf |
||
| 72 | $(BIN) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
||
| 73 | |||
| 74 | %.cof: %.elf |
||
| 75 | $(BIN) --debugging -O coff-ext-avr \ |
||
| 76 | --change-section-address .data-0x800000 \ |
||
| 77 | --change-section-address .bss-0x800000 \ |
||
| 78 | --change-section-address .noinit-0x800000 \ |
||
| 79 | --change-section-address .eeprom-0x810000 \ |
||
| 80 | $< $@ |
||
| 81 | |||
| 82 | |||
| 83 | ###### BLOCK 10) If all other steps compile ok then echo "Errors: none" ###### |
||
| 84 | |||
| 85 | %ok: |
||
| 86 | $(SIZE) $(TRG).elf |
||
| 87 | @echo "Errors: none" |
||
| 88 | |||
| 89 | |||
| 90 | ###### BLOCK 11) make instruction to delete created files ###### |
||
| 91 | |||
| 92 | clean: |
||
| 93 | $(RM) $(OBJ) |
||
| 94 | $(RM) $(SRC:.c=.s) |
||
| 95 | $(RM) $(SRC:.c=.lst) |
||
| 96 | $(RM) $(TRG).map |
||
| 97 | $(RM) $(TRG).elf |
||
| 98 | $(RM) $(TRG).cof |
||
| 99 | $(RM) $(TRG).obj |
||
| 100 | $(RM) $(TRG).a90 |
||
| 101 | $(RM) $(TRG).hex |
||
| 102 | $(RM) $(TRG).sym |
||
| 103 | $(RM) $(TRG).eep |
||
| 104 | $(RM) $(TRG).hex |
||
| 105 | $(RM) *.bak |
||
| 106 | $(RM) *.log |
||
| 107 | @echo "Errors: none" |
||
| 108 | |||
| 109 | size: |
||
| 110 | $(SIZE) $(TRG).elf |
||
| 111 |
Powered by WebSVN v2.8.3