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