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