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