Break device mode class driver interfaces into seperate config and state structs...
[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, 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 = BootloaderCDC
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/DevChapter9.c \
117 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Endpoint.c \
118 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Host.c \
119 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/HostChapter9.c \
120 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/LowLevel.c \
121 $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Pipe.c \
122 $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/Events.c \
123 $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/USBInterrupt.c \
124 $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/USBTask.c \
125 $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c \
126
127
128 # List C++ source files here. (C dependencies are automatically generated.)
129 CPPSRC =
130
131
132 # List Assembler source files here.
133 # Make them always end in a capital .S. Files ending in a lowercase .s
134 # will not be considered source files but generated files (assembler
135 # output from the compiler), and will be deleted upon "make clean"!
136 # Even though the DOS/Win* filesystem matches both .s and .S the same,
137 # it will preserve the spelling of the filenames, and gcc itself does
138 # care about how the name is spelled on its command-line.
139 ASRC =
140
141
142 # Optimization level, can be [0, 1, 2, 3, s].
143 # 0 = turn off optimization. s = optimize for size.
144 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
145 OPT = s
146
147
148 # Debugging format.
149 # Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
150 # AVR Studio 4.10 requires dwarf-2.
151 # AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
152 DEBUG = dwarf-2
153
154
155 # List any extra directories to look for include files here.
156 # Each directory must be seperated by a space.
157 # Use forward slashes for directory separators.
158 # For a directory that has spaces, enclose it in quotes.
159 EXTRAINCDIRS = $(LUFA_PATH)/
160
161
162 # Compiler flag to set the C Standard level.
163 # c89 = "ANSI" C
164 # gnu89 = c89 plus GCC extensions
165 # c99 = ISO C99 standard (not yet fully implemented)
166 # gnu99 = c99 plus GCC extensions
167 CSTANDARD = -std=gnu99
168
169
170 # Starting byte address of the bootloader
171 BOOT_START = 0x1E000
172
173
174 # Place -D or -U options here for C sources
175 CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
176 CDEFS += -DUSB_DEVICE_ONLY -DUSE_NONSTANDARD_DESCRIPTOR_NAMES
177 CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
178 CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
179 CDEFS += -DUSE_RAM_DESCRIPTORS -DBOOT_START_ADDR=$(BOOT_START)UL
180
181
182 # Place -D or -U options here for ASM sources
183 ADEFS = -DF_CPU=$(F_CPU)
184
185
186 # Place -D or -U options here for C++ sources
187 CPPDEFS = -DF_CPU=$(F_CPU)UL
188 #CPPDEFS += -D__STDC_LIMIT_MACROS
189 #CPPDEFS += -D__STDC_CONSTANT_MACROS
190
191
192
193 #---------------- Compiler Options C ----------------
194 # -g*: generate debugging information
195 # -O*: optimization level
196 # -f...: tuning, see GCC manual and avr-libc documentation
197 # -Wall...: warning level
198 # -Wa,...: tell GCC to pass this to the assembler.
199 # -adhlns...: create assembler listing
200 CFLAGS = -g$(DEBUG)
201 CFLAGS += $(CDEFS)
202 CFLAGS += -O$(OPT)
203 CFLAGS += -funsigned-char
204 CFLAGS += -funsigned-bitfields
205 CFLAGS += -ffunction-sections
206 CFLAGS += -fpack-struct
207 CFLAGS += -fshort-enums
208 CFLAGS += -fno-inline-small-functions
209 CFLAGS += -Wall
210 CFLAGS += -Wstrict-prototypes
211 CFLAGS += -Wundef
212 #CFLAGS += -fno-unit-at-a-time
213 #CFLAGS += -Wunreachable-code
214 #CFLAGS += -Wsign-compare
215 CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
216 CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
217 CFLAGS += $(CSTANDARD)
218
219
220 #---------------- Compiler Options C++ ----------------
221 # -g*: generate debugging information
222 # -O*: optimization level
223 # -f...: tuning, see GCC manual and avr-libc documentation
224 # -Wall...: warning level
225 # -Wa,...: tell GCC to pass this to the assembler.
226 # -adhlns...: create assembler listing
227 CPPFLAGS = -g$(DEBUG)
228 CPPFLAGS += $(CPPDEFS)
229 CPPFLAGS += -O$(OPT)
230 CPPFLAGS += -funsigned-char
231 CPPFLAGS += -funsigned-bitfields
232 CPPFLAGS += -fpack-struct
233 CPPFLAGS += -fshort-enums
234 CPPFLAGS += -fno-exceptions
235 CPPFLAGS += -Wall
236 CFLAGS += -Wundef
237 #CPPFLAGS += -mshort-calls
238 #CPPFLAGS += -fno-unit-at-a-time
239 #CPPFLAGS += -Wstrict-prototypes
240 #CPPFLAGS += -Wunreachable-code
241 #CPPFLAGS += -Wsign-compare
242 CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst)
243 CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
244 #CPPFLAGS += $(CSTANDARD)
245
246
247 #---------------- Assembler Options ----------------
248 # -Wa,...: tell GCC to pass this to the assembler.
249 # -adhlns: create listing
250 # -gstabs: have the assembler create line number information; note that
251 # for use in COFF files, additional information about filenames
252 # and function names needs to be present in the assembler source
253 # files -- see avr-libc docs [FIXME: not yet described there]
254 # -listing-cont-lines: Sets the maximum number of continuation lines of hex
255 # dump that will be displayed for a given single line of source input.
256 ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
257
258
259 #---------------- Library Options ----------------
260 # Minimalistic printf version
261 PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
262
263 # Floating point printf version (requires MATH_LIB = -lm below)
264 PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
265
266 # If this is left blank, then it will use the Standard printf version.
267 PRINTF_LIB =
268 #PRINTF_LIB = $(PRINTF_LIB_MIN)
269 #PRINTF_LIB = $(PRINTF_LIB_FLOAT)
270
271
272 # Minimalistic scanf version
273 SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
274
275 # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
276 SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
277
278 # If this is left blank, then it will use the Standard scanf version.
279 SCANF_LIB =
280 #SCANF_LIB = $(SCANF_LIB_MIN)
281 #SCANF_LIB = $(SCANF_LIB_FLOAT)
282
283
284 MATH_LIB = -lm
285
286
287 # List any extra directories to look for libraries here.
288 # Each directory must be seperated by a space.
289 # Use forward slashes for directory separators.
290 # For a directory that has spaces, enclose it in quotes.
291 EXTRALIBDIRS =
292
293
294
295 #---------------- External Memory Options ----------------
296
297 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
298 # used for variables (.data/.bss) and heap (malloc()).
299 #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
300
301 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
302 # only used for heap (malloc()).
303 #EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
304
305 EXTMEMOPTS =
306
307
308
309 #---------------- Linker Options ----------------
310 # -Wl,...: tell GCC to pass this to linker.
311 # -Map: create map file
312 # --cref: add cross reference to map file
313 LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
314 LDFLAGS += -Wl,--relax
315 LDFLAGS += -Wl,--gc-sections
316 LDFLAGS += -Wl,--section-start=.text=$(BOOT_START)
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
529 # Generate avr-gdb config/init file which does the following:
530 # define the reset signal, load the target file, connect to target, and set
531 # a breakpoint at main().
532 gdb-config:
533 @$(REMOVE) $(GDBINIT_FILE)
534 @echo define reset >> $(GDBINIT_FILE)
535 @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
536 @echo end >> $(GDBINIT_FILE)
537 @echo file $(TARGET).elf >> $(GDBINIT_FILE)
538 @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
539 ifeq ($(DEBUG_BACKEND),simulavr)
540 @echo load >> $(GDBINIT_FILE)
541 endif
542 @echo break main >> $(GDBINIT_FILE)
543
544 debug: gdb-config $(TARGET).elf
545 ifeq ($(DEBUG_BACKEND), avarice)
546 @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
547 @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
548 $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
549 @$(WINSHELL) /c pause
550
551 else
552 @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
553 $(DEBUG_MFREQ) --port $(DEBUG_PORT)
554 endif
555 @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
556
557
558
559
560 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
561 COFFCONVERT = $(OBJCOPY) --debugging
562 COFFCONVERT += --change-section-address .data-0x800000
563 COFFCONVERT += --change-section-address .bss-0x800000
564 COFFCONVERT += --change-section-address .noinit-0x800000
565 COFFCONVERT += --change-section-address .eeprom-0x810000
566
567
568
569 coff: $(TARGET).elf
570 @echo
571 @echo $(MSG_COFF) $(TARGET).cof
572 $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
573
574
575 extcoff: $(TARGET).elf
576 @echo
577 @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
578 $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
579
580
581
582 # Create final output files (.hex, .eep) from ELF output file.
583 %.hex: %.elf
584 @echo
585 @echo $(MSG_FLASH) $@
586 $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
587
588 %.eep: %.elf
589 @echo
590 @echo $(MSG_EEPROM) $@
591 -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
592 --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
593
594 # Create extended listing file from ELF output file.
595 %.lss: %.elf
596 @echo
597 @echo $(MSG_EXTENDED_LISTING) $@
598 $(OBJDUMP) -h -z -S $< > $@
599
600 # Create a symbol table from ELF output file.
601 %.sym: %.elf
602 @echo
603 @echo $(MSG_SYMBOL_TABLE) $@
604 $(NM) -n $< > $@
605
606
607
608 # Create library from object files.
609 .SECONDARY : $(TARGET).a
610 .PRECIOUS : $(OBJ)
611 %.a: $(OBJ)
612 @echo
613 @echo $(MSG_CREATING_LIBRARY) $@
614 $(AR) $@ $(OBJ)
615
616
617 # Link: create ELF output file from object files.
618 .SECONDARY : $(TARGET).elf
619 .PRECIOUS : $(OBJ)
620 %.elf: $(OBJ)
621 @echo
622 @echo $(MSG_LINKING) $@
623 $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
624
625
626 # Compile: create object files from C source files.
627 $(OBJDIR)/%.o : %.c
628 @echo
629 @echo $(MSG_COMPILING) $<
630 $(CC) -c $(ALL_CFLAGS) $< -o $@
631
632
633 # Compile: create object files from C++ source files.
634 $(OBJDIR)/%.o : %.cpp
635 @echo
636 @echo $(MSG_COMPILING_CPP) $<
637 $(CC) -c $(ALL_CPPFLAGS) $< -o $@
638
639
640 # Compile: create assembler files from C source files.
641 %.s : %.c
642 $(CC) -S $(ALL_CFLAGS) $< -o $@
643
644
645 # Compile: create assembler files from C++ source files.
646 %.s : %.cpp
647 $(CC) -S $(ALL_CPPFLAGS) $< -o $@
648
649
650 # Assemble: create object files from assembler source files.
651 $(OBJDIR)/%.o : %.S
652 @echo
653 @echo $(MSG_ASSEMBLING) $<
654 $(CC) -c $(ALL_ASFLAGS) $< -o $@
655
656
657 # Create preprocessed source for use in sending a bug report.
658 %.i : %.c
659 $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
660
661
662 # Target: clean project.
663 clean: begin clean_list clean_binary end
664
665 clean_binary:
666 $(REMOVE) $(TARGET).hex
667
668 clean_list:
669 @echo $(MSG_CLEANING)
670 $(REMOVE) $(TARGET).eep
671 $(REMOVE) $(TARGET)eep.hex
672 $(REMOVE) $(TARGET).cof
673 $(REMOVE) $(TARGET).elf
674 $(REMOVE) $(TARGET).map
675 $(REMOVE) $(TARGET).sym
676 $(REMOVE) $(TARGET).lss
677 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)
678 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)
679 $(REMOVE) $(SRC:.c=.s)
680 $(REMOVE) $(SRC:.c=.d)
681 $(REMOVE) $(SRC:.c=.i)
682 $(REMOVEDIR) .dep
683
684
685 doxygen:
686 @echo Generating Project Documentation...
687 @doxygen Doxygen.conf
688 @echo Documentation Generation Complete.
689
690 clean_doxygen:
691 rm -rf Documentation
692
693 # Create object files directory
694 $(shell mkdir $(OBJDIR) 2>/dev/null)
695
696
697 # Include the dependency files.
698 -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
699
700
701 # Listing of phony targets.
702 .PHONY : all checkhooks checklibmode checkboard \
703 begin finish end sizebefore sizeafter gccversion \
704 build elf hex eep lss sym coff extcoff clean \
705 clean_list clean_binary program debug gdb-config \
706 doxygen