Moved all source to the trunk directory.
[pub/USBasp.git] / Bootloaders / DFU / 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 (see library BoardTypes.h documentation, 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 # Output format. (can be srec, ihex, binary)
94 FORMAT = ihex
95
96
97 # Target file name (without extension).
98 TARGET = BootloaderDFU
99
100
101 # Object files directory
102 # To put object files in current directory, use a dot (.), do NOT make
103 # this an empty or blank macro!
104 OBJDIR = .
105
106
107 # List C source files here. (C dependencies are automatically generated.)
108 SRC = $(TARGET).c \
109 Descriptors.c \
110 ../../LUFA/Drivers/USB/LowLevel/LowLevel.c \
111 ../../LUFA/Drivers/USB/LowLevel/Endpoint.c \
112 ../../LUFA/Drivers/USB/LowLevel/DevChapter9.c \
113 ../../LUFA/Drivers/USB/HighLevel/USBTask.c \
114 ../../LUFA/Drivers/USB/HighLevel/USBInterrupt.c \
115 ../../LUFA/Drivers/USB/HighLevel/Events.c \
116 ../../LUFA/Drivers/USB/HighLevel/StdDescriptors.c \
117
118 # List C++ source files here. (C dependencies are automatically generated.)
119 CPPSRC =
120
121
122 # List Assembler source files here.
123 # Make them always end in a capital .S. Files ending in a lowercase .s
124 # will not be considered source files but generated files (assembler
125 # output from the compiler), and will be deleted upon "make clean"!
126 # Even though the DOS/Win* filesystem matches both .s and .S the same,
127 # it will preserve the spelling of the filenames, and gcc itself does
128 # care about how the name is spelled on its command-line.
129 ASRC =
130
131
132 # Optimization level, can be [0, 1, 2, 3, s].
133 # 0 = turn off optimization. s = optimize for size.
134 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
135 OPT = s
136
137
138 # Debugging format.
139 # Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
140 # AVR Studio 4.10 requires dwarf-2.
141 # AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
142 DEBUG = dwarf-2
143
144
145 # List any extra directories to look for include files here.
146 # Each directory must be seperated by a space.
147 # Use forward slashes for directory separators.
148 # For a directory that has spaces, enclose it in quotes.
149 EXTRAINCDIRS = ../../
150
151
152 # Compiler flag to set the C Standard level.
153 # c89 = "ANSI" C
154 # gnu89 = c89 plus GCC extensions
155 # c99 = ISO C99 standard (not yet fully implemented)
156 # gnu99 = c99 plus GCC extensions
157 CSTANDARD = -std=gnu99
158
159
160 # Starting byte address of the bootloader
161 BOOT_START = 0x1E000
162
163
164 # Place -D or -U options here for C sources
165 CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DSTATIC_ENDPOINT_CONFIGURATION
166 CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
167 CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DFIXED_CONTROL_ENDPOINT_SIZE=32 -DUSE_SINGLE_DEVICE_CONFIGURATION
168 CDEFS += -DNO_CLEARSET_FEATURE_REQUEST
169
170 # Place -D or -U options here for ASM sources
171 ADEFS = -DF_CPU=$(F_CPU)
172
173
174 # Place -D or -U options here for C++ sources
175 CPPDEFS = -DF_CPU=$(F_CPU)UL
176 #CPPDEFS += -D__STDC_LIMIT_MACROS
177 #CPPDEFS += -D__STDC_CONSTANT_MACROS
178
179
180
181 #---------------- Compiler Options C ----------------
182 # -g*: generate debugging information
183 # -O*: optimization level
184 # -f...: tuning, see GCC manual and avr-libc documentation
185 # -Wall...: warning level
186 # -Wa,...: tell GCC to pass this to the assembler.
187 # -adhlns...: create assembler listing
188 CFLAGS = -g$(DEBUG)
189 CFLAGS += $(CDEFS)
190 CFLAGS += -O$(OPT)
191 CFLAGS += -funsigned-char
192 CFLAGS += -funsigned-bitfields
193 CFLAGS += -ffunction-sections
194 CFLAGS += -fdata-sections
195 CFLAGS += -fpack-struct
196 CFLAGS += -fshort-enums
197 CFLAGS += -fno-inline-small-functions
198 CFLAGS += -fno-reorder-blocks
199 CFLAGS += -fno-reorder-blocks-and-partition
200 CFLAGS += -fno-reorder-functions
201 CFLAGS += -fno-toplevel-reorder
202 CFLAGS += -Wall
203 CFLAGS += -Wstrict-prototypes
204 CFLAGS += -Wundef
205 #CFLAGS += -fno-unit-at-a-time
206 #CFLAGS += -Wunreachable-code
207 #CFLAGS += -Wsign-compare
208 CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
209 CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
210 CFLAGS += $(CSTANDARD)
211
212
213 #---------------- Compiler Options C++ ----------------
214 # -g*: generate debugging information
215 # -O*: optimization level
216 # -f...: tuning, see GCC manual and avr-libc documentation
217 # -Wall...: warning level
218 # -Wa,...: tell GCC to pass this to the assembler.
219 # -adhlns...: create assembler listing
220 CPPFLAGS = -g$(DEBUG)
221 CPPFLAGS += $(CPPDEFS)
222 CPPFLAGS += -O$(OPT)
223 CPPFLAGS += -funsigned-char
224 CPPFLAGS += -funsigned-bitfields
225 CPPFLAGS += -fpack-struct
226 CPPFLAGS += -fshort-enums
227 CPPFLAGS += -fno-exceptions
228 CPPFLAGS += -Wall
229 CFLAGS += -Wundef
230 #CPPFLAGS += -mshort-calls
231 #CPPFLAGS += -fno-unit-at-a-time
232 #CPPFLAGS += -Wstrict-prototypes
233 #CPPFLAGS += -Wunreachable-code
234 #CPPFLAGS += -Wsign-compare
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) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
250
251
252 #---------------- Library Options ----------------
253 # Minimalistic printf version
254 PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
255
256 # Floating point printf version (requires MATH_LIB = -lm below)
257 PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
258
259 # If this is left blank, then it will use the Standard printf version.
260 PRINTF_LIB =
261 #PRINTF_LIB = $(PRINTF_LIB_MIN)
262 #PRINTF_LIB = $(PRINTF_LIB_FLOAT)
263
264
265 # Minimalistic scanf version
266 SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
267
268 # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
269 SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
270
271 # If this is left blank, then it will use the Standard scanf version.
272 SCANF_LIB =
273 #SCANF_LIB = $(SCANF_LIB_MIN)
274 #SCANF_LIB = $(SCANF_LIB_FLOAT)
275
276
277 MATH_LIB = -lm
278
279
280 # List any extra directories to look for libraries here.
281 # Each directory must be seperated by a space.
282 # Use forward slashes for directory separators.
283 # For a directory that has spaces, enclose it in quotes.
284 EXTRALIBDIRS =
285
286
287
288 #---------------- External Memory Options ----------------
289
290 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
291 # used for variables (.data/.bss) and heap (malloc()).
292 #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
293
294 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
295 # only used for heap (malloc()).
296 #EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
297
298 EXTMEMOPTS =
299
300
301
302 #---------------- Linker Options ----------------
303 # -Wl,...: tell GCC to pass this to linker.
304 # -Map: create map file
305 # --cref: add cross reference to map file
306 LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
307 LDFLAGS += -Wl,--relax
308 LDFLAGS += -Wl,--gc-sections
309 LDFLAGS += -Wl,--section-start=.text=$(BOOT_START)
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: alf avr910 avrisp bascom bsd
320 # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
321 #
322 # Type: avrdude -c ?
323 # to get a full listing.
324 #
325 AVRDUDE_PROGRAMMER = jtagmkII
326
327 # com1 = serial port. Use lpt1 to connect to parallel port.
328 AVRDUDE_PORT = usb
329
330 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
331 #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
332
333
334 # Uncomment the following if you want avrdude's erase cycle counter.
335 # Note that this counter needs to be initialized first using -Yn,
336 # see avrdude manual.
337 #AVRDUDE_ERASE_COUNTER = -y
338
339 # Uncomment the following if you do /not/ wish a verification to be
340 # performed after programming the device.
341 AVRDUDE_NO_VERIFY = -V
342
343 # Increase verbosity level. Please use this when submitting bug
344 # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
345 # to submit bug reports.
346 #AVRDUDE_VERBOSE = -v -v
347
348 AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
349 AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
350 AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
351 AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
352
353
354
355 #---------------- Debugging Options ----------------
356
357 # For simulavr only - target MCU frequency.
358 DEBUG_MFREQ = $(F_CPU)
359
360 # Set the DEBUG_UI to either gdb or insight.
361 # DEBUG_UI = gdb
362 DEBUG_UI = insight
363
364 # Set the debugging back-end to either avarice, simulavr.
365 DEBUG_BACKEND = avarice
366 #DEBUG_BACKEND = simulavr
367
368 # GDB Init Filename.
369 GDBINIT_FILE = __avr_gdbinit
370
371 # When using avarice settings for the JTAG
372 JTAG_DEV = /dev/com1
373
374 # Debugging port used to communicate between GDB / avarice / simulavr.
375 DEBUG_PORT = 4242
376
377 # Debugging host used to communicate between GDB / avarice / simulavr, normally
378 # just set to localhost unless doing some sort of crazy debugging when
379 # avarice is running on a different computer.
380 DEBUG_HOST = localhost
381
382
383
384 #============================================================================
385
386
387 # Define programs and commands.
388 SHELL = sh
389 CC = avr-gcc
390 OBJCOPY = avr-objcopy
391 OBJDUMP = avr-objdump
392 SIZE = avr-size
393 AR = avr-ar rcs
394 NM = avr-nm
395 AVRDUDE = avrdude
396 REMOVE = rm -f
397 REMOVEDIR = rm -rf
398 COPY = cp
399 WINSHELL = cmd
400
401 # Define Messages
402 # English
403 MSG_ERRORS_NONE = Errors: none
404 MSG_BEGIN = -------- begin --------
405 MSG_END = -------- end --------
406 MSG_SIZE_BEFORE = Size before:
407 MSG_SIZE_AFTER = Size after:
408 MSG_COFF = Converting to AVR COFF:
409 MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
410 MSG_FLASH = Creating load file for Flash:
411 MSG_EEPROM = Creating load file for EEPROM:
412 MSG_EXTENDED_LISTING = Creating Extended Listing:
413 MSG_SYMBOL_TABLE = Creating Symbol Table:
414 MSG_LINKING = Linking:
415 MSG_COMPILING = Compiling C:
416 MSG_COMPILING_CPP = Compiling C++:
417 MSG_ASSEMBLING = Assembling:
418 MSG_CLEANING = Cleaning project:
419 MSG_CREATING_LIBRARY = Creating library:
420
421
422
423
424 # Define all object files.
425 OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
426
427 # Define all listing files.
428 LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
429
430
431 # Compiler flags to generate dependency files.
432 GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
433
434
435 # Combine all necessary flags and optional flags.
436 # Add target processor to flags.
437 ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
438 ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)
439 ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
440
441
442
443
444
445 # Default target.
446 all: begin gccversion sizebefore build checkhooks checklibmode sizeafter end
447
448 # Change the build target to build a HEX file or a library.
449 build: elf hex eep lss sym
450 #build: lib
451
452
453 elf: $(TARGET).elf
454 hex: $(TARGET).hex
455 eep: $(TARGET).eep
456 lss: $(TARGET).lss
457 sym: $(TARGET).sym
458 LIBNAME=lib$(TARGET).a
459 lib: $(LIBNAME)
460
461
462
463 # Eye candy.
464 # AVR Studio 3.x does not check make's exit code but relies on
465 # the following magic strings to be generated by the compile job.
466 begin:
467 @echo
468 @echo $(MSG_BEGIN)
469
470 end:
471 @echo $(MSG_END)
472 @echo
473
474
475 # Display size of file.
476 HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
477 ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf
478 MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
479 FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
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 checkhooks: build
490 @echo
491 @echo ------- Unhooked LUFA Events -------
492 @$(shell) (grep -s '^Event.*LUFA/.*\\.o' $(TARGET).map | \
493 cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
494 echo "(None)"
495 @echo ----- End Unhooked LUFA Events -----
496
497 checklibmode:
498 @echo
499 @echo ----------- Library Mode -----------
500 @$(shell) ($(CC) $(ALL_CFLAGS) -E -dM - < /dev/null \
501 | grep 'USB_\(DEVICE\|HOST\)_ONLY' | cut -d' ' -f2 | grep ".*") \
502 || echo "No specific mode (both device and host mode allowable)."
503 @echo ------------------------------------
504
505 # Display compiler version information.
506 gccversion :
507 @$(CC) --version
508
509
510
511 # Program the device.
512 program: $(TARGET).hex $(TARGET).eep
513 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
514
515 flip: $(TARGET).hex
516 batchisp -hardware usb -device $(MCU) -operation erase f
517 batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program
518 batchisp -hardware usb -device $(MCU) -operation start reset 0
519
520 dfu: $(TARGET).hex
521 dfu-programmer $(MCU) erase
522 dfu-programmer $(MCU) flash --debug 1 $(TARGET).hex
523 dfu-programmer $(MCU) reset
524
525 flip-ee: $(TARGET).hex $(TARGET).eep
526 copy $(TARGET).eep $(TARGET)eep.hex
527 batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase
528 batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program
529 batchisp -hardware usb -device $(MCU) -operation start reset 0
530
531 dfu-ee: $(TARGET).hex $(TARGET).eep
532 dfu-programmer $(MCU) erase
533 dfu-programmer $(MCU) eeprom --debug 1 $(TARGET).eep
534 dfu-programmer $(MCU) reset
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).cof
679 $(REMOVE) $(TARGET).elf
680 $(REMOVE) $(TARGET).map
681 $(REMOVE) $(TARGET).sym
682 $(REMOVE) $(TARGET).lss
683 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)
684 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)
685 $(REMOVE) $(ASRC:%.S=$(OBJDIR)/%.o)
686 $(REMOVE) $(ASRC:%.S=$(OBJDIR)/%.lst)
687 $(REMOVE) $(SRC:.c=.s)
688 $(REMOVE) $(SRC:.c=.d)
689 $(REMOVE) $(SRC:.c=.i)
690 $(REMOVEDIR) .dep
691
692
693 doxygen:
694 @echo Generating Project Documentation...
695 @doxygen Doxygen.conf
696 @echo Documentation Generation Complete.
697
698 clean_doxygen:
699 rm -rf Documentation
700
701 # Create object files directory
702 $(shell mkdir $(OBJDIR) 2>/dev/null)
703
704
705 # Include the dependency files.
706 -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
707
708
709 # Listing of phony targets.
710 .PHONY : all checkhooks checklibmode begin \
711 finish end sizebefore sizeafter gccversion \
712 build elf hex eep lss sym coff extcoff \
713 clean clean_list clean_binary program debug \
714 gdb-config doxygen clean_doxygen