]> defiant.homedns.org Git - ros_wild_thumper.git/blobdiff - avr/motor_ctrl/Makefile
avr: test i2c fixes for status = TW_NO_INFO
[ros_wild_thumper.git] / avr / motor_ctrl / Makefile
index 6160c44aa0091f6f2f071da1727c55309ef3b21b..585034ce04c7eb4a0fe1dd8258e3c3036647cb67 100644 (file)
-# Hey Emacs, this is a -*- makefile -*-\r
-#\r
-# WinAVR makefile written by Eric B. Weddington, Jörg Wunsch, et al.\r
-# Released to the Public Domain\r
-# Please read the make user manual!\r
-#\r
-# Additional material for this makefile was submitted by:\r
-#  Tim Henigan\r
-#  Peter Fleury\r
-#  Reiner Patommel\r
-#  Sander Pool\r
-#  Frederik Rouleau\r
-#  Markus Pfaff\r
-#\r
-# On command line:\r
-#\r
-# make all = Make software.\r
-#\r
-# make clean = Clean out built project files.\r
-#\r
-# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).\r
-#\r
-# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio\r
-#                4.07 or greater).\r
-#\r
-# make program = Download the hex file to the device, using avrdude.  Please\r
-#                customize the avrdude settings below first!\r
-#\r
-# make filename.s = Just compile filename.c into the assembler code only\r
-#\r
-# To rebuild project do "make clean" then "make all".\r
-#\r
-\r
-# mth 2004/09 \r
-# Differences from WinAVR 20040720 sample:\r
-# - DEPFLAGS according to Eric Weddingtion's fix (avrfreaks/gcc-forum)\r
-# - F_OSC Define in CFLAGS and AFLAGS\r
-\r
-\r
-# MCU name\r
-MCU = atmega32\r
-\r
-# Main Oscillator Frequency\r
-# This is only used to define F_OSC in all assembler and c-sources.\r
-F_OSC = 3686400\r
-\r
-# Output format. (can be srec, ihex, binary)\r
-FORMAT = ihex\r
-\r
-# Target file name (without extension).\r
-TARGET = main\r
-\r
-\r
-# List C source files here. (C dependencies are automatically generated.)\r
-SRC = $(TARGET).c uart.c\r
-\r
-\r
-# List Assembler source files here.\r
-# Make them always end in a capital .S.  Files ending in a lowercase .s\r
-# will not be considered source files but generated files (assembler\r
-# output from the compiler), and will be deleted upon "make clean"!\r
-# Even though the DOS/Win* filesystem matches both .s and .S the same,\r
-# it will preserve the spelling of the filenames, and gcc itself does\r
-# care about how the name is spelled on its command-line.\r
-ASRC = \r
-\r
-\r
-\r
-# Optimization level, can be [0, 1, 2, 3, s]. \r
-# 0 = turn off optimization. s = optimize for size.\r
-# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)\r
-OPT = s\r
-\r
-# Debugging format.\r
-# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.\r
-# AVR (extended) COFF requires stabs, plus an avr-objcopy run.\r
-DEBUG = stabs\r
-#DEBUG = dwarf-2\r
-\r
-# List any extra directories to look for include files here.\r
-#     Each directory must be seperated by a space.\r
-EXTRAINCDIRS = \r
-\r
-\r
-# Compiler flag to set the C Standard level.\r
-# c89   - "ANSI" C\r
-# gnu89 - c89 plus GCC extensions\r
-# c99   - ISO C99 standard (not yet fully implemented)\r
-# gnu99 - c99 plus GCC extensions\r
-CSTANDARD = -std=gnu99\r
-\r
-# Place -D or -U options here\r
-CDEFS = -DF_CPU=8000000\r
-\r
-# Place -I options here\r
-CINCS = -Ii2c/\r
-\r
-\r
-# Compiler flags.\r
-#  -g*:          generate debugging information\r
-#  -O*:          optimization level\r
-#  -f...:        tuning, see GCC manual and avr-libc documentation\r
-#  -Wall...:     warning level\r
-#  -Wa,...:      tell GCC to pass this to the assembler.\r
-#    -adhlns...: create assembler listing\r
-CFLAGS = -g$(DEBUG)\r
-CFLAGS += $(CDEFS) $(CINCS)\r
-CFLAGS += -O$(OPT)\r
-CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums\r
-CFLAGS += -Wall -Wstrict-prototypes\r
-CFLAGS += -Wa,-adhlns=$(<:.c=.lst)\r
-CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))\r
-CFLAGS += $(CSTANDARD)\r
-CFLAGS += -DF_OSC=$(F_OSC)\r
-\r
-\r
-\r
-# Assembler flags.\r
-#  -Wa,...:   tell GCC to pass this to the assembler.\r
-#  -ahlms:    create listing\r
-#  -gstabs:   have the assembler create line number information; note that\r
-#             for use in COFF files, additional information about filenames\r
-#             and function names needs to be present in the assembler source\r
-#             files -- see avr-libc docs [FIXME: not yet described there]\r
-ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs \r
-ASFLAGS += -DF_OSC=$(F_OSC)\r
-\r
-\r
-#Additional libraries.\r
-\r
-# Minimalistic printf version\r
-PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min\r
-\r
-# Floating point printf version (requires MATH_LIB = -lm below)\r
-PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt -lm\r
-\r
-PRINTF_LIB = \r
-\r
-# Minimalistic scanf version\r
-SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min\r
-\r
-# Floating point + %[ scanf version (requires MATH_LIB = -lm below)\r
-SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt\r
-\r
-SCANF_LIB = \r
-\r
-MATH_LIB = -lm\r
-\r
-# External memory options\r
-\r
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),\r
-# used for variables (.data/.bss) and heap (malloc()).\r
-#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff\r
-\r
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),\r
-# only used for heap (malloc()).\r
-#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff\r
-\r
-EXTMEMOPTS =\r
-\r
-# Linker flags.\r
-#  -Wl,...:     tell GCC to pass this to linker.\r
-#    -Map:      create map file\r
-#    --cref:    add cross reference to  map file\r
-LDFLAGS = -Wl,-Map=$(TARGET).map,--cref\r
-LDFLAGS += $(EXTMEMOPTS)\r
-LDFLAGS += $(PRINTF_LIB_MIN) $(SCANF_LIB) $(MATH_LIB)\r
-\r
-\r
-\r
-\r
-# Programming support using avrdude. Settings and variables.\r
-\r
-# Programming hardware: alf avr910 avrisp bascom bsd \r
-# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500\r
-#\r
-# Type: avrdude -c ?\r
-# to get a full listing.\r
-#\r
-#AVRDUDE_PROGRAMMER = avr911\r
-AVRDUDE_PROGRAMMER = avrisp2\r
-\r
-# com1 = serial port. Use lpt1 to connect to parallel port.\r
-#AVRDUDE_PORT = /dev/ttyUSB0    # programmer connected to serial device\r
-AVRDUDE_PORT = usb    # programmer connected to serial device\r
-\r
-AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex\r
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep\r
-\r
-\r
-# Uncomment the following if you want avrdude's erase cycle counter.\r
-# Note that this counter needs to be initialized first using -Yn,\r
-# see avrdude manual.\r
-#AVRDUDE_ERASE_COUNTER = -y\r
-\r
-# Uncomment the following if you do /not/ wish a verification to be\r
-# performed after programming the device.\r
-#AVRDUDE_NO_VERIFY = -V\r
-\r
-# Increase verbosity level.  Please use this when submitting bug\r
-# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> \r
-# to submit bug reports.\r
-#AVRDUDE_VERBOSE = -v -v\r
-\r
-AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)\r
-AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)\r
-AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)\r
-AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)\r
-\r
-\r
-\r
-# ---------------------------------------------------------------------------\r
-\r
-# Define directories, if needed.\r
-DIRAVR = c:/winavr\r
-DIRAVRBIN = $(DIRAVR)/bin\r
-DIRAVRUTILS = $(DIRAVR)/utils/bin\r
-DIRINC = .\r
-DIRLIB = $(DIRAVR)/avr/lib\r
-\r
-\r
-# Define programs and commands.\r
-SHELL = sh\r
-CC = avr-gcc\r
-OBJCOPY = avr-objcopy\r
-OBJDUMP = avr-objdump\r
-SIZE = avr-size\r
-NM = avr-nm\r
-AVRDUDE = avrdude\r
-REMOVE = rm -f\r
-COPY = cp\r
-\r
-\r
-\r
-\r
-# Define Messages\r
-# English\r
-MSG_ERRORS_NONE = Errors: none\r
-MSG_BEGIN = -------- begin --------\r
-MSG_END = --------  end  --------\r
-MSG_SIZE_BEFORE = Size before: \r
-MSG_SIZE_AFTER = Size after:\r
-MSG_COFF = Converting to AVR COFF:\r
-MSG_EXTENDED_COFF = Converting to AVR Extended COFF:\r
-MSG_FLASH = Creating load file for Flash:\r
-MSG_EEPROM = Creating load file for EEPROM:\r
-MSG_EXTENDED_LISTING = Creating Extended Listing:\r
-MSG_SYMBOL_TABLE = Creating Symbol Table:\r
-MSG_LINKING = Linking:\r
-MSG_COMPILING = Compiling:\r
-MSG_ASSEMBLING = Assembling:\r
-MSG_CLEANING = Cleaning project:\r
-\r
-\r
-\r
-\r
-# Define all object files.\r
-OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) \r
-\r
-# Define all listing files.\r
-LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)\r
-\r
-\r
-# Compiler flags to generate dependency files.\r
-### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d\r
-GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d\r
-\r
-# Combine all necessary flags and optional flags.\r
-# Add target processor to flags.\r
-ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)\r
-ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)\r
-\r
-\r
-\r
-\r
-\r
-# Default target.\r
-all: begin gccversion sizebefore build sizeafter finished end\r
-\r
-build: elf hex eep lss sym\r
-\r
-elf: $(TARGET).elf\r
-hex: $(TARGET).hex\r
-eep: $(TARGET).eep\r
-lss: $(TARGET).lss \r
-sym: $(TARGET).sym\r
-\r
-\r
-\r
-# Eye candy.\r
-# AVR Studio 3.x does not check make's exit code but relies on\r
-# the following magic strings to be generated by the compile job.\r
-begin:\r
-       @echo\r
-       @echo $(MSG_BEGIN)\r
-\r
-finished:\r
-       @echo $(MSG_ERRORS_NONE)\r
-\r
-end:\r
-       @echo $(MSG_END)\r
-       @echo\r
-\r
-\r
-# Display size of file.\r
-HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex\r
-ELFSIZE = $(SIZE) -A $(TARGET).elf\r
-sizebefore:\r
-       @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi\r
-\r
-sizeafter:\r
-       @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi\r
-\r
-\r
-\r
-# Display compiler version information.\r
-gccversion : \r
-       @$(CC) --version\r
-\r
-\r
-\r
-# Program the device.  \r
-program: $(TARGET).hex $(TARGET).eep\r
-       $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)\r
-\r
-\r
-\r
-\r
-# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.\r
-COFFCONVERT=$(OBJCOPY) --debugging \\r
---change-section-address .data-0x800000 \\r
---change-section-address .bss-0x800000 \\r
---change-section-address .noinit-0x800000 \\r
---change-section-address .eeprom-0x810000 \r
-\r
-\r
-coff: $(TARGET).elf\r
-       @echo\r
-       @echo $(MSG_COFF) $(TARGET).cof\r
-       $(COFFCONVERT) -O coff-avr $< $(TARGET).cof\r
-\r
-\r
-extcoff: $(TARGET).elf\r
-       @echo\r
-       @echo $(MSG_EXTENDED_COFF) $(TARGET).cof\r
-       $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof\r
-\r
-\r
-\r
-# Create final output files (.hex, .eep) from ELF output file.\r
-%.hex: %.elf\r
-       @echo\r
-       @echo $(MSG_FLASH) $@\r
-       $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@\r
-\r
-%.eep: %.elf\r
-       @echo\r
-       @echo $(MSG_EEPROM) $@\r
-       -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \\r
-       --change-section-lma .eeprom=0 -O $(FORMAT) $< $@\r
-\r
-# Create extended listing file from ELF output file.\r
-%.lss: %.elf\r
-       @echo\r
-       @echo $(MSG_EXTENDED_LISTING) $@\r
-       $(OBJDUMP) -h -S $< > $@\r
-\r
-# Create a symbol table from ELF output file.\r
-%.sym: %.elf\r
-       @echo\r
-       @echo $(MSG_SYMBOL_TABLE) $@\r
-       $(NM) -n $< > $@\r
-\r
-\r
-\r
-# Link: create ELF output file from object files.\r
-.SECONDARY : $(TARGET).elf\r
-.PRECIOUS : $(OBJ)\r
-%.elf: $(OBJ)\r
-       @echo\r
-       @echo $(MSG_LINKING) $@\r
-       $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)\r
-\r
-\r
-# Compile: create object files from C source files.\r
-%.o : %.c\r
-       @echo\r
-       @echo $(MSG_COMPILING) $<\r
-       $(CC) -c $(ALL_CFLAGS) $< -o $@ \r
-\r
-\r
-# Compile: create assembler files from C source files.\r
-%.s : %.c\r
-       $(CC) -S $(ALL_CFLAGS) $< -o $@\r
-\r
-\r
-# Assemble: create object files from assembler source files.\r
-%.o : %.S\r
-       @echo\r
-       @echo $(MSG_ASSEMBLING) $<\r
-       $(CC) -c $(ALL_ASFLAGS) $< -o $@\r
-\r
-\r
-\r
-# Target: clean project.\r
-clean: begin clean_list finished end\r
-\r
-clean_list :\r
-       @echo\r
-       @echo $(MSG_CLEANING)\r
-       $(REMOVE) $(TARGET).hex\r
-       $(REMOVE) $(TARGET).eep\r
-       $(REMOVE) $(TARGET).obj\r
-       $(REMOVE) $(TARGET).cof\r
-       $(REMOVE) $(TARGET).elf\r
-       $(REMOVE) $(TARGET).map\r
-       $(REMOVE) $(TARGET).obj\r
-       $(REMOVE) $(TARGET).a90\r
-       $(REMOVE) $(TARGET).sym\r
-       $(REMOVE) $(TARGET).lnk\r
-       $(REMOVE) $(TARGET).lss\r
-       $(REMOVE) $(OBJ)\r
-       $(REMOVE) $(LST)\r
-       $(REMOVE) $(SRC:.c=.s)\r
-       $(REMOVE) $(SRC:.c=.d)\r
-       $(REMOVE) .dep/*\r
-\r
-\r
-\r
-# Include the dependency files.\r
--include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)\r
-\r
-\r
-# Listing of phony targets.\r
-.PHONY : all begin finish end sizebefore sizeafter gccversion \\r
-build elf hex eep lss sym coff extcoff \\r
-clean clean_list program\r
-\r
+# Hey Emacs, this is a -*- makefile -*-
+#
+# WinAVR makefile written by Eric B. Weddington, Jörg Wunsch, et al.
+# Released to the Public Domain
+# Please read the make user manual!
+#
+# Additional material for this makefile was submitted by:
+#  Tim Henigan
+#  Peter Fleury
+#  Reiner Patommel
+#  Sander Pool
+#  Frederik Rouleau
+#  Markus Pfaff
+#
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
+#
+# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
+#                4.07 or greater).
+#
+# make program = Download the hex file to the device, using avrdude.  Please
+#                customize the avrdude settings below first!
+#
+# make filename.s = Just compile filename.c into the assembler code only
+#
+# To rebuild project do "make clean" then "make all".
+#
+
+# mth 2004/09
+# Differences from WinAVR 20040720 sample:
+# - DEPFLAGS according to Eric Weddingtion's fix (avrfreaks/gcc-forum)
+# - F_OSC Define in CFLAGS and AFLAGS
+
+
+# MCU name
+MCU = atmega32
+
+# Main Oscillator Frequency
+# This is only used to define F_OSC in all assembler and c-sources.
+F_OSC = 3686400
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# Target file name (without extension).
+TARGET = main
+
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(TARGET).c uart.c
+
+
+# List Assembler source files here.
+# Make them always end in a capital .S.  Files ending in a lowercase .s
+# will not be considered source files but generated files (assembler
+# output from the compiler), and will be deleted upon "make clean"!
+# Even though the DOS/Win* filesystem matches both .s and .S the same,
+# it will preserve the spelling of the filenames, and gcc itself does
+# care about how the name is spelled on its command-line.
+ASRC =
+
+
+
+# Optimization level, can be [0, 1, 2, 3, s].
+# 0 = turn off optimization. s = optimize for size.
+# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Debugging format.
+# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
+# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
+DEBUG = stabs
+#DEBUG = dwarf-2
+
+# List any extra directories to look for include files here.
+#     Each directory must be seperated by a space.
+EXTRAINCDIRS =
+
+
+# Compiler flag to set the C Standard level.
+# c89   - "ANSI" C
+# gnu89 - c89 plus GCC extensions
+# c99   - ISO C99 standard (not yet fully implemented)
+# gnu99 - c99 plus GCC extensions
+CSTANDARD = -std=gnu99
+
+# Place -D or -U options here
+CDEFS = -DF_CPU=5000000
+
+# Place -I options here
+CINCS = -Ii2c/
+
+
+# Compiler flags.
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CFLAGS = -g$(DEBUG)
+CFLAGS += $(CDEFS) $(CINCS)
+CFLAGS += -O$(OPT)
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+CFLAGS += -Wall -Wstrict-prototypes
+CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
+CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
+CFLAGS += $(CSTANDARD)
+CFLAGS += -DF_OSC=$(F_OSC)
+
+
+
+# Assembler flags.
+#  -Wa,...:   tell GCC to pass this to the assembler.
+#  -ahlms:    create listing
+#  -gstabs:   have the assembler create line number information; note that
+#             for use in COFF files, additional information about filenames
+#             and function names needs to be present in the assembler source
+#             files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+ASFLAGS += -DF_OSC=$(F_OSC)
+
+
+#Additional libraries.
+
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt -lm
+
+PRINTF_LIB =
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+SCANF_LIB =
+
+MATH_LIB = -lm
+
+# External memory options
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+# Linker flags.
+#  -Wl,...:     tell GCC to pass this to linker.
+#    -Map:      create map file
+#    --cref:    add cross reference to  map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += $(EXTMEMOPTS)
+LDFLAGS += $(PRINTF_LIB_MIN) $(SCANF_LIB) $(MATH_LIB)
+
+
+
+
+# Programming support using avrdude. Settings and variables.
+
+# Programming hardware: alf avr910 avrisp bascom bsd
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+#
+#AVRDUDE_PROGRAMMER = avr911
+AVRDUDE_PROGRAMMER = avrisp2
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+#AVRDUDE_PORT = /dev/ttyUSB0    # programmer connected to serial device
+AVRDUDE_PORT = usb    # programmer connected to serial device
+
+AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+
+
+# ---------------------------------------------------------------------------
+
+# Define directories, if needed.
+DIRAVR = c:/winavr
+DIRAVRBIN = $(DIRAVR)/bin
+DIRAVRUTILS = $(DIRAVR)/utils/bin
+DIRINC = .
+DIRLIB = $(DIRAVR)/avr/lib
+
+
+# Define programs and commands.
+SHELL = sh
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+AVRDUDE = avrdude
+REMOVE = rm -f
+COPY = cp
+
+
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = --------  end  --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
+
+
+# Compiler flags to generate dependency files.
+### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+
+
+# Default target.
+all: begin gccversion sizebefore build sizeafter finished end
+
+build: elf hex eep lss sym
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+eep: $(TARGET).eep
+lss: $(TARGET).lss
+sym: $(TARGET).sym
+
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+       @echo
+       @echo $(MSG_BEGIN)
+
+finished:
+       @echo $(MSG_ERRORS_NONE)
+
+end:
+       @echo $(MSG_END)
+       @echo
+
+
+# Display size of file.
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+sizebefore:
+       @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
+
+sizeafter:
+       @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
+
+
+
+# Display compiler version information.
+gccversion:
+       @$(CC) --version
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+       #$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+       ../../scripts/pyshared/bootloader.py -b -j 0x50 $(TARGET).hex
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+       @echo
+       @echo $(MSG_COFF) $(TARGET).cof
+       $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+       @echo
+       @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+       $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+       @echo
+       @echo $(MSG_FLASH) $@
+       $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+       @echo
+       @echo $(MSG_EEPROM) $@
+       -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+       --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+       @echo
+       @echo $(MSG_EXTENDED_LISTING) $@
+       $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+       @echo
+       @echo $(MSG_SYMBOL_TABLE) $@
+       $(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+       @echo
+       @echo $(MSG_LINKING) $@
+       $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+       @echo
+       @echo $(MSG_COMPILING) $<
+       $(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+       $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+       @echo
+       @echo $(MSG_ASSEMBLING) $<
+       $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+
+
+# Target: clean project.
+clean: begin clean_list finished end
+
+clean_list :
+       @echo
+       @echo $(MSG_CLEANING)
+       $(REMOVE) $(TARGET).hex
+       $(REMOVE) $(TARGET).eep
+       $(REMOVE) $(TARGET).obj
+       $(REMOVE) $(TARGET).cof
+       $(REMOVE) $(TARGET).elf
+       $(REMOVE) $(TARGET).map
+       $(REMOVE) $(TARGET).obj
+       $(REMOVE) $(TARGET).a90
+       $(REMOVE) $(TARGET).sym
+       $(REMOVE) $(TARGET).lnk
+       $(REMOVE) $(TARGET).lss
+       $(REMOVE) $(OBJ)
+       $(REMOVE) $(LST)
+       $(REMOVE) $(SRC:.c=.s)
+       $(REMOVE) $(SRC:.c=.d)
+       $(REMOVE) .dep/*
+
+
+
+# Include the dependency files.
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program
+