1 | # Hey Emacs, this is a -*- makefile -*-
|
2 | #----------------------------------------------------------------------------
|
3 | # WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
|
4 | #
|
5 | # Released to the Public Domain
|
6 | #
|
7 | # Additional material for this makefile was written by:
|
8 | # Peter Fleury
|
9 | # Tim Henigan
|
10 | # Colin O'Flynn
|
11 | # Reiner Patommel
|
12 | # Markus Pfaff
|
13 | # Sander Pool
|
14 | # Frederik Rouleau
|
15 | # Carlos Lamas
|
16 | #
|
17 | #----------------------------------------------------------------------------
|
18 | # On command line:
|
19 | #
|
20 | # make all = Make software.
|
21 | #
|
22 | # make clean = Clean out built project files.
|
23 | #
|
24 | # make coff = Convert ELF to AVR COFF.
|
25 | #
|
26 | # make extcoff = Convert ELF to AVR Extended COFF.
|
27 | #
|
28 | # make program = Download the hex file to the device, using avrdude.
|
29 | # Please customize the avrdude settings below first!
|
30 | #
|
31 | # make debug = Start either simulavr or avarice as specified for debugging,
|
32 | # with avr-gdb or avr-insight as the front end for debugging.
|
33 | #
|
34 | # make filename.s = Just compile filename.c into the assembler code only.
|
35 | #
|
36 | # make filename.i = Create a preprocessed source file for use in submitting
|
37 | # bug reports to the GCC project.
|
38 | #
|
39 | # To rebuild project do "make clean" then "make all".
|
40 | #----------------------------------------------------------------------------
|
41 |
|
42 |
|
43 | # MCU name
|
44 | MCU = atmega128
|
45 |
|
46 |
|
47 | # Processor frequency.
|
48 | # This will define a symbol, F_CPU, in all source code files equal to the
|
49 | # processor frequency. You can then use this symbol in your source code to
|
50 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
51 | # automatically to create a 32-bit value in your source code.
|
52 | # Typical values are:
|
53 | # F_CPU = 1000000
|
54 | # F_CPU = 1843200
|
55 | # F_CPU = 2000000
|
56 | # F_CPU = 3686400
|
57 | # F_CPU = 4000000
|
58 | # F_CPU = 7372800
|
59 | # F_CPU = 8000000
|
60 | # F_CPU = 11059200
|
61 | # F_CPU = 14745600
|
62 | # F_CPU = 16000000
|
63 | # F_CPU = 18432000
|
64 | # F_CPU = 20000000
|
65 | F_CPU = 16000000
|
66 |
|
67 |
|
68 | # Output format. (can be srec, ihex, binary)
|
69 | FORMAT = ihex
|
70 |
|
71 |
|
72 | # Target file name (without extension).
|
73 | TARGET = main
|
74 |
|
75 |
|
76 | # Object files directory
|
77 | # To put object files in current directory, use a dot (.), do NOT make
|
78 | # this an empty or blank macro!
|
79 | OBJDIR = .
|
80 |
|
81 |
|
82 | # List C source files here. (C dependencies are automatically generated.)
|
83 | SRC = $(TARGET).c
|
84 |
|
85 |
|
86 | # List C++ source files here. (C dependencies are automatically generated.)
|
87 | CPPSRC =
|
88 |
|
89 |
|
90 | # List Assembler source files here.
|
91 | # Make them always end in a capital .S. Files ending in a lowercase .s
|
92 | # will not be considered source files but generated files (assembler
|
93 | # output from the compiler), and will be deleted upon "make clean"!
|
94 | # Even though the DOS/Win* filesystem matches both .s and .S the same,
|
95 | # it will preserve the spelling of the filenames, and gcc itself does
|
96 | # care about how the name is spelled on its command-line.
|
97 | ASRC =
|
98 |
|
99 |
|
100 | # Optimization level, can be [0, 1, 2, 3, s].
|
101 | # 0 = turn off optimization. s = optimize for size.
|
102 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
103 | OPT = s
|
104 |
|
105 |
|
106 | # Debugging format.
|
107 | # Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
|
108 | # AVR Studio 4.10 requires dwarf-2.
|
109 | # AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
|
110 | DEBUG = dwarf-2
|
111 |
|
112 |
|
113 | # List any extra directories to look for include files here.
|
114 | # Each directory must be seperated by a space.
|
115 | # Use forward slashes for directory separators.
|
116 | # For a directory that has spaces, enclose it in quotes.
|
117 | EXTRAINCDIRS =
|
118 |
|
119 |
|
120 | # Compiler flag to set the C Standard level.
|
121 | # c89 = "ANSI" C
|
122 | # gnu89 = c89 plus GCC extensions
|
123 | # c99 = ISO C99 standard (not yet fully implemented)
|
124 | # gnu99 = c99 plus GCC extensions
|
125 | CSTANDARD = -std=gnu99
|
126 |
|
127 |
|
128 | # Place -D or -U options here for C sources
|
129 | CDEFS = -DF_CPU=$(F_CPU)UL
|
130 |
|
131 |
|
132 | # Place -D or -U options here for ASM sources
|
133 | ADEFS = -DF_CPU=$(F_CPU)
|
134 |
|
135 |
|
136 | # Place -D or -U options here for C++ sources
|
137 | CPPDEFS = -DF_CPU=$(F_CPU)UL
|
138 | #CPPDEFS += -D__STDC_LIMIT_MACROS
|
139 | #CPPDEFS += -D__STDC_CONSTANT_MACROS
|
140 |
|
141 |
|
142 |
|
143 | #---------------- Compiler Options C ----------------
|
144 | # -g*: generate debugging information
|
145 | # -O*: optimization level
|
146 | # -f...: tuning, see GCC manual and avr-libc documentation
|
147 | # -Wall...: warning level
|
148 | # -Wa,...: tell GCC to pass this to the assembler.
|
149 | # -adhlns...: create assembler listing
|
150 | CFLAGS = -g$(DEBUG)
|
151 | CFLAGS += $(CDEFS)
|
152 | CFLAGS += -O$(OPT)
|
153 | CFLAGS += -funsigned-char
|
154 | CFLAGS += -funsigned-bitfields
|
155 | CFLAGS += -fpack-struct
|
156 | CFLAGS += -fshort-enums
|
157 | CFLAGS += -Wall
|
158 | CFLAGS += -Wstrict-prototypes
|
159 | #CFLAGS += -mshort-calls
|
160 | #CFLAGS += -fno-unit-at-a-time
|
161 | #CFLAGS += -Wundef
|
162 | #CFLAGS += -Wunreachable-code
|
163 | #CFLAGS += -Wsign-compare
|
164 | CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
|
165 | CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
166 | CFLAGS += $(CSTANDARD)
|
167 |
|
168 |
|
169 | #---------------- Compiler Options C++ ----------------
|
170 | # -g*: generate debugging information
|
171 | # -O*: optimization level
|
172 | # -f...: tuning, see GCC manual and avr-libc documentation
|
173 | # -Wall...: warning level
|
174 | # -Wa,...: tell GCC to pass this to the assembler.
|
175 | # -adhlns...: create assembler listing
|
176 | CPPFLAGS = -g$(DEBUG)
|
177 | CPPFLAGS += $(CPPDEFS)
|
178 | CPPFLAGS += -O$(OPT)
|
179 | CPPFLAGS += -funsigned-char
|
180 | CPPFLAGS += -funsigned-bitfields
|
181 | CPPFLAGS += -fpack-struct
|
182 | CPPFLAGS += -fshort-enums
|
183 | CPPFLAGS += -fno-exceptions
|
184 | CPPFLAGS += -Wall
|
185 | CPPFLAGS += -Wundef
|
186 | #CPPFLAGS += -mshort-calls
|
187 | #CPPFLAGS += -fno-unit-at-a-time
|
188 | #CPPFLAGS += -Wstrict-prototypes
|
189 | #CPPFLAGS += -Wunreachable-code
|
190 | #CPPFLAGS += -Wsign-compare
|
191 | CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst)
|
192 | CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
193 | #CPPFLAGS += $(CSTANDARD)
|
194 |
|
195 |
|
196 | #---------------- Assembler Options ----------------
|
197 | # -Wa,...: tell GCC to pass this to the assembler.
|
198 | # -adhlns: create listing
|
199 | # -gstabs: have the assembler create line number information; note that
|
200 | # for use in COFF files, additional information about filenames
|
201 | # and function names needs to be present in the assembler source
|
202 | # files -- see avr-libc docs [FIXME: not yet described there]
|
203 | # -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
204 | # dump that will be displayed for a given single line of source input.
|
205 | ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
206 |
|
207 |
|
208 | #---------------- Library Options ----------------
|
209 | # Minimalistic printf version
|
210 | PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
211 |
|
212 | # Floating point printf version (requires MATH_LIB = -lm below)
|
213 | PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
214 |
|
215 | # If this is left blank, then it will use the Standard printf version.
|
216 | PRINTF_LIB =
|
217 | #PRINTF_LIB = $(PRINTF_LIB_MIN)
|
218 | #PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
219 |
|
220 |
|
221 | # Minimalistic scanf version
|
222 | SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
223 |
|
224 | # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
|
225 | SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
226 |
|
227 | # If this is left blank, then it will use the Standard scanf version.
|
228 | SCANF_LIB =
|
229 | #SCANF_LIB = $(SCANF_LIB_MIN)
|
230 | #SCANF_LIB = $(SCANF_LIB_FLOAT)
|
231 |
|
232 |
|
233 | MATH_LIB = -lm
|
234 |
|
235 |
|
236 | # List any extra directories to look for libraries here.
|
237 | # Each directory must be seperated by a space.
|
238 | # Use forward slashes for directory separators.
|
239 | # For a directory that has spaces, enclose it in quotes.
|
240 | EXTRALIBDIRS =
|
241 |
|
242 |
|
243 |
|
244 | #---------------- External Memory Options ----------------
|
245 |
|
246 | # 64 KB of external RAM, starting after internal RAM (ATmega128!),
|
247 | # used for variables (.data/.bss) and heap (malloc()).
|
248 | #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
|
249 |
|
250 | # 64 KB of external RAM, starting after internal RAM (ATmega128!),
|
251 | # only used for heap (malloc()).
|
252 | #EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
|
253 |
|
254 | EXTMEMOPTS =
|
255 |
|
256 |
|
257 |
|
258 | #---------------- Linker Options ----------------
|
259 | # -Wl,...: tell GCC to pass this to linker.
|
260 | # -Map: create map file
|
261 | # --cref: add cross reference to map file
|
262 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
263 | LDFLAGS += $(EXTMEMOPTS)
|
264 | LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
265 | LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
|
266 | #LDFLAGS += -T linker_script.x
|
267 |
|
268 |
|
269 |
|
270 | #---------------- Programming Options (avrdude) ----------------
|
271 |
|
272 | # Programming hardware
|
273 | # Type: avrdude -c ?
|
274 | # to get a full listing.
|
275 | #
|
276 | AVRDUDE_PROGRAMMER = avrispv2
|
277 |
|
278 | # com1 = serial port. Use lpt1 to connect to parallel port.
|
279 | AVRDUDE_PORT = usb
|
280 |
|
281 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
282 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
283 |
|
284 |
|
285 | # Uncomment the following if you want avrdude's erase cycle counter.
|
286 | # Note that this counter needs to be initialized first using -Yn,
|
287 | # see avrdude manual.
|
288 | #AVRDUDE_ERASE_COUNTER = -y
|
289 |
|
290 | # Uncomment the following if you do /not/ wish a verification to be
|
291 | # performed after programming the device.
|
292 | #AVRDUDE_NO_VERIFY = -V
|
293 |
|
294 | # Increase verbosity level. Please use this when submitting bug
|
295 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
296 | # to submit bug reports.
|
297 | #AVRDUDE_VERBOSE = -v -v
|
298 |
|
299 | AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
|
300 | AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
|
301 | AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
|
302 | AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
|
303 |
|
304 |
|
305 |
|
306 | #---------------- Debugging Options ----------------
|
307 |
|
308 | # For simulavr only - target MCU frequency.
|
309 | DEBUG_MFREQ = $(F_CPU)
|
310 |
|
311 | # Set the DEBUG_UI to either gdb or insight.
|
312 | # DEBUG_UI = gdb
|
313 | DEBUG_UI = insight
|
314 |
|
315 | # Set the debugging back-end to either avarice, simulavr.
|
316 | DEBUG_BACKEND = avarice
|
317 | #DEBUG_BACKEND = simulavr
|
318 |
|
319 | # GDB Init Filename.
|
320 | GDBINIT_FILE = __avr_gdbinit
|
321 |
|
322 | # When using avarice settings for the JTAG
|
323 | JTAG_DEV = /dev/com1
|
324 |
|
325 | # Debugging port used to communicate between GDB / avarice / simulavr.
|
326 | DEBUG_PORT = 4242
|
327 |
|
328 | # Debugging host used to communicate between GDB / avarice / simulavr, normally
|
329 | # just set to localhost unless doing some sort of crazy debugging when
|
330 | # avarice is running on a different computer.
|
331 | DEBUG_HOST = localhost
|
332 |
|
333 |
|
334 |
|
335 | #============================================================================
|
336 |
|
337 |
|
338 | # Define programs and commands.
|
339 | SHELL = sh
|
340 | CC = avr-gcc
|
341 | OBJCOPY = avr-objcopy
|
342 | OBJDUMP = avr-objdump
|
343 | SIZE = avr-size
|
344 | AR = avr-ar rcs
|
345 | NM = avr-nm
|
346 | AVRDUDE = avrdude
|
347 | REMOVE = rm -f
|
348 | REMOVEDIR = rm -rf
|
349 | COPY = cp
|
350 | WINSHELL = cmd
|
351 |
|
352 |
|
353 | # Define Messages
|
354 | # English
|
355 | MSG_ERRORS_NONE = Errors: none
|
356 | MSG_BEGIN = -------- begin --------
|
357 | MSG_END = -------- end --------
|
358 | MSG_SIZE_BEFORE = Size before:
|
359 | MSG_SIZE_AFTER = Size after:
|
360 | MSG_COFF = Converting to AVR COFF:
|
361 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
362 | MSG_FLASH = Creating load file for Flash:
|
363 | MSG_EEPROM = Creating load file for EEPROM:
|
364 | MSG_EXTENDED_LISTING = Creating Extended Listing:
|
365 | MSG_SYMBOL_TABLE = Creating Symbol Table:
|
366 | MSG_LINKING = Linking:
|
367 | MSG_COMPILING = Compiling C:
|
368 | MSG_COMPILING_CPP = Compiling C++:
|
369 | MSG_ASSEMBLING = Assembling:
|
370 | MSG_CLEANING = Cleaning project:
|
371 | MSG_CREATING_LIBRARY = Creating library:
|
372 |
|
373 |
|
374 |
|
375 |
|
376 | # Define all object files.
|
377 | OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
378 |
|
379 | # Define all listing files.
|
380 | LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
381 |
|
382 |
|
383 | # Compiler flags to generate dependency files.
|
384 | GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
|
385 |
|
386 |
|
387 | # Combine all necessary flags and optional flags.
|
388 | # Add target processor to flags.
|
389 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
|
390 | ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)
|
391 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 | # Default target.
|
398 | all: begin gccversion sizebefore build sizeafter end
|
399 |
|
400 | # Change the build target to build a HEX file or a library.
|
401 | build: elf hex eep lss sym
|
402 | #build: lib
|
403 |
|
404 |
|
405 | elf: $(TARGET).elf
|
406 | hex: $(TARGET).hex
|
407 | eep: $(TARGET).eep
|
408 | lss: $(TARGET).lss
|
409 | sym: $(TARGET).sym
|
410 | LIBNAME=lib$(TARGET).a
|
411 | lib: $(LIBNAME)
|
412 |
|
413 |
|
414 |
|
415 | # Eye candy.
|
416 | # AVR Studio 3.x does not check make's exit code but relies on
|
417 | # the following magic strings to be generated by the compile job.
|
418 | begin:
|
419 | @echo
|
420 | @echo $(MSG_BEGIN)
|
421 |
|
422 | end:
|
423 | @echo $(MSG_END)
|
424 | @echo
|
425 |
|
426 |
|
427 | # Display size of file.
|
428 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
|
429 | ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf
|
430 |
|
431 | sizebefore:
|
432 | @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
|
433 | 2>/dev/null; echo; fi
|
434 |
|
435 | sizeafter:
|
436 | @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
|
437 | 2>/dev/null; echo; fi
|
438 |
|
439 |
|
440 |
|
441 | # Display compiler version information.
|
442 | gccversion :
|
443 | @$(CC) --version
|
444 |
|
445 |
|
446 |
|
447 | # Program the device.
|
448 | program: $(TARGET).hex $(TARGET).eep
|
449 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
450 |
|
451 |
|
452 | # Generate avr-gdb config/init file which does the following:
|
453 | # define the reset signal, load the target file, connect to target, and set
|
454 | # a breakpoint at main().
|
455 | gdb-config:
|
456 | @$(REMOVE) $(GDBINIT_FILE)
|
457 | @echo define reset >> $(GDBINIT_FILE)
|
458 | @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
459 | @echo end >> $(GDBINIT_FILE)
|
460 | @echo file $(TARGET).elf >> $(GDBINIT_FILE)
|
461 | @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
|
462 | ifeq ($(DEBUG_BACKEND),simulavr)
|
463 | @echo load >> $(GDBINIT_FILE)
|
464 | endif
|
465 | @echo break main >> $(GDBINIT_FILE)
|
466 |
|
467 | debug: gdb-config $(TARGET).elf
|
468 | ifeq ($(DEBUG_BACKEND), avarice)
|
469 | @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
|
470 | @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
|
471 | $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
|
472 | @$(WINSHELL) /c pause
|
473 |
|
474 | else
|
475 | @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
|
476 | $(DEBUG_MFREQ) --port $(DEBUG_PORT)
|
477 | endif
|
478 | @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
|
479 |
|
480 |
|
481 |
|
482 |
|
483 | # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
|
484 | COFFCONVERT = $(OBJCOPY) --debugging
|
485 | COFFCONVERT += --change-section-address .data-0x800000
|
486 | COFFCONVERT += --change-section-address .bss-0x800000
|
487 | COFFCONVERT += --change-section-address .noinit-0x800000
|
488 | COFFCONVERT += --change-section-address .eeprom-0x810000
|
489 |
|
490 |
|
491 |
|
492 | coff: $(TARGET).elf
|
493 | @echo
|
494 | @echo $(MSG_COFF) $(TARGET).cof
|
495 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
|
496 |
|
497 |
|
498 | extcoff: $(TARGET).elf
|
499 | @echo
|
500 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
|
501 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
|
502 |
|
503 |
|
504 |
|
505 | # Create final output files (.hex, .eep) from ELF output file.
|
506 | %.hex: %.elf
|
507 | @echo
|
508 | @echo $(MSG_FLASH) $@
|
509 | $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@
|
510 |
|
511 | %.eep: %.elf
|
512 | @echo
|
513 | @echo $(MSG_EEPROM) $@
|
514 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
515 | --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
|
516 |
|
517 | # Create extended listing file from ELF output file.
|
518 | %.lss: %.elf
|
519 | @echo
|
520 | @echo $(MSG_EXTENDED_LISTING) $@
|
521 | $(OBJDUMP) -h -S -z $< > $@
|
522 |
|
523 | # Create a symbol table from ELF output file.
|
524 | %.sym: %.elf
|
525 | @echo
|
526 | @echo $(MSG_SYMBOL_TABLE) $@
|
527 | $(NM) -n $< > $@
|
528 |
|
529 |
|
530 |
|
531 | # Create library from object files.
|
532 | .SECONDARY : $(TARGET).a
|
533 | .PRECIOUS : $(OBJ)
|
534 | %.a: $(OBJ)
|
535 | @echo
|
536 | @echo $(MSG_CREATING_LIBRARY) $@
|
537 | $(AR) $@ $(OBJ)
|
538 |
|
539 |
|
540 | # Link: create ELF output file from object files.
|
541 | .SECONDARY : $(TARGET).elf
|
542 | .PRECIOUS : $(OBJ)
|
543 | %.elf: $(OBJ)
|
544 | @echo
|
545 | @echo $(MSG_LINKING) $@
|
546 | $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
|
547 |
|
548 |
|
549 | # Compile: create object files from C source files.
|
550 | $(OBJDIR)/%.o : %.c
|
551 | @echo
|
552 | @echo $(MSG_COMPILING) $<
|
553 | $(CC) -c $(ALL_CFLAGS) $< -o $@
|
554 |
|
555 |
|
556 | # Compile: create object files from C++ source files.
|
557 | $(OBJDIR)/%.o : %.cpp
|
558 | @echo
|
559 | @echo $(MSG_COMPILING_CPP) $<
|
560 | $(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
561 |
|
562 |
|
563 | # Compile: create assembler files from C source files.
|
564 | %.s : %.c
|
565 | $(CC) -S $(ALL_CFLAGS) $< -o $@
|
566 |
|
567 |
|
568 | # Compile: create assembler files from C++ source files.
|
569 | %.s : %.cpp
|
570 | $(CC) -S $(ALL_CPPFLAGS) $< -o $@
|
571 |
|
572 |
|
573 | # Assemble: create object files from assembler source files.
|
574 | $(OBJDIR)/%.o : %.S
|
575 | @echo
|
576 | @echo $(MSG_ASSEMBLING) $<
|
577 | $(CC) -c $(ALL_ASFLAGS) $< -o $@
|
578 |
|
579 |
|
580 | # Create preprocessed source for use in sending a bug report.
|
581 | %.i : %.c
|
582 | $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
583 |
|
584 |
|
585 | # Target: clean project.
|
586 | clean: begin clean_list end
|
587 |
|
588 | clean_list :
|
589 | @echo
|
590 | @echo $(MSG_CLEANING)
|
591 | $(REMOVE) $(TARGET).hex
|
592 | $(REMOVE) $(TARGET).eep
|
593 | $(REMOVE) $(TARGET).cof
|
594 | $(REMOVE) $(TARGET).elf
|
595 | $(REMOVE) $(TARGET).map
|
596 | $(REMOVE) $(TARGET).sym
|
597 | $(REMOVE) $(TARGET).lss
|
598 | $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)
|
599 | $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)
|
600 | $(REMOVE) $(SRC:.c=.s)
|
601 | $(REMOVE) $(SRC:.c=.d)
|
602 | $(REMOVE) $(SRC:.c=.i)
|
603 | $(REMOVEDIR) .dep
|
604 |
|
605 |
|
606 | # Create object files directory
|
607 | $(shell mkdir $(OBJDIR) 2>/dev/null)
|
608 |
|
609 |
|
610 | # Include the dependency files.
|
611 | -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
612 |
|
613 |
|
614 | # Listing of phony targets.
|
615 | .PHONY : all begin finish end sizebefore sizeafter gccversion \
|
616 | build elf hex eep lss sym coff extcoff \
|
617 | clean clean_list program debug gdb-config
|