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