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