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