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