Rev Author Line No. Line
2770 kaklik 1 # Hey Emacs, this is a -*- makefile -*-
2 #----------------------------------------------------------------------------
3 # WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
4 #
5 # Released to the Public Domain
6 #
7 # Additional material for this makefile was written by:
8 # Peter Fleury
9 # Tim Henigan
10 # Colin O'Flynn
11 # Reiner Patommel
12 # Markus Pfaff
13 # Sander Pool
14 # Frederik Rouleau
15 # Carlos Lamas
16 #
17 #----------------------------------------------------------------------------
18 # On command line:
19 #
20 # make all = Make software.
21 #
22 # make clean = Clean out built project files.
23 #
24 # make coff = Convert ELF to AVR COFF.
25 #
26 # make extcoff = Convert ELF to AVR Extended COFF.
27 #
28 # make program = Download the hex file to the device, using avrdude.
29 # Please customize the avrdude settings below first!
30 #
31 # make debug = Start either simulavr or avarice as specified for debugging,
32 # with avr-gdb or avr-insight as the front end for debugging.
33 #
34 # make filename.s = Just compile filename.c into the assembler code only.
35 #
36 # make filename.i = Create a preprocessed source file for use in submitting
37 # bug reports to the GCC project.
38 #
39 # To rebuild project do "make clean" then "make all".
40 #----------------------------------------------------------------------------
41  
42  
43 # MCU name
44 MCU = atmega328p
45  
46  
47 # Processor frequency.
48 # This will define a symbol, F_CPU, in all source code files equal to the
49 # processor frequency. You can then use this symbol in your source code to
50 # calculate timings. Do NOT tack on a 'UL' at the end, this will be done
51 # automatically to create a 32-bit value in your source code.
52 # Typical values are:
53 # F_CPU = 1000000
54 # F_CPU = 1843200
55 # F_CPU = 2000000
56 # F_CPU = 3686400
57 # F_CPU = 4000000
58 # F_CPU = 7372800
59 # F_CPU = 8000000
60 # F_CPU = 11059200
61 # F_CPU = 14745600
62 # F_CPU = 16000000
63 # F_CPU = 18432000
64 # F_CPU = 20000000
65 F_CPU = 8000000
66  
67  
68 # Output format. (can be srec, ihex, binary)
69 FORMAT = ihex
70  
71  
72 # Target file name (without extension).
73 TARGET = main
74  
75  
76 # Object files directory
77 # To put object files in current directory, use a dot (.), do NOT make
78 # this an empty or blank macro!
79 OBJDIR = .
80  
81  
82 # List C source files here. (C dependencies are automatically generated.)
83 SRC = $(TARGET).c
84 #SRC += LCD_driver.c
85  
86  
87 # List C++ source files here. (C dependencies are automatically generated.)
88 CPPSRC =
89  
90  
91 # List Assembler source files here.
92 # Make them always end in a capital .S. Files ending in a lowercase .s
93 # will not be considered source files but generated files (assembler
94 # output from the compiler), and will be deleted upon "make clean"!
95 # Even though the DOS/Win* filesystem matches both .s and .S the same,
96 # it will preserve the spelling of the filenames, and gcc itself does
97 # care about how the name is spelled on its command-line.
98 ASRC =
99  
100  
101 # Optimization level, can be [0, 1, 2, 3, s].
102 # 0 = turn off optimization. s = optimize for size.
103 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
104 OPT = s
105  
106  
107 # Debugging format.
108 # Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
109 # AVR Studio 4.10 requires dwarf-2.
110 # AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
111 DEBUG = dwarf-2
112  
113  
114 # List any extra directories to look for include files here.
115 # Each directory must be seperated by a space.
116 # Use forward slashes for directory separators.
117 # For a directory that has spaces, enclose it in quotes.
118 EXTRAINCDIRS =
119  
120  
121 # Compiler flag to set the C Standard level.
122 # c89 = "ANSI" C
123 # gnu89 = c89 plus GCC extensions
124 # c99 = ISO C99 standard (not yet fully implemented)
125 # gnu99 = c99 plus GCC extensions
126 CSTANDARD = -std=gnu99
127  
128  
129 # Place -D or -U options here for C sources
130 CDEFS = -DF_CPU=$(F_CPU)UL
131  
132  
133 # Place -D or -U options here for ASM sources
134 ADEFS = -DF_CPU=$(F_CPU)
135  
136  
137 # Place -D or -U options here for C++ sources
138 CPPDEFS = -DF_CPU=$(F_CPU)UL
139 #CPPDEFS += -D__STDC_LIMIT_MACROS
140 #CPPDEFS += -D__STDC_CONSTANT_MACROS
141  
142  
143  
144 #---------------- Compiler Options C ----------------
145 # -g*: generate debugging information
146 # -O*: optimization level
147 # -f...: tuning, see GCC manual and avr-libc documentation
148 # -Wall...: warning level
149 # -Wa,...: tell GCC to pass this to the assembler.
150 # -adhlns...: create assembler listing
151 CFLAGS = -g$(DEBUG)
152 CFLAGS += $(CDEFS)
153 CFLAGS += -O$(OPT)
154 CFLAGS += -funsigned-char
155 CFLAGS += -funsigned-bitfields
156 CFLAGS += -fpack-struct
157 CFLAGS += -fshort-enums
158 CFLAGS += -Wall
159 CFLAGS += -Wstrict-prototypes
160 #CFLAGS += -mshort-calls
161 #CFLAGS += -fno-unit-at-a-time
162 #CFLAGS += -Wundef
163 #CFLAGS += -Wunreachable-code
164 #CFLAGS += -Wsign-compare
165 CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
166 CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
167 CFLAGS += $(CSTANDARD)
168  
169  
170 #---------------- Compiler Options C++ ----------------
171 # -g*: generate debugging information
172 # -O*: optimization level
173 # -f...: tuning, see GCC manual and avr-libc documentation
174 # -Wall...: warning level
175 # -Wa,...: tell GCC to pass this to the assembler.
176 # -adhlns...: create assembler listing
177 CPPFLAGS = -g$(DEBUG)
178 CPPFLAGS += $(CPPDEFS)
179 CPPFLAGS += -O$(OPT)
180 CPPFLAGS += -funsigned-char
181 CPPFLAGS += -funsigned-bitfields
182 CPPFLAGS += -fpack-struct
183 CPPFLAGS += -fshort-enums
184 CPPFLAGS += -fno-exceptions
185 CPPFLAGS += -Wall
186 CFLAGS += -Wundef
187 #CPPFLAGS += -mshort-calls
188 #CPPFLAGS += -fno-unit-at-a-time
189 #CPPFLAGS += -Wstrict-prototypes
190 #CPPFLAGS += -Wunreachable-code
191 #CPPFLAGS += -Wsign-compare
192 CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst)
193 CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
194 #CPPFLAGS += $(CSTANDARD)
195  
196  
197 #---------------- Assembler Options ----------------
198 # -Wa,...: tell GCC to pass this to the assembler.
199 # -adhlns: create listing
200 # -gstabs: have the assembler create line number information; note that
201 # for use in COFF files, additional information about filenames
202 # and function names needs to be present in the assembler source
203 # files -- see avr-libc docs [FIXME: not yet described there]
204 # -listing-cont-lines: Sets the maximum number of continuation lines of hex
205 # dump that will be displayed for a given single line of source input.
206 ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
207  
208  
209 #---------------- Library Options ----------------
210 # Minimalistic printf version
211 PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
212  
213 # Floating point printf version (requires MATH_LIB = -lm below)
214 PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
215  
216 # If this is left blank, then it will use the Standard printf version.
217 #PRINTF_LIB =
218 #PRINTF_LIB = $(PRINTF_LIB_MIN)
219 PRINTF_LIB = $(PRINTF_LIB_FLOAT)
220  
221  
222 # Minimalistic scanf version
223 SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
224  
225 # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
226 SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
227  
228 # If this is left blank, then it will use the Standard scanf version.
229 SCANF_LIB =
230 #SCANF_LIB = $(SCANF_LIB_MIN)
231 #SCANF_LIB = $(SCANF_LIB_FLOAT)
232  
233  
234 MATH_LIB = -lm
235  
236  
237 # List any extra directories to look for libraries here.
238 # Each directory must be seperated by a space.
239 # Use forward slashes for directory separators.
240 # For a directory that has spaces, enclose it in quotes.
241 EXTRALIBDIRS =
242  
243  
244  
245 #---------------- External Memory Options ----------------
246  
247 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
248 # used for variables (.data/.bss) and heap (malloc()).
249 #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
250  
251 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
252 # only used for heap (malloc()).
253 #EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
254  
255 EXTMEMOPTS =
256  
257  
258  
259 #---------------- Linker Options ----------------
260 # -Wl,...: tell GCC to pass this to linker.
261 # -Map: create map file
262 # --cref: add cross reference to map file
263 LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
264 LDFLAGS += $(EXTMEMOPTS)
265 LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
266 LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
267 #LDFLAGS += -T linker_script.x
268  
269  
270  
271 #---------------- Programming Options (avrdude) ----------------
272  
273 # Programming hardware: alf avr910 avrisp bascom bsd
274 # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
275 #
276 # Type: avrdude -c ?
277 # to get a full listing.
278 #
279 #AVRDUDE_PROGRAMMER = stk200
280 AVRDUDE_PROGRAMMER = ponyser
281  
282 # com1 = serial port. Use lpt1 to connect to parallel port.
283 #AVRDUDE_PORT = lpt1
284 AVRDUDE_PORT = com1
285 # programmer connected to serial device
286  
287 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
288 #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
289  
290  
291 # Uncomment the following if you want avrdude's erase cycle counter.
292 # Note that this counter needs to be initialized first using -Yn,
293 # see avrdude manual.
294 #AVRDUDE_ERASE_COUNTER = -y
295  
296 # Uncomment the following if you do /not/ wish a verification to be
297 # performed after programming the device.
298 #AVRDUDE_NO_VERIFY = -V
299  
300 # Increase verbosity level. Please use this when submitting bug
301 # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
302 # to submit bug reports.
303 #AVRDUDE_VERBOSE = -v -v
304  
305 AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
306 AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
307 AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
308 AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
309  
310 #---------------- Programming Options (STK500) ----------------
311 # Programming hardware: stk500
312  
313 STK500 = stk500
314  
315 # Location of STK500.exe - no trailing '\'
316 STK500_PATH = C:\Program Files\Atmel\AVR Tools\STK500
317  
318 # The STK500 AVR ISP MKII is USB. The USB drivers must already be installed.
319 # Do this normally by installing AVR Studio.
320 STK500_PORT = USB
321  
322 #-erase chip -Program Flash -Verify Flash -File name -Serial programing(ISP)
323 STK500_WRITE_FLASH = -e -pf -vf -if$(TARGET).hex -ms
324 STK500_WRITE_FLASH += -s
325  
326 #Program the Fuse Bytes
327 #STK500_FLAGS = -d$(MCU) -c$(STK500_PORT) -fFF79 -FFF79
328 #Skip the Fuse Bytes
329 STK500_FLAGS = -d$(MCU) -c$(STK500_PORT)
330  
331 #-Set ISP frequency to 250kHz. Limit is 1/4 of internal osc which is default 1MHz
332 STK500_FLAGS += -I250kHz
333  
334 #---------------- Programming Options (avrdude serial bootloader) ----------------
335  
336 #"C:\arduino\hardware\tools\avr\bin\avrdude" -PCOM28 -c stk500v1 -patmega168 -b19200 -Uflash:w:Simon-PTH-v1.hex -V -F -C"C:\arduino\hardware\tools\avr\etc\avrdude.conf"
337 SERIAL_AVRDUDE = "C:\Program Files\arduino-0018\arduino-0018\hardware\tools\avr\bin\avrdude"
338 SERIAL_AVRDUDE_CONFIG = "C:\Program Files\arduino-0018\arduino-0018\hardware\tools\avr\etc\avrdude.conf"
339 SERIAL_AVRDUDE_PORT = COM6
340 SERIAL_AVRDUDE_SPEED = 57600
341 SERIAL_AVRDUDE_PROGRAMMER = stk500v1
342  
343 SERIAL_AVRDUDE_FLAGS = -p $(MCU) -P $(SERIAL_AVRDUDE_PORT) -c $(SERIAL_AVRDUDE_PROGRAMMER) -b $(SERIAL_AVRDUDE_SPEED)
344 SERIAL_AVRDUDE_FLAGS += -C$(SERIAL_AVRDUDE_CONFIG)
345 SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
346 SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
347 SERIAL_AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
348  
349 #---------------- Debugging Options ----------------
350  
351 # For simulavr only - target MCU frequency.
352 DEBUG_MFREQ = $(F_CPU)
353  
354 # Set the DEBUG_UI to either gdb or insight.
355 # DEBUG_UI = gdb
356 DEBUG_UI = insight
357  
358 # Set the debugging back-end to either avarice, simulavr.
359 DEBUG_BACKEND = avarice
360 #DEBUG_BACKEND = simulavr
361  
362 # GDB Init Filename.
363 GDBINIT_FILE = __avr_gdbinit
364  
365 # When using avarice settings for the JTAG
366 JTAG_DEV = /dev/com1
367  
368 # Debugging port used to communicate between GDB / avarice / simulavr.
369 DEBUG_PORT = 4242
370  
371 # Debugging host used to communicate between GDB / avarice / simulavr, normally
372 # just set to localhost unless doing some sort of crazy debugging when
373 # avarice is running on a different computer.
374 DEBUG_HOST = localhost
375  
376  
377  
378 #============================================================================
379  
380  
381 # Define programs and commands.
382 SHELL = sh
383 CC = avr-gcc
384 OBJCOPY = avr-objcopy
385 OBJDUMP = avr-objdump
386 SIZE = avr-size
387 AR = avr-ar rcs
388 NM = avr-nm
389 AVRDUDE = avrdude
390 REMOVE = rm -f
391 REMOVEDIR = rm -rf
392 COPY = cp
393 WINSHELL = cmd
394  
395  
396 # Define Messages
397 # English
398 MSG_ERRORS_NONE = Errors: none
399 MSG_BEGIN = -------- begin --------
400 MSG_END = -------- end --------
401 MSG_SIZE_BEFORE = Size before:
402 MSG_SIZE_AFTER = Size after:
403 MSG_COFF = Converting to AVR COFF:
404 MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
405 MSG_FLASH = Creating load file for Flash:
406 MSG_EEPROM = Creating load file for EEPROM:
407 MSG_EXTENDED_LISTING = Creating Extended Listing:
408 MSG_SYMBOL_TABLE = Creating Symbol Table:
409 MSG_LINKING = Linking:
410 MSG_COMPILING = Compiling C:
411 MSG_COMPILING_CPP = Compiling C++:
412 MSG_ASSEMBLING = Assembling:
413 MSG_CLEANING = Cleaning project:
414 MSG_CREATING_LIBRARY = Creating library:
415  
416  
417  
418  
419 # Define all object files.
420 OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
421  
422 # Define all listing files.
423 LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
424  
425  
426 # Compiler flags to generate dependency files.
427 GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
428  
429  
430 # Combine all necessary flags and optional flags.
431 # Add target processor to flags.
432 ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
433 ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS)
434 ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
435  
436  
437  
438  
439  
440 # Default target.
441 all: begin gccversion sizebefore build sizeafter end
442  
443 # Change the build target to build a HEX file or a library.
444 build: elf hex eep lss sym
445 #build: lib
446  
447  
448 elf: $(TARGET).elf
449 hex: $(TARGET).hex
450 eep: $(TARGET).eep
451 lss: $(TARGET).lss
452 sym: $(TARGET).sym
453 LIBNAME=lib$(TARGET).a
454 lib: $(LIBNAME)
455  
456  
457  
458 # Eye candy.
459 # AVR Studio 3.x does not check make's exit code but relies on
460 # the following magic strings to be generated by the compile job.
461 begin:
462 @echo
463 @echo $(MSG_BEGIN)
464  
465 end:
466 @echo $(MSG_END)
467 @echo
468  
469  
470 # Display size of file.
471 HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
472 ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf
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  
483  
484 # Display compiler version information.
485 gccversion :
486 @$(CC) --version
487  
488  
489  
490 # Program the device.
491 program: $(TARGET).hex $(TARGET).eep
492 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
493  
494 program_stk500: $(TARGET).hex $(TARGET).eep
495 $(STK500_PATH)\$(STK500) $(STK500_FLAGS) $(STK500_WRITE_FLASH)
496  
497 program_serial: $(TARGET).hex $(TARGET).eep
498 $(SERIAL_AVRDUDE) $(SERIAL_AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
499  
500 # Generate avr-gdb config/init file which does the following:
501 # define the reset signal, load the target file, connect to target, and set
502 # a breakpoint at main().
503 gdb-config:
504 @$(REMOVE) $(GDBINIT_FILE)
505 @echo define reset >> $(GDBINIT_FILE)
506 @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
507 @echo end >> $(GDBINIT_FILE)
508 @echo file $(TARGET).elf >> $(GDBINIT_FILE)
509 @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
510 ifeq ($(DEBUG_BACKEND),simulavr)
511 @echo load >> $(GDBINIT_FILE)
512 endif
513 @echo break main >> $(GDBINIT_FILE)
514  
515 debug: gdb-config $(TARGET).elf
516 ifeq ($(DEBUG_BACKEND), avarice)
517 @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
518 @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
519 $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
520 @$(WINSHELL) /c pause
521  
522 else
523 @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
524 $(DEBUG_MFREQ) --port $(DEBUG_PORT)
525 endif
526 @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
527  
528  
529  
530  
531 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
532 COFFCONVERT = $(OBJCOPY) --debugging
533 COFFCONVERT += --change-section-address .data-0x800000
534 COFFCONVERT += --change-section-address .bss-0x800000
535 COFFCONVERT += --change-section-address .noinit-0x800000
536 COFFCONVERT += --change-section-address .eeprom-0x810000
537  
538  
539  
540 coff: $(TARGET).elf
541 @echo
542 @echo $(MSG_COFF) $(TARGET).cof
543 $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
544  
545  
546 extcoff: $(TARGET).elf
547 @echo
548 @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
549 $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
550  
551  
552  
553 # Create final output files (.hex, .eep) from ELF output file.
554 %.hex: %.elf
555 @echo
556 @echo $(MSG_FLASH) $@
557 $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
558  
559 %.eep: %.elf
560 @echo
561 @echo $(MSG_EEPROM) $@
562 -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
563 --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
564  
565 # Create extended listing file from ELF output file.
566 %.lss: %.elf
567 @echo
568 @echo $(MSG_EXTENDED_LISTING) $@
569 $(OBJDUMP) -h -S $< > $@
570  
571 # Create a symbol table from ELF output file.
572 %.sym: %.elf
573 @echo
574 @echo $(MSG_SYMBOL_TABLE) $@
575 $(NM) -n $< > $@
576  
577  
578  
579 # Create library from object files.
580 .SECONDARY : $(TARGET).a
581 .PRECIOUS : $(OBJ)
582 %.a: $(OBJ)
583 @echo
584 @echo $(MSG_CREATING_LIBRARY) $@
585 $(AR) $@ $(OBJ)
586  
587  
588 # Link: create ELF output file from object files.
589 .SECONDARY : $(TARGET).elf
590 .PRECIOUS : $(OBJ)
591 %.elf: $(OBJ)
592 @echo
593 @echo $(MSG_LINKING) $@
594 $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
595  
596  
597 # Compile: create object files from C source files.
598 $(OBJDIR)/%.o : %.c
599 @echo
600 @echo $(MSG_COMPILING) $<
601 $(CC) -c $(ALL_CFLAGS) $< -o $@
602  
603  
604 # Compile: create object files from C++ source files.
605 $(OBJDIR)/%.o : %.cpp
606 @echo
607 @echo $(MSG_COMPILING_CPP) $<
608 $(CC) -c $(ALL_CPPFLAGS) $< -o $@
609  
610  
611 # Compile: create assembler files from C source files.
612 %.s : %.c
613 $(CC) -S $(ALL_CFLAGS) $< -o $@
614  
615  
616 # Compile: create assembler files from C++ source files.
617 %.s : %.cpp
618 $(CC) -S $(ALL_CPPFLAGS) $< -o $@
619  
620  
621 # Assemble: create object files from assembler source files.
622 $(OBJDIR)/%.o : %.S
623 @echo
624 @echo $(MSG_ASSEMBLING) $<
625 $(CC) -c $(ALL_ASFLAGS) $< -o $@
626  
627  
628 # Create preprocessed source for use in sending a bug report.
629 %.i : %.c
630 $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
631  
632  
633 # Target: clean project.
634 clean: begin clean_list end
635  
636 clean_list :
637 @echo
638 @echo $(MSG_CLEANING)
639 $(REMOVE) $(TARGET).hex
640 $(REMOVE) $(TARGET).eep
641 $(REMOVE) $(TARGET).cof
642 $(REMOVE) $(TARGET).elf
643 $(REMOVE) $(TARGET).map
644 $(REMOVE) $(TARGET).sym
645 $(REMOVE) $(TARGET).lss
646 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)
647 $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)
648 $(REMOVE) $(SRC:.c=.s)
649 $(REMOVE) $(SRC:.c=.d)
650 $(REMOVE) $(SRC:.c=.i)
651 $(REMOVEDIR) .dep
652  
653  
654 # Create object files directory
655 $(shell mkdir $(OBJDIR) 2>/dev/null)
656  
657  
658 # Include the dependency files.
659 -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
660  
661  
662 # Listing of phony targets.
663 .PHONY : all begin finish end sizebefore sizeafter gccversion \
664 build elf hex eep lss sym coff extcoff \
665 clean clean_list program debug gdb-config
666  
667