2 # Hey Emacs, this is a -*- makefile -*-
\r
3 #----------------------------------------------------------------------------
\r
4 # WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
\r
5 # >> Modified for use with the LUFA project. <<
\r
7 # Released to the Public Domain
\r
9 # Additional material for this makefile was written by:
\r
22 #----------------------------------------------------------------------------
\r
25 # make all = Make software.
\r
27 # make clean = Clean out built project files.
\r
29 # make coff = Convert ELF to AVR COFF.
\r
31 # make extcoff = Convert ELF to AVR Extended COFF.
\r
33 # make program = Download the hex file to the device, using avrdude.
\r
34 # Please customize the avrdude settings below first!
\r
36 # make dfu = Download the hex file to the device, using dfu-programmer (must
\r
37 # have dfu-programmer installed).
\r
39 # make flip = Download the hex file to the device, using Atmel FLIP (must
\r
40 # have Atmel FLIP installed).
\r
42 # make dfu-ee = Download the eeprom file to the device, using dfu-programmer
\r
43 # (must have dfu-programmer installed).
\r
45 # make flip-ee = Download the eeprom file to the device, using Atmel FLIP
\r
46 # (must have Atmel FLIP installed).
\r
48 # make doxygen = Generate DoxyGen documentation for the project (must have
\r
49 # DoxyGen installed)
\r
51 # make debug = Start either simulavr or avarice as specified for debugging,
\r
52 # with avr-gdb or avr-insight as the front end for debugging.
\r
54 # make filename.s = Just compile filename.c into the assembler code only.
\r
56 # make filename.i = Create a preprocessed source file for use in submitting
\r
57 # bug reports to the GCC project.
\r
59 # To rebuild project do "make clean" then "make all".
\r
60 #----------------------------------------------------------------------------
\r
67 # Target architecture (see library "Board Types" documentation).
\r
71 # Target board (see library "Board Types" documentation, NONE for projects not requiring
\r
72 # LUFA board drivers). If USER is selected, put custom board drivers in a directory called
\r
73 # "Board" inside the application directory.
\r
77 # Processor frequency.
\r
78 # This will define a symbol, F_CPU, in all source code files equal to the
\r
79 # processor frequency in Hz. You can then use this symbol in your source code to
\r
80 # calculate timings. Do NOT tack on a 'UL' at the end, this will be done
\r
81 # automatically to create a 32-bit value in your source code.
\r
83 # This will be an integer division of F_USB below, as it is sourced by
\r
84 # F_USB after it has run through any CPU prescalers. Note that this value
\r
85 # does not *change* the processor frequency - it should merely be updated to
\r
86 # reflect the processor speed set externally so that the code can use accurate
\r
91 # Input clock frequency.
\r
92 # This will define a symbol, F_USB, in all source code files equal to the
\r
93 # input clock frequency (before any prescaling is performed) in Hz. This value may
\r
94 # differ from F_CPU if prescaling is used on the latter, and is required as the
\r
95 # raw input clock is fed directly to the PLL sections of the AVR for high speed
\r
96 # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
\r
97 # at the end, this will be done automatically to create a 32-bit value in your
\r
100 # If no clock division is performed on the input clock inside the AVR (via the
\r
101 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
\r
105 # Output format. (can be srec, ihex, binary)
\r
109 # Target file name (without extension).
\r
110 TARGET = DualVirtualSerial
\r
113 # Object files directory
\r
114 # To put object files in current directory, use a dot (.), do NOT make
\r
115 # this an empty or blank macro!
\r
119 # Path to the LUFA library
\r
120 LUFA_PATH = ../../../..
\r
123 # LUFA library compile-time options and predefined tokens
\r
124 LUFA_OPTS = -D USB_DEVICE_ONLY
\r
125 LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
\r
126 LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
\r
127 LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
\r
128 LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
\r
131 # Create the LUFA source path variables by including the LUFA root makefile
\r
132 include $(LUFA_PATH)/LUFA/makefile
\r
135 # List C source files here. (C dependencies are automatically generated.)
\r
140 $(LUFA_SRC_USBCLASS) \
\r
141 cirbuf_add_buf_head.c \
\r
142 cirbuf_add_buf_tail.c \
\r
143 cirbuf_add_head.c \
\r
144 cirbuf_add_tail.c \
\r
147 cirbuf_del_buf_head.c \
\r
148 cirbuf_del_buf_tail.c \
\r
149 cirbuf_del_head.c \
\r
150 cirbuf_del_tail.c \
\r
151 cirbuf_get_buf_head.c \
\r
152 cirbuf_get_buf_tail.c \
\r
153 cirbuf_get_head.c \
\r
154 cirbuf_get_tail.c \
\r
159 DualVirtualSerial.c \
\r
170 scheduler_interrupt.c \
\r
171 scheduler_stats.c \
\r
177 uart_recv_nowait.c \
\r
179 uart_send_nowait.c \
\r
192 timer0_prescaler.c \
\r
193 timer0_register_OC_at_tics.c \
\r
194 timer0_register_OC_in_us.c \
\r
195 timer0_register_OV.c \
\r
196 timer0_startstop.c \
\r
198 timer1_prescaler.c \
\r
199 timer1_register_OC_at_tics.c \
\r
200 timer1_register_OC_in_us.c \
\r
201 timer1_register_OV.c \
\r
202 timer1_startstop.c \
\r
204 timer2_prescaler.c \
\r
205 timer2_register_OC_at_tics.c \
\r
206 timer2_register_OC_in_us.c \
\r
207 timer2_register_OV.c \
\r
208 timer2_startstop.c \
\r
210 timer3_prescaler.c \
\r
211 timer3_register_OC_at_tics.c \
\r
212 timer3_register_OC_in_us.c \
\r
213 timer3_register_OV.c \
\r
214 timer3_startstop.c \
\r
216 timer4_prescaler.c \
\r
217 timer4_register_OC_at_tics.c \
\r
218 timer4_register_OC_in_us.c \
\r
219 timer4_register_OV.c \
\r
220 timer4_startstop.c \
\r
222 timer5_prescaler.c \
\r
223 timer5_register_OC_at_tics.c \
\r
224 timer5_register_OC_in_us.c \
\r
225 timer5_register_OV.c \
\r
226 timer5_startstop.c \
\r
227 timer_conf_check.c \
\r
236 # List C++ source files here. (C dependencies are automatically generated.)
\r
240 # List Assembler source files here.
\r
241 # Make them always end in a capital .S. Files ending in a lowercase .s
\r
242 # will not be considered source files but generated files (assembler
\r
243 # output from the compiler), and will be deleted upon "make clean"!
\r
244 # Even though the DOS/Win* filesystem matches both .s and .S the same,
\r
245 # it will preserve the spelling of the filenames, and gcc itself does
\r
246 # care about how the name is spelled on its command-line.
\r
250 # Optimization level, can be [0, 1, 2, 3, s].
\r
251 # 0 = turn off optimization. s = optimize for size.
\r
252 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
\r
256 # Debugging format.
\r
257 # Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
\r
258 # AVR Studio 4.10 requires dwarf-2.
\r
259 # AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
\r
263 # List any extra directories to look for include files here.
\r
264 # Each directory must be seperated by a space.
\r
265 # Use forward slashes for directory separators.
\r
266 # For a directory that has spaces, enclose it in quotes.
\r
267 EXTRAINCDIRS = $(LUFA_PATH)/
\r
270 # Compiler flag to set the C Standard level.
\r
272 # gnu89 = c89 plus GCC extensions
\r
273 # c99 = ISO C99 standard (not yet fully implemented)
\r
274 # gnu99 = c99 plus GCC extensions
\r
275 CSTANDARD = -std=c99
\r
278 # Place -D or -U options here for C sources
\r
279 CDEFS = -DF_CPU=$(F_CPU)UL
\r
280 CDEFS += -DF_USB=$(F_USB)UL
\r
281 CDEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH)
\r
282 CDEFS += $(LUFA_OPTS)
\r
285 # Place -D or -U options here for ASM sources
\r
286 ADEFS = -DF_CPU=$(F_CPU)
\r
287 ADEFS += -DF_USB=$(F_USB)UL
\r
288 ADEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH)
\r
289 ADEFS += $(LUFA_OPTS)
\r
291 # Place -D or -U options here for C++ sources
\r
292 CPPDEFS = -DF_CPU=$(F_CPU)UL
\r
293 CPPDEFS += -DF_USB=$(F_USB)UL
\r
294 CPPDEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH)
\r
295 CPPDEFS += $(LUFA_OPTS)
\r
296 #CPPDEFS += -D__STDC_LIMIT_MACROS
\r
297 #CPPDEFS += -D__STDC_CONSTANT_MACROS
\r
301 #---------------- Compiler Options C ----------------
\r
302 # -g*: generate debugging information
\r
303 # -O*: optimization level
\r
304 # -f...: tuning, see GCC manual and avr-libc documentation
\r
305 # -Wall...: warning level
\r
306 # -Wa,...: tell GCC to pass this to the assembler.
\r
307 # -adhlns...: create assembler listing
\r
308 CFLAGS = -g$(DEBUG)
\r
311 CFLAGS += -funsigned-char
\r
312 CFLAGS += -funsigned-bitfields
\r
313 CFLAGS += -ffunction-sections
\r
314 CFLAGS += -fno-inline-small-functions
\r
315 CFLAGS += -fpack-struct
\r
316 CFLAGS += -fshort-enums
\r
317 CFLAGS += -fno-strict-aliasing
\r
318 CFLAGS += -Wall -Werror
\r
319 CFLAGS += -Wstrict-prototypes
\r
320 CFLAGS += -ffreestanding
\r
321 #CFLAGS += -mshort-calls
\r
322 #CFLAGS += -fno-unit-at-a-time
\r
324 #CFLAGS += -Wunreachable-code
\r
325 #CFLAGS += -Wsign-compare
\r
326 CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
\r
327 CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
\r
328 CFLAGS += $(CSTANDARD)
\r
329 CFLAGS += -std=gnu99
\r
332 #---------------- Compiler Options C++ ----------------
\r
333 # -g*: generate debugging information
\r
334 # -O*: optimization level
\r
335 # -f...: tuning, see GCC manual and avr-libc documentation
\r
336 # -Wall...: warning level
\r
337 # -Wa,...: tell GCC to pass this to the assembler.
\r
338 # -adhlns...: create assembler listing
\r
339 CPPFLAGS = -g$(DEBUG)
\r
340 CPPFLAGS += $(CPPDEFS)
\r
341 CPPFLAGS += -O$(OPT)
\r
342 CPPFLAGS += -funsigned-char
\r
343 CPPFLAGS += -funsigned-bitfields
\r
344 CPPFLAGS += -fpack-struct
\r
345 CPPFLAGS += -fshort-enums
\r
346 CPPFLAGS += -fno-exceptions
\r
348 CPPFLAGS += -Wundef
\r
349 #CPPFLAGS += -mshort-calls
\r
350 #CPPFLAGS += -fno-unit-at-a-time
\r
351 #CPPFLAGS += -Wstrict-prototypes
\r
352 #CPPFLAGS += -Wunreachable-code
\r
353 #CPPFLAGS += -Wsign-compare
\r
354 CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst)
\r
355 CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
\r
356 #CPPFLAGS += $(CSTANDARD)
\r
359 #---------------- Assembler Options ----------------
\r
360 # -Wa,...: tell GCC to pass this to the assembler.
\r
361 # -adhlns: create listing
\r
362 # -gstabs: have the assembler create line number information; note that
\r
363 # for use in COFF files, additional information about filenames
\r
364 # and function names needs to be present in the assembler source
\r
365 # files -- see avr-libc docs [FIXME: not yet described there]
\r
366 # -listing-cont-lines: Sets the maximum number of continuation lines of hex
\r
367 # dump that will be displayed for a given single line of source input.
\r
368 ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
\r
371 #---------------- Library Options ----------------
\r
372 # Minimalistic printf version
\r
373 PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
\r
375 # Floating point printf version (requires MATH_LIB = -lm below)
\r
376 PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
\r
378 # If this is left blank, then it will use the Standard printf version.
\r
380 #PRINTF_LIB = $(PRINTF_LIB_MIN)
\r
381 #PRINTF_LIB = $(PRINTF_LIB_FLOAT)
\r
384 # Minimalistic scanf version
\r
385 SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
\r
387 # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
\r
388 SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
\r
390 # If this is left blank, then it will use the Standard scanf version.
\r
392 #SCANF_LIB = $(SCANF_LIB_MIN)
\r
393 #SCANF_LIB = $(SCANF_LIB_FLOAT)
\r
399 # List any extra directories to look for libraries here.
\r
400 # Each directory must be seperated by a space.
\r
401 # Use forward slashes for directory separators.
\r
402 # For a directory that has spaces, enclose it in quotes.
\r
407 #---------------- External Memory Options ----------------
\r
409 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
\r
410 # used for variables (.data/.bss) and heap (malloc()).
\r
411 #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
\r
413 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
\r
414 # only used for heap (malloc()).
\r
415 #EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
\r
421 #---------------- Linker Options ----------------
\r
422 # -Wl,...: tell GCC to pass this to linker.
\r
423 # -Map: create map file
\r
424 # --cref: add cross reference to map file
\r
425 LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
\r
426 LDFLAGS += -Wl,--relax
\r
427 LDFLAGS += -Wl,--gc-sections
\r
428 LDFLAGS += $(EXTMEMOPTS)
\r
429 LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
\r
430 LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
\r
431 #LDFLAGS += -T linker_script.x
\r
435 #---------------- Programming Options (avrdude) ----------------
\r
437 # Programming hardware
\r
438 # Type: avrdude -c ?
\r
439 # to get a full listing.
\r
441 AVRDUDE_PROGRAMMER = jtagmkII
\r
443 # com1 = serial port. Use lpt1 to connect to parallel port.
\r
446 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
\r
447 #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
\r
450 # Uncomment the following if you want avrdude's erase cycle counter.
\r
451 # Note that this counter needs to be initialized first using -Yn,
\r
452 # see avrdude manual.
\r
453 #AVRDUDE_ERASE_COUNTER = -y
\r
455 # Uncomment the following if you do /not/ wish a verification to be
\r
456 # performed after programming the device.
\r
457 #AVRDUDE_NO_VERIFY = -V
\r
459 # Increase verbosity level. Please use this when submitting bug
\r
460 # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
\r
461 # to submit bug reports.
\r
462 #AVRDUDE_VERBOSE = -v -v
\r
464 AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
\r
465 AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
\r
466 AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
\r
467 AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
\r
471 #---------------- Debugging Options ----------------
\r
473 # For simulavr only - target MCU frequency.
\r
474 DEBUG_MFREQ = $(F_CPU)
\r
476 # Set the DEBUG_UI to either gdb or insight.
\r
480 # Set the debugging back-end to either avarice, simulavr.
\r
481 DEBUG_BACKEND = avarice
\r
482 #DEBUG_BACKEND = simulavr
\r
484 # GDB Init Filename.
\r
485 GDBINIT_FILE = __avr_gdbinit
\r
487 # When using avarice settings for the JTAG
\r
488 JTAG_DEV = /dev/com1
\r
490 # Debugging port used to communicate between GDB / avarice / simulavr.
\r
493 # Debugging host used to communicate between GDB / avarice / simulavr, normally
\r
494 # just set to localhost unless doing some sort of crazy debugging when
\r
495 # avarice is running on a different computer.
\r
496 DEBUG_HOST = localhost
\r
500 #============================================================================
\r
503 # Define programs and commands.
\r
506 OBJCOPY = avr-objcopy
\r
507 OBJDUMP = avr-objdump
\r
520 MSG_ERRORS_NONE = Errors: none
\r
521 MSG_BEGIN = -------- begin --------
\r
522 MSG_END = -------- end --------
\r
523 MSG_SIZE_BEFORE = Size before:
\r
524 MSG_SIZE_AFTER = Size after:
\r
525 MSG_COFF = Converting to AVR COFF:
\r
526 MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
\r
527 MSG_FLASH = Creating load file for Flash:
\r
528 MSG_EEPROM = Creating load file for EEPROM:
\r
529 MSG_EXTENDED_LISTING = Creating Extended Listing:
\r
530 MSG_SYMBOL_TABLE = Creating Symbol Table:
\r
531 MSG_LINKING = Linking:
\r
532 MSG_COMPILING = Compiling C:
\r
533 MSG_COMPILING_CPP = Compiling C++:
\r
534 MSG_ASSEMBLING = Assembling:
\r
535 MSG_CLEANING = Cleaning project:
\r
536 MSG_CREATING_LIBRARY = Creating library:
\r
541 # Define all object files.
\r
542 OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
\r
544 # Define all listing files.
\r
545 LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
\r
548 # Compiler flags to generate dependency files.
\r
549 GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
\r
552 # Combine all necessary flags and optional flags.
\r
553 # Add target processor to flags.
\r
554 ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
\r
555 ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)
\r
556 ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
\r
563 all: begin gccversion sizebefore build sizeafter end
\r
565 # Change the build target to build a HEX file or a library.
\r
566 build: elf hex eep lss sym
\r
575 LIBNAME=lib$(TARGET).a
\r
581 # AVR Studio 3.x does not check make's exit code but relies on
\r
582 # the following magic strings to be generated by the compile job.
\r
592 # Display size of file.
\r
593 HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
\r
594 ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf
\r
595 MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
\r
596 FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
\r
600 @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
\r
601 2>/dev/null; echo; fi
\r
604 @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
\r
605 2>/dev/null; echo; fi
\r
609 # Display compiler version information.
\r
614 # Program the device.
\r
615 program: $(TARGET).hex $(TARGET).eep
\r
616 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
\r
618 flip: $(TARGET).hex
\r
619 batchisp -hardware usb -device $(MCU) -operation erase f
\r
620 batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program
\r
621 batchisp -hardware usb -device $(MCU) -operation start reset 0
\r
624 dfu-programmer $(MCU) erase
\r
625 dfu-programmer $(MCU) flash $(TARGET).hex
\r
626 dfu-programmer $(MCU) reset
\r
628 flip-ee: $(TARGET).hex $(TARGET).eep
\r
629 $(COPY) $(TARGET).eep $(TARGET)eep.hex
\r
630 batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase
\r
631 batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program
\r
632 batchisp -hardware usb -device $(MCU) -operation start reset 0
\r
633 $(REMOVE) $(TARGET)eep.hex
\r
635 dfu-ee: $(TARGET).hex $(TARGET).eep
\r
636 dfu-programmer $(MCU) eeprom-flash $(TARGET).eep
\r
637 dfu-programmer $(MCU) reset
\r
640 # Generate avr-gdb config/init file which does the following:
\r
641 # define the reset signal, load the target file, connect to target, and set
\r
642 # a breakpoint at main().
\r
644 @$(REMOVE) $(GDBINIT_FILE)
\r
645 @echo define reset >> $(GDBINIT_FILE)
\r
646 @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
\r
647 @echo end >> $(GDBINIT_FILE)
\r
648 @echo file $(TARGET).elf >> $(GDBINIT_FILE)
\r
649 @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
\r
650 ifeq ($(DEBUG_BACKEND),simulavr)
\r
651 @echo load >> $(GDBINIT_FILE)
\r
653 @echo break main >> $(GDBINIT_FILE)
\r
655 debug: gdb-config $(TARGET).elf
\r
656 ifeq ($(DEBUG_BACKEND), avarice)
\r
657 @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
\r
658 @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
\r
659 $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
\r
660 @$(WINSHELL) /c pause
\r
663 @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
\r
664 $(DEBUG_MFREQ) --port $(DEBUG_PORT)
\r
666 @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
\r
671 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
\r
672 COFFCONVERT = $(OBJCOPY) --debugging
\r
673 COFFCONVERT += --change-section-address .data-0x800000
\r
674 COFFCONVERT += --change-section-address .bss-0x800000
\r
675 COFFCONVERT += --change-section-address .noinit-0x800000
\r
676 COFFCONVERT += --change-section-address .eeprom-0x810000
\r
680 coff: $(TARGET).elf
\r
682 @echo $(MSG_COFF) $(TARGET).cof
\r
683 $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
\r
686 extcoff: $(TARGET).elf
\r
688 @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
\r
689 $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
\r
693 # Create final output files (.hex, .eep) from ELF output file.
\r
696 @echo $(MSG_FLASH) $@
\r
697 $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@
\r
701 @echo $(MSG_EEPROM) $@
\r
702 -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
\r
703 --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
\r
705 # Create extended listing file from ELF output file.
\r
708 @echo $(MSG_EXTENDED_LISTING) $@
\r
709 $(OBJDUMP) -h -S -z $< > $@
\r
711 # Create a symbol table from ELF output file.
\r
714 @echo $(MSG_SYMBOL_TABLE) $@
\r
719 # Create library from object files.
\r
720 .SECONDARY : $(TARGET).a
\r
724 @echo $(MSG_CREATING_LIBRARY) $@
\r
728 # Link: create ELF output file from object files.
\r
729 .SECONDARY : $(TARGET).elf
\r
733 @echo $(MSG_LINKING) $@
\r
734 $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
\r
737 # Compile: create object files from C source files.
\r
738 $(OBJDIR)/%.o : %.c
\r
740 @echo $(MSG_COMPILING) $<
\r
741 $(CC) -c $(ALL_CFLAGS) $< -o $@
\r
744 # Compile: create object files from C++ source files.
\r
745 $(OBJDIR)/%.o : %.cpp
\r
747 @echo $(MSG_COMPILING_CPP) $<
\r
748 $(CC) -c $(ALL_CPPFLAGS) $< -o $@
\r
751 # Compile: create assembler files from C source files.
\r
753 $(CC) -S $(ALL_CFLAGS) $< -o $@
\r
756 # Compile: create assembler files from C++ source files.
\r
758 $(CC) -S $(ALL_CPPFLAGS) $< -o $@
\r
761 # Assemble: create object files from assembler source files.
\r
762 $(OBJDIR)/%.o : %.S
\r
764 @echo $(MSG_ASSEMBLING) $<
\r
765 $(CC) -c $(ALL_ASFLAGS) $< -o $@
\r
768 # Create preprocessed source for use in sending a bug report.
\r
770 $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
\r
773 # Target: clean project.
\r
774 clean: begin clean_list end
\r
778 @echo $(MSG_CLEANING)
\r
779 $(REMOVE) $(TARGET).hex
\r
780 $(REMOVE) $(TARGET).eep
\r
781 $(REMOVE) $(TARGET).cof
\r
782 $(REMOVE) $(TARGET).elf
\r
783 $(REMOVE) $(TARGET).map
\r
784 $(REMOVE) $(TARGET).sym
\r
785 $(REMOVE) $(TARGET).lss
\r
786 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
\r
787 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
\r
788 $(REMOVE) $(SRC:.c=.s)
\r
789 $(REMOVE) $(SRC:.c=.d)
\r
790 $(REMOVE) $(SRC:.c=.i)
\r
794 @echo Generating Project Documentation \($(TARGET)\)...
\r
795 @doxygen Doxygen.conf
\r
796 @echo Documentation Generation Complete.
\r
799 rm -rf Documentation
\r
802 @for f in $(SRC) $(CPPSRC) $(ASRC); do \
\r
803 if [ -f $$f ]; then \
\r
804 echo "Found Source File: $$f" ; \
\r
806 echo "Source File Not Found: $$f" ; \
\r
810 # Create object files directory
\r
811 $(shell mkdir $(OBJDIR) 2>/dev/null)
\r
814 # Include the dependency files.
\r
815 -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
\r
818 # Listing of phony targets.
\r
819 .PHONY : all begin finish end sizebefore sizeafter gccversion \
\r
820 build elf hex eep lss sym coff extcoff doxygen clean \
\r
821 clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
\r
822 debug gdb-config checksource
\r