Fixed minor issue with the RNDISEthernet demo DHCP protocol decoder routine using...
[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 # 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
174 CDEFS += -DSTATIC_ENDPOINT_CONFIGURATION -DFIXED_CONTROL_ENDPOINT_SIZE=8
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 += -fpack-struct
204 CFLAGS += -fshort-enums
205 CFLAGS += -fno-inline-small-functions
206 CFLAGS += -fno-reorder-blocks
207 CFLAGS += -fno-reorder-blocks-and-partition
208 CFLAGS += -fno-reorder-functions
209 CFLAGS += -fno-toplevel-reorder
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 += -Wl,--section-start=.text=$(BOOT_START)
318 LDFLAGS += $(EXTMEMOPTS)
319 LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
320 LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
321 #LDFLAGS += -T linker_script.x
322
323
324
325 #---------------- Programming Options (avrdude) ----------------
326
327 # Programming hardware: alf avr910 avrisp bascom bsd
328 # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
329 #
330 # Type: avrdude -c ?
331 # to get a full listing.
332 #
333 AVRDUDE_PROGRAMMER = jtagmkII
334
335 # com1 = serial port. Use lpt1 to connect to parallel port.
336 AVRDUDE_PORT = usb
337
338 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
339 #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
340
341
342 # Uncomment the following if you want avrdude's erase cycle counter.
343 # Note that this counter needs to be initialized first using -Yn,
344 # see avrdude manual.
345 #AVRDUDE_ERASE_COUNTER = -y
346
347 # Uncomment the following if you do /not/ wish a verification to be
348 # performed after programming the device.
349 #AVRDUDE_NO_VERIFY = -V
350
351 # Increase verbosity level. Please use this when submitting bug
352 # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
353 # to submit bug reports.
354 #AVRDUDE_VERBOSE = -v -v
355
356 AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
357 AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
358 AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
359 AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
360
361
362
363 #---------------- Debugging Options ----------------
364
365 # For simulavr only - target MCU frequency.
366 DEBUG_MFREQ = $(F_CPU)
367
368 # Set the DEBUG_UI to either gdb or insight.
369 # DEBUG_UI = gdb
370 DEBUG_UI = insight
371
372 # Set the debugging back-end to either avarice, simulavr.
373 DEBUG_BACKEND = avarice
374 #DEBUG_BACKEND = simulavr
375
376 # GDB Init Filename.
377 GDBINIT_FILE = __avr_gdbinit
378
379 # When using avarice settings for the JTAG
380 JTAG_DEV = /dev/com1
381
382 # Debugging port used to communicate between GDB / avarice / simulavr.
383 DEBUG_PORT = 4242
384
385 # Debugging host used to communicate between GDB / avarice / simulavr, normally
386 # just set to localhost unless doing some sort of crazy debugging when
387 # avarice is running on a different computer.
388 DEBUG_HOST = localhost
389
390
391
392 #============================================================================
393
394
395 # Define programs and commands.
396 SHELL = sh
397 CC = avr-gcc
398 OBJCOPY = avr-objcopy
399 OBJDUMP = avr-objdump
400 SIZE = avr-size
401 AR = avr-ar rcs
402 NM = avr-nm
403 AVRDUDE = avrdude
404 REMOVE = rm -f
405 REMOVEDIR = rm -rf
406 COPY = cp
407 WINSHELL = cmd
408
409 # Define Messages
410 # English
411 MSG_ERRORS_NONE = Errors: none
412 MSG_BEGIN = -------- begin --------
413 MSG_END = -------- end --------
414 MSG_SIZE_BEFORE = Size before:
415 MSG_SIZE_AFTER = Size after:
416 MSG_COFF = Converting to AVR COFF:
417 MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
418 MSG_FLASH = Creating load file for Flash:
419 MSG_EEPROM = Creating load file for EEPROM:
420 MSG_EXTENDED_LISTING = Creating Extended Listing:
421 MSG_SYMBOL_TABLE = Creating Symbol Table:
422 MSG_LINKING = Linking:
423 MSG_COMPILING = Compiling C:
424 MSG_COMPILING_CPP = Compiling C++:
425 MSG_ASSEMBLING = Assembling:
426 MSG_CLEANING = Cleaning project:
427 MSG_CREATING_LIBRARY = Creating library:
428
429
430
431
432 # Define all object files.
433 OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
434
435 # Define all listing files.
436 LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
437
438
439 # Compiler flags to generate dependency files.
440 GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
441
442
443 # Combine all necessary flags and optional flags.
444 # Add target processor to flags.
445 ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
446 ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)
447 ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
448
449
450
451
452
453 # Default target.
454 all: begin gccversion sizebefore build checkhooks checklibmode checkboard sizeafter end
455
456 # Change the build target to build a HEX file or a library.
457 build: elf hex eep lss sym
458 #build: lib
459
460
461 elf: $(TARGET).elf
462 hex: $(TARGET).hex
463 eep: $(TARGET).eep
464 lss: $(TARGET).lss
465 sym: $(TARGET).sym
466 LIBNAME=lib$(TARGET).a
467 lib: $(LIBNAME)
468
469
470
471 # Eye candy.
472 # AVR Studio 3.x does not check make's exit code but relies on
473 # the following magic strings to be generated by the compile job.
474 begin:
475 @echo
476 @echo $(MSG_BEGIN)
477
478 end:
479 @echo $(MSG_END)
480 @echo
481
482
483 # Display size of file.
484 HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
485 ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf
486 MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
487 FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
488
489 sizebefore:
490 @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
491 2>/dev/null; echo; fi
492
493 sizeafter:
494 @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
495 2>/dev/null; echo; fi
496
497 checkhooks: build
498 @echo
499 @echo ------- Unhooked LUFA Events -------
500 @$(shell) (grep -s '^Event.*LUFA/.*\\.o' $(TARGET).map | \
501 cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
502 echo "(None)"
503 @echo ------------------------------------
504
505 checklibmode:
506 @echo
507 @echo ----------- Library Mode -----------
508 @$(shell) ($(CC) $(ALL_CFLAGS) -E -dM - < /dev/null \
509 | grep 'USB_\(DEVICE\|HOST\)_ONLY' | cut -d' ' -f2 | grep ".*") \
510 || echo "No specific mode (both device and host mode allowable)."
511 @echo ------------------------------------
512
513 checkboard:
514 @echo
515 @echo ---------- Selected Board ----------
516 @echo Selected board model is $(BOARD).
517 @echo ------------------------------------
518
519 # Display compiler version information.
520 gccversion :
521 @$(CC) --version
522
523
524
525 # Program the device.
526 program: $(TARGET).hex $(TARGET).eep
527 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
528
529
530 # Generate avr-gdb config/init file which does the following:
531 # define the reset signal, load the target file, connect to target, and set
532 # a breakpoint at main().
533 gdb-config:
534 @$(REMOVE) $(GDBINIT_FILE)
535 @echo define reset >> $(GDBINIT_FILE)
536 @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
537 @echo end >> $(GDBINIT_FILE)
538 @echo file $(TARGET).elf >> $(GDBINIT_FILE)
539 @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
540 ifeq ($(DEBUG_BACKEND),simulavr)
541 @echo load >> $(GDBINIT_FILE)
542 endif
543 @echo break main >> $(GDBINIT_FILE)
544
545 debug: gdb-config $(TARGET).elf
546 ifeq ($(DEBUG_BACKEND), avarice)
547 @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
548 @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
549 $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
550 @$(WINSHELL) /c pause
551
552 else
553 @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
554 $(DEBUG_MFREQ) --port $(DEBUG_PORT)
555 endif
556 @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
557
558
559
560
561 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
562 COFFCONVERT = $(OBJCOPY) --debugging
563 COFFCONVERT += --change-section-address .data-0x800000
564 COFFCONVERT += --change-section-address .bss-0x800000
565 COFFCONVERT += --change-section-address .noinit-0x800000
566 COFFCONVERT += --change-section-address .eeprom-0x810000
567
568
569
570 coff: $(TARGET).elf
571 @echo
572 @echo $(MSG_COFF) $(TARGET).cof
573 $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
574
575
576 extcoff: $(TARGET).elf
577 @echo
578 @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
579 $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
580
581
582
583 # Create final output files (.hex, .eep) from ELF output file.
584 %.hex: %.elf
585 @echo
586 @echo $(MSG_FLASH) $@
587 $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
588
589 %.eep: %.elf
590 @echo
591 @echo $(MSG_EEPROM) $@
592 -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
593 --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
594
595 # Create extended listing file from ELF output file.
596 %.lss: %.elf
597 @echo
598 @echo $(MSG_EXTENDED_LISTING) $@
599 $(OBJDUMP) -h -z -S $< > $@
600
601 # Create a symbol table from ELF output file.
602 %.sym: %.elf
603 @echo
604 @echo $(MSG_SYMBOL_TABLE) $@
605 $(NM) -n $< > $@
606
607
608
609 # Create library from object files.
610 .SECONDARY : $(TARGET).a
611 .PRECIOUS : $(OBJ)
612 %.a: $(OBJ)
613 @echo
614 @echo $(MSG_CREATING_LIBRARY) $@
615 $(AR) $@ $(OBJ)
616
617
618 # Link: create ELF output file from object files.
619 .SECONDARY : $(TARGET).elf
620 .PRECIOUS : $(OBJ)
621 %.elf: $(OBJ)
622 @echo
623 @echo $(MSG_LINKING) $@
624 $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
625
626
627 # Compile: create object files from C source files.
628 $(OBJDIR)/%.o : %.c
629 @echo
630 @echo $(MSG_COMPILING) $<
631 $(CC) -c $(ALL_CFLAGS) $< -o $@
632
633
634 # Compile: create object files from C++ source files.
635 $(OBJDIR)/%.o : %.cpp
636 @echo
637 @echo $(MSG_COMPILING_CPP) $<
638 $(CC) -c $(ALL_CPPFLAGS) $< -o $@
639
640
641 # Compile: create assembler files from C source files.
642 %.s : %.c
643 $(CC) -S $(ALL_CFLAGS) $< -o $@
644
645
646 # Compile: create assembler files from C++ source files.
647 %.s : %.cpp
648 $(CC) -S $(ALL_CPPFLAGS) $< -o $@
649
650
651 # Assemble: create object files from assembler source files.
652 $(OBJDIR)/%.o : %.S
653 @echo
654 @echo $(MSG_ASSEMBLING) $<
655 $(CC) -c $(ALL_ASFLAGS) $< -o $@
656
657
658 # Create preprocessed source for use in sending a bug report.
659 %.i : %.c
660 $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
661
662
663 # Target: clean project.
664 clean: begin clean_list clean_binary end
665
666 clean_binary:
667 $(REMOVE) $(TARGET).hex
668
669 clean_list:
670 @echo $(MSG_CLEANING)
671 $(REMOVE) $(TARGET).eep
672 $(REMOVE) $(TARGET)eep.hex
673 $(REMOVE) $(TARGET).cof
674 $(REMOVE) $(TARGET).elf
675 $(REMOVE) $(TARGET).map
676 $(REMOVE) $(TARGET).sym
677 $(REMOVE) $(TARGET).lss
678 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)
679 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)
680 $(REMOVE) $(SRC:.c=.s)
681 $(REMOVE) $(SRC:.c=.d)
682 $(REMOVE) $(SRC:.c=.i)
683 $(REMOVEDIR) .dep
684
685
686 doxygen:
687 @echo Generating Project Documentation...
688 @doxygen Doxygen.conf
689 @echo Documentation Generation Complete.
690
691 clean_doxygen:
692 rm -rf Documentation
693
694 # Create object files directory
695 $(shell mkdir $(OBJDIR) 2>/dev/null)
696
697
698 # Include the dependency files.
699 -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
700
701
702 # Listing of phony targets.
703 .PHONY : all checkhooks checklibmode checkboard \
704 begin finish end sizebefore sizeafter gccversion \
705 build elf hex eep lss sym coff extcoff clean \
706 clean_list clean_binary program debug gdb-config \
707 doxygen