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