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