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