Change over all makefiles to use C99 standards mode, rather than C99 + GNU Extensions.
[pub/USBasp.git] / Demos / Host / Incomplete / BluetoothHost / 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. 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 = 16000000
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 = $(F_CPU)
105
106
107 # Output format. (can be srec, ihex, binary)
108 FORMAT = ihex
109
110
111 # Target file name (without extension).
112 TARGET = BluetoothHost
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 # Path to the LUFA library
122 LUFA_PATH = ../../../..
123
124
125 # LUFA library compile-time options
126 LUFA_OPTS = -D USB_HOST_ONLY
127 LUFA_OPTS += -D NO_STREAM_CALLBACKS
128 LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
129
130
131 # List C source files here. (C dependencies are automatically generated.)
132 SRC = $(TARGET).c \
133 BluetoothEvents.c \
134 DeviceDescriptor.c \
135 ConfigDescriptor.c \
136 Lib/BluetoothStack.c \
137 Lib/BluetoothHCICommands.c \
138 Lib/BluetoothACLPackets.c \
139 Lib/SDP.c \
140 Lib/SDPServices.c \
141 Lib/RFCOMM.c \
142 Lib/RFCOMMControl.c \
143 $(LUFA_PATH)/LUFA/Drivers/Peripheral/SerialStream.c \
144 $(LUFA_PATH)/LUFA/Drivers/Peripheral/Serial.c \
145 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c \
146 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Device.c \
147 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Endpoint.c \
148 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Host.c \
149 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/HostChapter9.c \
150 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/LowLevel.c \
151 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Pipe.c \
152 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/USBInterrupt.c \
153 $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c \
154 $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/Events.c \
155 $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/USBTask.c \
156
157
158 # List C++ source files here. (C dependencies are automatically generated.)
159 CPPSRC =
160
161
162 # List Assembler source files here.
163 # Make them always end in a capital .S. Files ending in a lowercase .s
164 # will not be considered source files but generated files (assembler
165 # output from the compiler), and will be deleted upon "make clean"!
166 # Even though the DOS/Win* filesystem matches both .s and .S the same,
167 # it will preserve the spelling of the filenames, and gcc itself does
168 # care about how the name is spelled on its command-line.
169 ASRC =
170
171
172 # Optimization level, can be [0, 1, 2, 3, s].
173 # 0 = turn off optimization. s = optimize for size.
174 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
175 OPT = s
176
177
178 # Debugging format.
179 # Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
180 # AVR Studio 4.10 requires dwarf-2.
181 # AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
182 DEBUG = dwarf-2
183
184
185 # List any extra directories to look for include files here.
186 # Each directory must be seperated by a space.
187 # Use forward slashes for directory separators.
188 # For a directory that has spaces, enclose it in quotes.
189 EXTRAINCDIRS = $(LUFA_PATH)/
190
191
192 # Compiler flag to set the C Standard level.
193 # c89 = "ANSI" C
194 # gnu89 = c89 plus GCC extensions
195 # c99 = ISO C99 standard (not yet fully implemented)
196 # gnu99 = c99 plus GCC extensions
197 CSTANDARD = -std=c99
198
199
200 # Place -D or -U options here for C sources
201 CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA_OPTS)
202
203
204 # Place -D or -U options here for ASM sources
205 ADEFS = -DF_CPU=$(F_CPU)
206
207
208 # Place -D or -U options here for C++ sources
209 CPPDEFS = -DF_CPU=$(F_CPU)UL
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 += -Wall
233 CFLAGS += -Wstrict-prototypes
234 CFLAGS += -Wundef
235 #CFLAGS += -fno-unit-at-a-time
236 #CFLAGS += -Wunreachable-code
237 #CFLAGS += -Wsign-compare
238 CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
239 CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
240 CFLAGS += $(CSTANDARD)
241
242
243 #---------------- Compiler Options C++ ----------------
244 # -g*: generate debugging information
245 # -O*: optimization level
246 # -f...: tuning, see GCC manual and avr-libc documentation
247 # -Wall...: warning level
248 # -Wa,...: tell GCC to pass this to the assembler.
249 # -adhlns...: create assembler listing
250 CPPFLAGS = -g$(DEBUG)
251 CPPFLAGS += $(CPPDEFS)
252 CPPFLAGS += -O$(OPT)
253 CPPFLAGS += -funsigned-char
254 CPPFLAGS += -funsigned-bitfields
255 CPPFLAGS += -fpack-struct
256 CPPFLAGS += -fshort-enums
257 CPPFLAGS += -fno-exceptions
258 CPPFLAGS += -Wall
259 CFLAGS += -Wundef
260 #CPPFLAGS += -mshort-calls
261 #CPPFLAGS += -fno-unit-at-a-time
262 #CPPFLAGS += -Wstrict-prototypes
263 #CPPFLAGS += -Wunreachable-code
264 #CPPFLAGS += -Wsign-compare
265 CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst)
266 CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
267 #CPPFLAGS += $(CSTANDARD)
268
269
270 #---------------- Assembler Options ----------------
271 # -Wa,...: tell GCC to pass this to the assembler.
272 # -adhlns: create listing
273 # -gstabs: have the assembler create line number information; note that
274 # for use in COFF files, additional information about filenames
275 # and function names needs to be present in the assembler source
276 # files -- see avr-libc docs [FIXME: not yet described there]
277 # -listing-cont-lines: Sets the maximum number of continuation lines of hex
278 # dump that will be displayed for a given single line of source input.
279 ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
280
281
282 #---------------- Library Options ----------------
283 # Minimalistic printf version
284 PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
285
286 # Floating point printf version (requires MATH_LIB = -lm below)
287 PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
288
289 # If this is left blank, then it will use the Standard printf version.
290 PRINTF_LIB =
291 #PRINTF_LIB = $(PRINTF_LIB_MIN)
292 #PRINTF_LIB = $(PRINTF_LIB_FLOAT)
293
294
295 # Minimalistic scanf version
296 SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
297
298 # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
299 SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
300
301 # If this is left blank, then it will use the Standard scanf version.
302 SCANF_LIB =
303 #SCANF_LIB = $(SCANF_LIB_MIN)
304 #SCANF_LIB = $(SCANF_LIB_FLOAT)
305
306
307 MATH_LIB = -lm
308
309
310 # List any extra directories to look for libraries here.
311 # Each directory must be seperated by a space.
312 # Use forward slashes for directory separators.
313 # For a directory that has spaces, enclose it in quotes.
314 EXTRALIBDIRS =
315
316
317
318 #---------------- External Memory Options ----------------
319
320 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
321 # used for variables (.data/.bss) and heap (malloc()).
322 #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
323
324 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
325 # only used for heap (malloc()).
326 #EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
327
328 EXTMEMOPTS =
329
330
331
332 #---------------- Linker Options ----------------
333 # -Wl,...: tell GCC to pass this to linker.
334 # -Map: create map file
335 # --cref: add cross reference to map file
336 LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
337 LDFLAGS += -Wl,--relax
338 LDFLAGS += -Wl,--gc-sections
339 LDFLAGS += $(EXTMEMOPTS)
340 LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
341 LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
342 #LDFLAGS += -T linker_script.x
343
344
345
346 #---------------- Programming Options (avrdude) ----------------
347
348 # Programming hardware: alf avr910 avrisp bascom bsd
349 # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
350 #
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 # Define Messages
431 # English
432 MSG_ERRORS_NONE = Errors: none
433 MSG_BEGIN = -------- begin --------
434 MSG_END = -------- end --------
435 MSG_SIZE_BEFORE = Size before:
436 MSG_SIZE_AFTER = Size after:
437 MSG_COFF = Converting to AVR COFF:
438 MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
439 MSG_FLASH = Creating load file for Flash:
440 MSG_EEPROM = Creating load file for EEPROM:
441 MSG_EXTENDED_LISTING = Creating Extended Listing:
442 MSG_SYMBOL_TABLE = Creating Symbol Table:
443 MSG_LINKING = Linking:
444 MSG_COMPILING = Compiling C:
445 MSG_COMPILING_CPP = Compiling C++:
446 MSG_ASSEMBLING = Assembling:
447 MSG_CLEANING = Cleaning project:
448 MSG_CREATING_LIBRARY = Creating library:
449
450
451
452
453 # Define all object files.
454 OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
455
456 # Define all listing files.
457 LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
458
459
460 # Compiler flags to generate dependency files.
461 GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
462
463
464 # Combine all necessary flags and optional flags.
465 # Add target processor to flags.
466 ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
467 ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)
468 ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
469
470
471
472
473
474 # Default target.
475 all: begin gccversion sizebefore build showliboptions showtarget sizeafter end
476
477 # Change the build target to build a HEX file or a library.
478 build: elf hex eep lss sym
479 #build: lib
480
481
482 elf: $(TARGET).elf
483 hex: $(TARGET).hex
484 eep: $(TARGET).eep
485 lss: $(TARGET).lss
486 sym: $(TARGET).sym
487 LIBNAME=lib$(TARGET).a
488 lib: $(LIBNAME)
489
490
491
492 # Eye candy.
493 # AVR Studio 3.x does not check make's exit code but relies on
494 # the following magic strings to be generated by the compile job.
495 begin:
496 @echo
497 @echo $(MSG_BEGIN)
498
499 end:
500 @echo $(MSG_END)
501 @echo
502
503
504 # Display size of file.
505 HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
506 ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf
507 MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
508 FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
509
510 sizebefore:
511 @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
512 2>/dev/null; echo; fi
513
514 sizeafter:
515 @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
516 2>/dev/null; echo; fi
517
518 showliboptions:
519 @echo
520 @echo ---- Compile Time Library Options ----
521 @for i in $(LUFA_OPTS:-D%=%); do \
522 echo $$i; \
523 done
524 @echo --------------------------------------
525
526 showtarget:
527 @echo
528 @echo --------- Target Information ---------
529 @echo AVR Model: $(MCU)
530 @echo Board: $(BOARD)
531 @echo Clock: $(F_CPU)Hz CPU, $(F_CLOCK)Hz Master
532 @echo --------------------------------------
533
534
535 # Display compiler version information.
536 gccversion :
537 @$(CC) --version
538
539
540 # Program the device.
541 program: $(TARGET).hex $(TARGET).eep
542 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
543
544 flip: $(TARGET).hex
545 batchisp -hardware usb -device $(MCU) -operation erase f
546 batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program
547 batchisp -hardware usb -device $(MCU) -operation start reset 0
548
549 dfu: $(TARGET).hex
550 dfu-programmer $(MCU) erase
551 dfu-programmer $(MCU) flash --debug 1 $(TARGET).hex
552 dfu-programmer $(MCU) reset
553
554 flip-ee: $(TARGET).hex $(TARGET).eep
555 $(COPY) $(TARGET).eep $(TARGET)eep.hex
556 batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase
557 batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program
558 batchisp -hardware usb -device $(MCU) -operation start reset 0
559 $(REMOVE) $(TARGET)eep.hex
560
561 dfu-ee: $(TARGET).hex $(TARGET).eep
562 dfu-programmer $(MCU) flash-eeprom --debug 1 --suppress-bootloader-mem $(TARGET).eep
563 dfu-programmer $(MCU) reset
564
565
566 # Generate avr-gdb config/init file which does the following:
567 # define the reset signal, load the target file, connect to target, and set
568 # a breakpoint at main().
569 gdb-config:
570 @$(REMOVE) $(GDBINIT_FILE)
571 @echo define reset >> $(GDBINIT_FILE)
572 @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
573 @echo end >> $(GDBINIT_FILE)
574 @echo file $(TARGET).elf >> $(GDBINIT_FILE)
575 @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
576 ifeq ($(DEBUG_BACKEND),simulavr)
577 @echo load >> $(GDBINIT_FILE)
578 endif
579 @echo break main >> $(GDBINIT_FILE)
580
581 debug: gdb-config $(TARGET).elf
582 ifeq ($(DEBUG_BACKEND), avarice)
583 @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
584 @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
585 $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
586 @$(WINSHELL) /c pause
587
588 else
589 @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
590 $(DEBUG_MFREQ) --port $(DEBUG_PORT)
591 endif
592 @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
593
594
595
596
597 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
598 COFFCONVERT = $(OBJCOPY) --debugging
599 COFFCONVERT += --change-section-address .data-0x800000
600 COFFCONVERT += --change-section-address .bss-0x800000
601 COFFCONVERT += --change-section-address .noinit-0x800000
602 COFFCONVERT += --change-section-address .eeprom-0x810000
603
604
605
606 coff: $(TARGET).elf
607 @echo
608 @echo $(MSG_COFF) $(TARGET).cof
609 $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
610
611
612 extcoff: $(TARGET).elf
613 @echo
614 @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
615 $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
616
617
618
619 # Create final output files (.hex, .eep) from ELF output file.
620 %.hex: %.elf
621 @echo
622 @echo $(MSG_FLASH) $@
623 $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
624
625 %.eep: %.elf
626 @echo
627 @echo $(MSG_EEPROM) $@
628 -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
629 --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
630
631 # Create extended listing file from ELF output file.
632 %.lss: %.elf
633 @echo
634 @echo $(MSG_EXTENDED_LISTING) $@
635 $(OBJDUMP) -h -z -S $< > $@
636
637 # Create a symbol table from ELF output file.
638 %.sym: %.elf
639 @echo
640 @echo $(MSG_SYMBOL_TABLE) $@
641 $(NM) -n $< > $@
642
643
644
645 # Create library from object files.
646 .SECONDARY : $(TARGET).a
647 .PRECIOUS : $(OBJ)
648 %.a: $(OBJ)
649 @echo
650 @echo $(MSG_CREATING_LIBRARY) $@
651 $(AR) $@ $(OBJ)
652
653
654 # Link: create ELF output file from object files.
655 .SECONDARY : $(TARGET).elf
656 .PRECIOUS : $(OBJ)
657 %.elf: $(OBJ)
658 @echo
659 @echo $(MSG_LINKING) $@
660 $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
661
662
663 # Compile: create object files from C source files.
664 $(OBJDIR)/%.o : %.c
665 @echo
666 @echo $(MSG_COMPILING) $<
667 $(CC) -c $(ALL_CFLAGS) $< -o $@
668
669
670 # Compile: create object files from C++ source files.
671 $(OBJDIR)/%.o : %.cpp
672 @echo
673 @echo $(MSG_COMPILING_CPP) $<
674 $(CC) -c $(ALL_CPPFLAGS) $< -o $@
675
676
677 # Compile: create assembler files from C source files.
678 %.s : %.c
679 $(CC) -S $(ALL_CFLAGS) $< -o $@
680
681
682 # Compile: create assembler files from C++ source files.
683 %.s : %.cpp
684 $(CC) -S $(ALL_CPPFLAGS) $< -o $@
685
686
687 # Assemble: create object files from assembler source files.
688 $(OBJDIR)/%.o : %.S
689 @echo
690 @echo $(MSG_ASSEMBLING) $<
691 $(CC) -c $(ALL_ASFLAGS) $< -o $@
692
693
694 # Create preprocessed source for use in sending a bug report.
695 %.i : %.c
696 $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
697
698
699 # Target: clean project.
700 clean: begin clean_list clean_binary end
701
702 clean_binary:
703 $(REMOVE) $(TARGET).hex
704
705 clean_list:
706 @echo $(MSG_CLEANING)
707 $(REMOVE) $(TARGET).eep
708 $(REMOVE) $(TARGET)eep.hex
709 $(REMOVE) $(TARGET).cof
710 $(REMOVE) $(TARGET).elf
711 $(REMOVE) $(TARGET).map
712 $(REMOVE) $(TARGET).sym
713 $(REMOVE) $(TARGET).lss
714 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)
715 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)
716 $(REMOVE) $(SRC:.c=.s)
717 $(REMOVE) $(SRC:.c=.d)
718 $(REMOVE) $(SRC:.c=.i)
719 $(REMOVE) InvalidEvents.tmp
720 $(REMOVEDIR) .dep
721
722 doxygen:
723 @echo Generating Project Documentation...
724 @doxygen Doxygen.conf
725 @echo Documentation Generation Complete.
726
727 clean_doxygen:
728 rm -rf Documentation
729
730 # Create object files directory
731 $(shell mkdir $(OBJDIR) 2>/dev/null)
732
733
734 # Include the dependency files.
735 -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
736
737
738 # Listing of phony targets.
739 .PHONY : all showliboptions showtarget begin \
740 finish end sizebefore sizeafter gccversion build \
741 elf hex eep lss sym coff extcoff program dfu flip \
742 flip-ee dfu-ee clean debug clean_list clean_binary \
743 clean_doxygen gdb-config doxygen