Fixed GenericHIDHost demo report write routine incorrect for control type requests...
[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 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 BoardTypes.h documentation, USER or blank 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. 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 # Typical values are:
66 # F_CPU = 1000000
67 # F_CPU = 1843200
68 # F_CPU = 2000000
69 # F_CPU = 3686400
70 # F_CPU = 4000000
71 # F_CPU = 7372800
72 # F_CPU = 8000000
73 # F_CPU = 11059200
74 # F_CPU = 14745600
75 # F_CPU = 16000000
76 # F_CPU = 18432000
77 # F_CPU = 20000000
78 F_CPU = 8000000
79
80
81 # Input clock frequency.
82 # This will define a symbol, F_CLOCK, in all source code files equal to the
83 # input clock frequency (before any prescaling is performed). This value may
84 # differ from F_CPU if prescaling is used on the latter, and is required as the
85 # raw input clock is fed directly to the PLL sections of the AVR for high speed
86 # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
87 # at the end, this will be done automatically to create a 32-bit value in your
88 # source code.
89 #
90 # If no clock division is performed on the input clock inside the AVR (via the
91 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
92 F_CLOCK = 8000000
93
94
95 # Output format. (can be srec, ihex, binary)
96 FORMAT = ihex
97
98
99 # Target file name (without extension).
100 TARGET = BootloaderDFU
101
102
103 # Object files directory
104 # To put object files in current directory, use a dot (.), do NOT make
105 # this an empty or blank macro!
106 OBJDIR = .
107
108
109 # Path to the LUFA library
110 LUFA_PATH = ../..
111
112
113 # List C source files here. (C dependencies are automatically generated.)
114 SRC = $(TARGET).c \
115 Descriptors.c \
116 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/LowLevel.c \
117 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Endpoint.c \
118 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c \
119 $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/USBTask.c \
120 $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/USBInterrupt.c \
121 $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/Events.c \
122 $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/StdDescriptors.c \
123
124
125 # List C++ source files here. (C dependencies are automatically generated.)
126 CPPSRC =
127
128
129 # List Assembler source files here.
130 # Make them always end in a capital .S. Files ending in a lowercase .s
131 # will not be considered source files but generated files (assembler
132 # output from the compiler), and will be deleted upon "make clean"!
133 # Even though the DOS/Win* filesystem matches both .s and .S the same,
134 # it will preserve the spelling of the filenames, and gcc itself does
135 # care about how the name is spelled on its command-line.
136 ASRC =
137
138
139 # Optimization level, can be [0, 1, 2, 3, s].
140 # 0 = turn off optimization. s = optimize for size.
141 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
142 OPT = s
143
144
145 # Debugging format.
146 # Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
147 # AVR Studio 4.10 requires dwarf-2.
148 # AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
149 DEBUG = dwarf-2
150
151
152 # List any extra directories to look for include files here.
153 # Each directory must be seperated by a space.
154 # Use forward slashes for directory separators.
155 # For a directory that has spaces, enclose it in quotes.
156 EXTRAINCDIRS = $(LUFA_PATH)/
157
158
159 # Compiler flag to set the C Standard level.
160 # c89 = "ANSI" C
161 # gnu89 = c89 plus GCC extensions
162 # c99 = ISO C99 standard (not yet fully implemented)
163 # gnu99 = c99 plus GCC extensions
164 CSTANDARD = -std=gnu99
165
166
167 # Starting byte address of the bootloader
168 BOOT_START = 0x1E000
169
170
171 # Place -D or -U options here for C sources
172 CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
173 CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DFEATURELESS_CONTROL_ONLY_DEVICE
174 CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=32
175 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
176 CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL -DUSE_SINGLE_DEVICE_CONFIGURATION
177
178
179 # Place -D or -U options here for ASM sources
180 ADEFS = -DF_CPU=$(F_CPU)
181
182
183 # Place -D or -U options here for C++ sources
184 CPPDEFS = -DF_CPU=$(F_CPU)UL
185 #CPPDEFS += -D__STDC_LIMIT_MACROS
186 #CPPDEFS += -D__STDC_CONSTANT_MACROS
187
188
189
190 #---------------- Compiler Options C ----------------
191 # -g*: generate debugging information
192 # -O*: optimization level
193 # -f...: tuning, see GCC manual and avr-libc documentation
194 # -Wall...: warning level
195 # -Wa,...: tell GCC to pass this to the assembler.
196 # -adhlns...: create assembler listing
197 CFLAGS = -g$(DEBUG)
198 CFLAGS += $(CDEFS)
199 CFLAGS += -O$(OPT)
200 CFLAGS += -funsigned-char
201 CFLAGS += -funsigned-bitfields
202 CFLAGS += -ffunction-sections
203 CFLAGS += -fdata-sections
204 CFLAGS += -fpack-struct
205 CFLAGS += -fshort-enums
206 CFLAGS += -fno-inline-small-functions
207 CFLAGS += -fno-reorder-blocks
208 CFLAGS += -fno-reorder-blocks-and-partition
209 CFLAGS += -fno-reorder-functions
210 CFLAGS += -fno-toplevel-reorder
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,--relax
317 LDFLAGS += -Wl,--gc-sections
318 LDFLAGS += -Wl,--section-start=.text=$(BOOT_START)
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 checkhooks checklibmode checkboard 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 checkhooks: build
499 @echo
500 @echo ------- Unhooked LUFA Events -------
501 @$(shell) (grep -s '^Event.*LUFA/.*\\.o' $(TARGET).map | \
502 cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
503 echo "(None)"
504 @echo ------------------------------------
505
506 checklibmode:
507 @echo
508 @echo ----------- Library Mode -----------
509 @$(shell) ($(CC) $(ALL_CFLAGS) -E -dM - < /dev/null \
510 | grep 'USB_\(DEVICE\|HOST\)_ONLY' | cut -d' ' -f2 | grep ".*") \
511 || echo "No specific mode (both device and host mode allowable)."
512 @echo ------------------------------------
513
514 checkboard:
515 @echo
516 @echo ---------- Selected Board ----------
517 @echo Selected board model is $(BOARD).
518 @echo ------------------------------------
519
520 # Display compiler version information.
521 gccversion :
522 @$(CC) --version
523
524
525
526 # Program the device.
527 program: $(TARGET).hex $(TARGET).eep
528 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
529
530
531 # Generate avr-gdb config/init file which does the following:
532 # define the reset signal, load the target file, connect to target, and set
533 # a breakpoint at main().
534 gdb-config:
535 @$(REMOVE) $(GDBINIT_FILE)
536 @echo define reset >> $(GDBINIT_FILE)
537 @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
538 @echo end >> $(GDBINIT_FILE)
539 @echo file $(TARGET).elf >> $(GDBINIT_FILE)
540 @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
541 ifeq ($(DEBUG_BACKEND),simulavr)
542 @echo load >> $(GDBINIT_FILE)
543 endif
544 @echo break main >> $(GDBINIT_FILE)
545
546 debug: gdb-config $(TARGET).elf
547 ifeq ($(DEBUG_BACKEND), avarice)
548 @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
549 @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
550 $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
551 @$(WINSHELL) /c pause
552
553 else
554 @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
555 $(DEBUG_MFREQ) --port $(DEBUG_PORT)
556 endif
557 @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
558
559
560
561
562 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
563 COFFCONVERT = $(OBJCOPY) --debugging
564 COFFCONVERT += --change-section-address .data-0x800000
565 COFFCONVERT += --change-section-address .bss-0x800000
566 COFFCONVERT += --change-section-address .noinit-0x800000
567 COFFCONVERT += --change-section-address .eeprom-0x810000
568
569
570
571 coff: $(TARGET).elf
572 @echo
573 @echo $(MSG_COFF) $(TARGET).cof
574 $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
575
576
577 extcoff: $(TARGET).elf
578 @echo
579 @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
580 $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
581
582
583
584 # Create final output files (.hex, .eep) from ELF output file.
585 %.hex: %.elf
586 @echo
587 @echo $(MSG_FLASH) $@
588 $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
589
590 %.eep: %.elf
591 @echo
592 @echo $(MSG_EEPROM) $@
593 -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
594 --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
595
596 # Create extended listing file from ELF output file.
597 %.lss: %.elf
598 @echo
599 @echo $(MSG_EXTENDED_LISTING) $@
600 $(OBJDUMP) -h -z -S $< > $@
601
602 # Create a symbol table from ELF output file.
603 %.sym: %.elf
604 @echo
605 @echo $(MSG_SYMBOL_TABLE) $@
606 $(NM) -n $< > $@
607
608
609
610 # Create library from object files.
611 .SECONDARY : $(TARGET).a
612 .PRECIOUS : $(OBJ)
613 %.a: $(OBJ)
614 @echo
615 @echo $(MSG_CREATING_LIBRARY) $@
616 $(AR) $@ $(OBJ)
617
618
619 # Link: create ELF output file from object files.
620 .SECONDARY : $(TARGET).elf
621 .PRECIOUS : $(OBJ)
622 %.elf: $(OBJ)
623 @echo
624 @echo $(MSG_LINKING) $@
625 $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
626
627
628 # Compile: create object files from C source files.
629 $(OBJDIR)/%.o : %.c
630 @echo
631 @echo $(MSG_COMPILING) $<
632 $(CC) -c $(ALL_CFLAGS) $< -o $@
633
634
635 # Compile: create object files from C++ source files.
636 $(OBJDIR)/%.o : %.cpp
637 @echo
638 @echo $(MSG_COMPILING_CPP) $<
639 $(CC) -c $(ALL_CPPFLAGS) $< -o $@
640
641
642 # Compile: create assembler files from C source files.
643 %.s : %.c
644 $(CC) -S $(ALL_CFLAGS) $< -o $@
645
646
647 # Compile: create assembler files from C++ source files.
648 %.s : %.cpp
649 $(CC) -S $(ALL_CPPFLAGS) $< -o $@
650
651
652 # Assemble: create object files from assembler source files.
653 $(OBJDIR)/%.o : %.S
654 @echo
655 @echo $(MSG_ASSEMBLING) $<
656 $(CC) -c $(ALL_ASFLAGS) $< -o $@
657
658
659 # Create preprocessed source for use in sending a bug report.
660 %.i : %.c
661 $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
662
663
664 # Target: clean project.
665 clean: begin clean_list clean_binary end
666
667 clean_binary:
668 $(REMOVE) $(TARGET).hex
669
670 clean_list:
671 @echo $(MSG_CLEANING)
672 $(REMOVE) $(TARGET).eep
673 $(REMOVE) $(TARGET)eep.hex
674 $(REMOVE) $(TARGET).cof
675 $(REMOVE) $(TARGET).elf
676 $(REMOVE) $(TARGET).map
677 $(REMOVE) $(TARGET).sym
678 $(REMOVE) $(TARGET).lss
679 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)
680 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)
681 $(REMOVE) $(SRC:.c=.s)
682 $(REMOVE) $(SRC:.c=.d)
683 $(REMOVE) $(SRC:.c=.i)
684 $(REMOVEDIR) .dep
685
686
687 doxygen:
688 @echo Generating Project Documentation...
689 @doxygen Doxygen.conf
690 @echo Documentation Generation Complete.
691
692 clean_doxygen:
693 rm -rf Documentation
694
695 # Create object files directory
696 $(shell mkdir $(OBJDIR) 2>/dev/null)
697
698
699 # Include the dependency files.
700 -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
701
702
703 # Listing of phony targets.
704 .PHONY : all checkhooks checklibmode checkboard \
705 begin finish end sizebefore sizeafter gccversion \
706 build elf hex eep lss sym coff extcoff clean \
707 clean_list clean_binary program debug gdb-config \
708 doxygen