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