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