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

UCC git Repository :: git.ucc.asn.au