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