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