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