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