Rev 29 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 29 | Rev 31 | ||
---|---|---|---|
1 | #-------------------------------------------------------------------- |
1 | #-------------------------------------------------------------------- |
2 | # MCU name |
2 | # MCU name |
3 | MCU = atmega8 |
3 | MCU = atmega8 |
4 | #------------------------------------------------------------------- |
4 | #------------------------------------------------------------------- |
5 | HAUPT_VERSION = 0 |
5 | HAUPT_VERSION = 0 |
6 | NEBEN_VERSION = 31 |
6 | NEBEN_VERSION = 31 |
7 | #------------------------------------------------------------------- |
7 | #------------------------------------------------------------------- |
8 | 8 | ||
9 | # Output format. (can be srec, ihex, binary) |
9 | # Output format. (can be srec, ihex, binary) |
10 | FORMAT = ihex |
10 | FORMAT = ihex |
11 | 11 | ||
12 | # Target file name (without extension). |
12 | # Target file name (without extension). |
13 | TARGET = BrushLess-Ctrl_V$(HAUPT_VERSION)_$(NEBEN_VERSION) |
13 | TARGET = BrushLess-Ctrl_8kHz_PWM_V$(HAUPT_VERSION)_$(NEBEN_VERSION) |
14 | 14 | ||
15 | # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. |
15 | # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. |
16 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
16 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
17 | OPT = s |
17 | OPT = s |
18 | 18 | ||
19 | ########################################################################################################## |
19 | ########################################################################################################## |
20 | # List C source files here. (C dependencies are automatically generated.) |
20 | # List C source files here. (C dependencies are automatically generated.) |
21 | SRC = main.c uart.c timer0.c analog.c PPM_Decode.c twislave.c BLMC.c |
21 | SRC = main.c uart.c timer0.c analog.c PPM_Decode.c twislave.c BLMC.c |
22 | #printf_P.c |
22 | #printf_P.c |
23 | ########################################################################################################## |
23 | ########################################################################################################## |
24 | 24 | ||
25 | # If there is more than one source file, append them above, or modify and |
25 | # If there is more than one source file, append them above, or modify and |
26 | # uncomment the following: |
26 | # uncomment the following: |
27 | #SRC += foo.c bar.c |
27 | #SRC += foo.c bar.c |
28 | 28 | ||
29 | # You can also wrap lines by appending a backslash to the end of the line: |
29 | # You can also wrap lines by appending a backslash to the end of the line: |
30 | #SRC += baz.c \ |
30 | #SRC += baz.c \ |
31 | #xyzzy.c |
31 | #xyzzy.c |
32 | 32 | ||
33 | 33 | ||
34 | 34 | ||
35 | # List Assembler source files here. |
35 | # List Assembler source files here. |
36 | # Make them always end in a capital .S. Files ending in a lowercase .s |
36 | # Make them always end in a capital .S. Files ending in a lowercase .s |
37 | # will not be considered source files but generated files (assembler |
37 | # will not be considered source files but generated files (assembler |
38 | # output from the compiler), and will be deleted upon "make clean"! |
38 | # output from the compiler), and will be deleted upon "make clean"! |
39 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
39 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
40 | # it will preserve the spelling of the filenames, and gcc itself does |
40 | # it will preserve the spelling of the filenames, and gcc itself does |
41 | # care about how the name is spelled on its command-line. |
41 | # care about how the name is spelled on its command-line. |
42 | ASRC = |
42 | ASRC = |
43 | 43 | ||
44 | 44 | ||
45 | # List any extra directories to look for include files here. |
45 | # List any extra directories to look for include files here. |
46 | # Each directory must be seperated by a space. |
46 | # Each directory must be seperated by a space. |
47 | EXTRAINCDIRS = |
47 | EXTRAINCDIRS = |
48 | 48 | ||
49 | 49 | ||
50 | # Optional compiler flags. |
50 | # Optional compiler flags. |
51 | # -g: generate debugging information (for GDB, or for COFF conversion) |
51 | # -g: generate debugging information (for GDB, or for COFF conversion) |
52 | # -O*: optimization level |
52 | # -O*: optimization level |
53 | # -f...: tuning, see gcc manual and avr-libc documentation |
53 | # -f...: tuning, see gcc manual and avr-libc documentation |
54 | # -Wall...: warning level |
54 | # -Wall...: warning level |
55 | # -Wa,...: tell GCC to pass this to the assembler. |
55 | # -Wa,...: tell GCC to pass this to the assembler. |
56 | # -ahlms: create assembler listing |
56 | # -ahlms: create assembler listing |
57 | CFLAGS = -g -O$(OPT) \ |
57 | CFLAGS = -g -O$(OPT) \ |
58 | -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \ |
58 | -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \ |
59 | -Wall -Wstrict-prototypes \ |
59 | -Wall -Wstrict-prototypes \ |
60 | -Wa,-adhlns=$(<:.c=.lst) \ |
60 | -Wa,-adhlns=$(<:.c=.lst) \ |
61 | $(patsubst %,-I%,$(EXTRAINCDIRS)) |
61 | $(patsubst %,-I%,$(EXTRAINCDIRS)) |
62 | 62 | ||
63 | 63 | ||
64 | # Set a "language standard" compiler flag. |
64 | # Set a "language standard" compiler flag. |
65 | # Unremark just one line below to set the language standard to use. |
65 | # Unremark just one line below to set the language standard to use. |
66 | # gnu99 = C99 + GNU extensions. See GCC manual for more information. |
66 | # gnu99 = C99 + GNU extensions. See GCC manual for more information. |
67 | #CFLAGS += -std=c89 |
67 | #CFLAGS += -std=c89 |
68 | #CFLAGS += -std=gnu89 |
68 | #CFLAGS += -std=gnu89 |
69 | #CFLAGS += -std=c99 |
69 | #CFLAGS += -std=c99 |
70 | CFLAGS += -std=gnu99 |
70 | CFLAGS += -std=gnu99 |
71 | 71 | ||
72 | CFLAGS += -DVERSION_HAUPTVERSION=$(HAUPT_VERSION) -DVERSION_NEBENVERSION=$(NEBEN_VERSION) |
72 | CFLAGS += -DVERSION_HAUPTVERSION=$(HAUPT_VERSION) -DVERSION_NEBENVERSION=$(NEBEN_VERSION) |
73 | 73 | ||
74 | ifeq ($(AVR_CTRL_PLATINE), 1) |
74 | ifeq ($(AVR_CTRL_PLATINE), 1) |
75 | CFLAGS += -DAVR_CTRL_PLATINE=$(AVR_CTRL_PLATINE) |
75 | CFLAGS += -DAVR_CTRL_PLATINE=$(AVR_CTRL_PLATINE) |
76 | endif |
76 | endif |
77 | 77 | ||
78 | 78 | ||
79 | 79 | ||
80 | # Optional assembler flags. |
80 | # Optional assembler flags. |
81 | # -Wa,...: tell GCC to pass this to the assembler. |
81 | # -Wa,...: tell GCC to pass this to the assembler. |
82 | # -ahlms: create listing |
82 | # -ahlms: create listing |
83 | # -gstabs: have the assembler create line number information; note that |
83 | # -gstabs: have the assembler create line number information; note that |
84 | # for use in COFF files, additional information about filenames |
84 | # for use in COFF files, additional information about filenames |
85 | # and function names needs to be present in the assembler source |
85 | # and function names needs to be present in the assembler source |
86 | # files -- see avr-libc docs [FIXME: not yet described there] |
86 | # files -- see avr-libc docs [FIXME: not yet described there] |
87 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
87 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
88 | 88 | ||
89 | 89 | ||
90 | 90 | ||
91 | # Optional linker flags. |
91 | # Optional linker flags. |
92 | # -Wl,...: tell GCC to pass this to linker. |
92 | # -Wl,...: tell GCC to pass this to linker. |
93 | # -Map: create map file |
93 | # -Map: create map file |
94 | # --cref: add cross reference to map file |
94 | # --cref: add cross reference to map file |
95 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
95 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
96 | 96 | ||
97 | 97 | ||
98 | 98 | ||
99 | # Additional libraries |
99 | # Additional libraries |
100 | 100 | ||
101 | # Minimalistic printf version |
101 | # Minimalistic printf version |
102 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_min |
102 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_min |
103 | 103 | ||
104 | # Floating point printf version (requires -lm below) |
104 | # Floating point printf version (requires -lm below) |
105 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt |
105 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt |
106 | 106 | ||
107 | # -lm = math library |
107 | # -lm = math library |
108 | LDFLAGS += -lm |
108 | LDFLAGS += -lm |
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | # Programming support using avrdude. Settings and variables. |
113 | # Programming support using avrdude. Settings and variables. |
114 | 114 | ||
115 | # Programming hardware: alf avr910 avrisp bascom bsd |
115 | # Programming hardware: alf avr910 avrisp bascom bsd |
116 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
116 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
117 | # |
117 | # |
118 | # Type: avrdude -c ? |
118 | # Type: avrdude -c ? |
119 | # to get a full listing. |
119 | # to get a full listing. |
120 | # |
120 | # |
121 | 121 | ||
122 | AVRDUDE_PROGRAMMER = dt006 |
122 | AVRDUDE_PROGRAMMER = dt006 |
123 | #AVRDUDE_PROGRAMMER = stk200 |
123 | #AVRDUDE_PROGRAMMER = stk200 |
124 | 124 | ||
125 | #AVRDUDE_PORT = com1 # programmer connected to serial device |
125 | #AVRDUDE_PORT = com1 # programmer connected to serial device |
126 | AVRDUDE_PORT = lpt1 # programmer connected to parallel port |
126 | AVRDUDE_PORT = lpt1 # programmer connected to parallel port |
127 | 127 | ||
128 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
128 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
129 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
129 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
130 | 130 | ||
131 | AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
131 | AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
132 | 132 | ||
133 | # Uncomment the following if you want avrdude's erase cycle counter. |
133 | # Uncomment the following if you want avrdude's erase cycle counter. |
134 | # Note that this counter needs to be initialized first using -Yn, |
134 | # Note that this counter needs to be initialized first using -Yn, |
135 | # see avrdude manual. |
135 | # see avrdude manual. |
136 | #AVRDUDE_ERASE += -y |
136 | #AVRDUDE_ERASE += -y |
137 | 137 | ||
138 | # Uncomment the following if you do /not/ wish a verification to be |
138 | # Uncomment the following if you do /not/ wish a verification to be |
139 | # performed after programming the device. |
139 | # performed after programming the device. |
140 | #AVRDUDE_FLAGS += -V -E noreset |
140 | #AVRDUDE_FLAGS += -V -E noreset |
141 | 141 | ||
142 | 142 | ||
143 | # Increase verbosity level. Please use this when submitting bug |
143 | # Increase verbosity level. Please use this when submitting bug |
144 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
144 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
145 | # to submit bug reports. |
145 | # to submit bug reports. |
146 | #AVRDUDE_FLAGS += -v -v |
146 | #AVRDUDE_FLAGS += -v -v |
147 | 147 | ||
148 | 148 | ||
149 | 149 | ||
150 | 150 | ||
151 | # --------------------------------------------------------------------------- |
151 | # --------------------------------------------------------------------------- |
152 | 152 | ||
153 | # Define directories, if needed. |
153 | # Define directories, if needed. |
154 | DIRAVR = c:/winavr |
154 | DIRAVR = c:/winavr |
155 | DIRAVRBIN = $(DIRAVR)/bin |
155 | DIRAVRBIN = $(DIRAVR)/bin |
156 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
156 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
157 | DIRINC = . |
157 | DIRINC = . |
158 | DIRLIB = $(DIRAVR)/avr/lib |
158 | DIRLIB = $(DIRAVR)/avr/lib |
159 | 159 | ||
160 | 160 | ||
161 | # Define programs and commands. |
161 | # Define programs and commands. |
162 | SHELL = sh |
162 | SHELL = sh |
163 | 163 | ||
164 | CC = avr-gcc |
164 | CC = avr-gcc |
165 | 165 | ||
166 | OBJCOPY = avr-objcopy |
166 | OBJCOPY = avr-objcopy |
167 | OBJDUMP = avr-objdump |
167 | OBJDUMP = avr-objdump |
168 | SIZE = avr-size |
168 | SIZE = avr-size |
169 | 169 | ||
170 | 170 | ||
171 | # Programming support using avrdude. |
171 | # Programming support using avrdude. |
172 | AVRDUDE = avrdude |
172 | AVRDUDE = avrdude |
173 | 173 | ||
174 | 174 | ||
175 | REMOVE = rm -f |
175 | REMOVE = rm -f |
176 | COPY = cp |
176 | COPY = cp |
177 | 177 | ||
178 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
178 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
179 | ELFSIZE = $(SIZE) -A $(TARGET).elf |
179 | ELFSIZE = $(SIZE) -A $(TARGET).elf |
180 | 180 | ||
181 | 181 | ||
182 | 182 | ||
183 | # Define Messages |
183 | # Define Messages |
184 | # English |
184 | # English |
185 | MSG_ERRORS_NONE = Errors: none |
185 | MSG_ERRORS_NONE = Errors: none |
186 | MSG_BEGIN = -------- begin -------- |
186 | MSG_BEGIN = -------- begin -------- |
187 | MSG_END = -------- end -------- |
187 | MSG_END = -------- end -------- |
188 | MSG_SIZE_BEFORE = Size before: |
188 | MSG_SIZE_BEFORE = Size before: |
189 | MSG_SIZE_AFTER = Size after: |
189 | MSG_SIZE_AFTER = Size after: |
190 | MSG_COFF = Converting to AVR COFF: |
190 | MSG_COFF = Converting to AVR COFF: |
191 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
191 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
192 | MSG_FLASH = Creating load file for Flash: |
192 | MSG_FLASH = Creating load file for Flash: |
193 | MSG_EEPROM = Creating load file for EEPROM: |
193 | MSG_EEPROM = Creating load file for EEPROM: |
194 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
194 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
195 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
195 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
196 | MSG_LINKING = Linking: |
196 | MSG_LINKING = Linking: |
197 | MSG_COMPILING = Compiling: |
197 | MSG_COMPILING = Compiling: |
198 | MSG_ASSEMBLING = Assembling: |
198 | MSG_ASSEMBLING = Assembling: |
199 | MSG_CLEANING = Cleaning project: |
199 | MSG_CLEANING = Cleaning project: |
200 | 200 | ||
201 | 201 | ||
202 | 202 | ||
203 | 203 | ||
204 | # Define all object files. |
204 | # Define all object files. |
205 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
205 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
206 | 206 | ||
207 | # Define all listing files. |
207 | # Define all listing files. |
208 | LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
208 | LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
209 | 209 | ||
210 | # Combine all necessary flags and optional flags. |
210 | # Combine all necessary flags and optional flags. |
211 | # Add target processor to flags. |
211 | # Add target processor to flags. |
212 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
212 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
213 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
213 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
214 | 214 | ||
215 | 215 | ||
216 | 216 | ||
217 | # Default target. |
217 | # Default target. |
218 | all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ |
218 | all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ |
219 | $(TARGET).lss $(TARGET).sym sizeafter finished end |
219 | $(TARGET).lss $(TARGET).sym sizeafter finished end |
220 | 220 | ||
221 | 221 | ||
222 | # Eye candy. |
222 | # Eye candy. |
223 | # AVR Studio 3.x does not check make's exit code but relies on |
223 | # AVR Studio 3.x does not check make's exit code but relies on |
224 | # the following magic strings to be generated by the compile job. |
224 | # the following magic strings to be generated by the compile job. |
225 | begin: |
225 | begin: |
226 | @echo |
226 | @echo |
227 | @echo $(MSG_BEGIN) |
227 | @echo $(MSG_BEGIN) |
228 | 228 | ||
229 | finished: |
229 | finished: |
230 | @echo $(MSG_ERRORS_NONE) |
230 | @echo $(MSG_ERRORS_NONE) |
231 | 231 | ||
232 | end: |
232 | end: |
233 | @echo $(MSG_END) |
233 | @echo $(MSG_END) |
234 | @echo |
234 | @echo |
235 | 235 | ||
236 | 236 | ||
237 | # Display size of file. |
237 | # Display size of file. |
238 | sizebefore: |
238 | sizebefore: |
239 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
239 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
240 | 240 | ||
241 | sizeafter: |
241 | sizeafter: |
242 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
242 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
243 | 243 | ||
244 | 244 | ||
245 | 245 | ||
246 | # Display compiler version information. |
246 | # Display compiler version information. |
247 | gccversion : |
247 | gccversion : |
248 | @$(CC) --version |
248 | @$(CC) --version |
249 | 249 | ||
250 | 250 | ||
251 | 251 | ||
252 | 252 | ||
253 | # Convert ELF to COFF for use in debugging / simulating in |
253 | # Convert ELF to COFF for use in debugging / simulating in |
254 | # AVR Studio or VMLAB. |
254 | # AVR Studio or VMLAB. |
255 | COFFCONVERT=$(OBJCOPY) --debugging \ |
255 | COFFCONVERT=$(OBJCOPY) --debugging \ |
256 | --change-section-address .data-0x800000 \ |
256 | --change-section-address .data-0x800000 \ |
257 | --change-section-address .bss-0x800000 \ |
257 | --change-section-address .bss-0x800000 \ |
258 | --change-section-address .noinit-0x800000 \ |
258 | --change-section-address .noinit-0x800000 \ |
259 | --change-section-address .eeprom-0x810000 |
259 | --change-section-address .eeprom-0x810000 |
260 | 260 | ||
261 | 261 | ||
262 | coff: $(TARGET).elf |
262 | coff: $(TARGET).elf |
263 | @echo |
263 | @echo |
264 | @echo $(MSG_COFF) $(TARGET).cof |
264 | @echo $(MSG_COFF) $(TARGET).cof |
265 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
265 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
266 | 266 | ||
267 | 267 | ||
268 | extcoff: $(TARGET).elf |
268 | extcoff: $(TARGET).elf |
269 | @echo |
269 | @echo |
270 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
270 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
271 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
271 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
272 | 272 | ||
273 | 273 | ||
274 | 274 | ||
275 | 275 | ||
276 | # Program the device. |
276 | # Program the device. |
277 | program: $(TARGET).hex $(TARGET).eep |
277 | program: $(TARGET).hex $(TARGET).eep |
278 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
278 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
279 | 279 | ||
280 | 280 | ||
281 | 281 | ||
282 | 282 | ||
283 | # Create final output files (.hex, .eep) from ELF output file. |
283 | # Create final output files (.hex, .eep) from ELF output file. |
284 | %.hex: %.elf |
284 | %.hex: %.elf |
285 | @echo |
285 | @echo |
286 | @echo $(MSG_FLASH) $@ |
286 | @echo $(MSG_FLASH) $@ |
287 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
287 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
288 | 288 | ||
289 | %.eep: %.elf |
289 | %.eep: %.elf |
290 | @echo |
290 | @echo |
291 | @echo $(MSG_EEPROM) $@ |
291 | @echo $(MSG_EEPROM) $@ |
292 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
292 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
293 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
293 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
294 | 294 | ||
295 | # Create extended listing file from ELF output file. |
295 | # Create extended listing file from ELF output file. |
296 | %.lss: %.elf |
296 | %.lss: %.elf |
297 | @echo |
297 | @echo |
298 | @echo $(MSG_EXTENDED_LISTING) $@ |
298 | @echo $(MSG_EXTENDED_LISTING) $@ |
299 | $(OBJDUMP) -h -S $< > $@ |
299 | $(OBJDUMP) -h -S $< > $@ |
300 | 300 | ||
301 | # Create a symbol table from ELF output file. |
301 | # Create a symbol table from ELF output file. |
302 | %.sym: %.elf |
302 | %.sym: %.elf |
303 | @echo |
303 | @echo |
304 | @echo $(MSG_SYMBOL_TABLE) $@ |
304 | @echo $(MSG_SYMBOL_TABLE) $@ |
305 | avr-nm -n $< > $@ |
305 | avr-nm -n $< > $@ |
306 | 306 | ||
307 | 307 | ||
308 | 308 | ||
309 | # Link: create ELF output file from object files. |
309 | # Link: create ELF output file from object files. |
310 | .SECONDARY : $(TARGET).elf |
310 | .SECONDARY : $(TARGET).elf |
311 | .PRECIOUS : $(OBJ) |
311 | .PRECIOUS : $(OBJ) |
312 | %.elf: $(OBJ) |
312 | %.elf: $(OBJ) |
313 | @echo |
313 | @echo |
314 | @echo $(MSG_LINKING) $@ |
314 | @echo $(MSG_LINKING) $@ |
315 | $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
315 | $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
316 | 316 | ||
317 | 317 | ||
318 | # Compile: create object files from C source files. |
318 | # Compile: create object files from C source files. |
319 | %.o : %.c |
319 | %.o : %.c |
320 | @echo |
320 | @echo |
321 | @echo $(MSG_COMPILING) $< |
321 | @echo $(MSG_COMPILING) $< |
322 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
322 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
323 | 323 | ||
324 | 324 | ||
325 | # Compile: create assembler files from C source files. |
325 | # Compile: create assembler files from C source files. |
326 | %.s : %.c |
326 | %.s : %.c |
327 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
327 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
328 | 328 | ||
329 | 329 | ||
330 | # Assemble: create object files from assembler source files. |
330 | # Assemble: create object files from assembler source files. |
331 | %.o : %.S |
331 | %.o : %.S |
332 | @echo |
332 | @echo |
333 | @echo $(MSG_ASSEMBLING) $< |
333 | @echo $(MSG_ASSEMBLING) $< |
334 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
334 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
335 | 335 | ||
336 | 336 | ||
337 | 337 | ||
338 | 338 | ||
339 | 339 | ||
340 | 340 | ||
341 | # Target: clean project. |
341 | # Target: clean project. |
342 | clean: begin clean_list finished end |
342 | clean: begin clean_list finished end |
343 | 343 | ||
344 | clean_list : |
344 | clean_list : |
345 | @echo |
345 | @echo |
346 | @echo $(MSG_CLEANING) |
346 | @echo $(MSG_CLEANING) |
347 | # $(REMOVE) $(TARGET).hex |
347 | # $(REMOVE) $(TARGET).hex |
348 | # $(REMOVE) $(TARGET).eep |
348 | # $(REMOVE) $(TARGET).eep |
349 | # $(REMOVE) $(TARGET).obj |
349 | # $(REMOVE) $(TARGET).obj |
350 | $(REMOVE) $(TARGET).cof |
350 | $(REMOVE) $(TARGET).cof |
351 | $(REMOVE) $(TARGET).elf |
351 | $(REMOVE) $(TARGET).elf |
352 | $(REMOVE) $(TARGET).map |
352 | $(REMOVE) $(TARGET).map |
353 | $(REMOVE) $(TARGET).obj |
353 | $(REMOVE) $(TARGET).obj |
354 | $(REMOVE) $(TARGET).a90 |
354 | $(REMOVE) $(TARGET).a90 |
355 | $(REMOVE) $(TARGET).sym |
355 | $(REMOVE) $(TARGET).sym |
356 | $(REMOVE) $(TARGET).lnk |
356 | $(REMOVE) $(TARGET).lnk |
357 | $(REMOVE) $(TARGET).lss |
357 | $(REMOVE) $(TARGET).lss |
358 | $(REMOVE) $(OBJ) |
358 | $(REMOVE) $(OBJ) |
359 | $(REMOVE) $(LST) |
359 | $(REMOVE) $(LST) |
360 | $(REMOVE) $(SRC:.c=.s) |
360 | $(REMOVE) $(SRC:.c=.s) |
361 | $(REMOVE) $(SRC:.c=.d) |
361 | $(REMOVE) $(SRC:.c=.d) |
362 | 362 | ||
363 | 363 | ||
364 | # Automatically generate C source code dependencies. |
364 | # Automatically generate C source code dependencies. |
365 | # (Code originally taken from the GNU make user manual and modified |
365 | # (Code originally taken from the GNU make user manual and modified |
366 | # (See README.txt Credits).) |
366 | # (See README.txt Credits).) |
367 | # |
367 | # |
368 | # Note that this will work with sh (bash) and sed that is shipped with WinAVR |
368 | # Note that this will work with sh (bash) and sed that is shipped with WinAVR |
369 | # (see the SHELL variable defined above). |
369 | # (see the SHELL variable defined above). |
370 | # This may not work with other shells or other seds. |
370 | # This may not work with other shells or other seds. |
371 | # |
371 | # |
372 | %.d: %.c |
372 | %.d: %.c |
373 | set -e; $(CC) -MM $(ALL_CFLAGS) $< \ |
373 | set -e; $(CC) -MM $(ALL_CFLAGS) $< \ |
374 | | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ |
374 | | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ |
375 | [ -s $@ ] || rm -f $@ |
375 | [ -s $@ ] || rm -f $@ |
376 | 376 | ||
377 | 377 | ||
378 | # Remove the '-' if you want to see the dependency files generated. |
378 | # Remove the '-' if you want to see the dependency files generated. |
379 | -include $(SRC:.c=.d) |
379 | -include $(SRC:.c=.d) |
380 | 380 | ||
381 | 381 | ||
382 | 382 | ||
383 | # Listing of phony targets. |
383 | # Listing of phony targets. |
384 | .PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \ |
384 | .PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \ |
385 | clean clean_list program |
385 | clean clean_list program |
386 | 386 |