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