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