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