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