grejen är att man måste göra en makefile. Jag har gjort en som ser ut såhär
____________________________________
# Sample makefile (c) 2002-2003 Eric B. Weddington
# Released to the Public Domain
# Define directories.
DIRAVR = c:/winavr
DIRAVRBIN = $(DIRAVR)/bin
DIRAVRUTILS = $(DIRAVR)/utils/bin
DIRINC = .
DIRLIB = $(DIRAVR)/avr/lib
# Define programs.
SHELL = sh
COMPILE = avr-gcc
ASSEMBLE = avr-gcc -x assembler-with-cpp
REMOVE = rm -f
COPY = cp
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
ELFCOFF = objtool
HEXSIZE = @avr-size --target=$(FORMAT) $(TARGET).hex
ELFSIZE = @avr-size $(TARGET).elf
XSIZE = avr-sizex -l -t 5 $(TARGET).elf
FINISH = @echo Errors: none
BEGIN = @echo -------- begin --------
END = @echo -------- end --------
BUILD_INIT = @build_init.bat
BUILD_NO = @build_inc.bat
# MCU name
MCU = atmega8
# Output format. Can be [srec|ihex].
FORMAT = ihex
# Target file name (without extension).
TARGET = main
# List C source files here.
SRC = $(TARGET).c
# List Assembler source files here.
ASRC =
# Compiler flags.
CPFLAGS = -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=$(<:.c=.lst)
# Assembler flags.
ASFLAGS = -Wa,-ahlms=$(<:.s=.lst), -gstabs
# Linker flags (passed via GCC).
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
# Additional library flags (-lm = math library).
LIBFLAGS = -lm
# Define all project specific object files.
OBJ = $(SRC:.c=.o) $(ASRC:.s=.o)
# Define all listing files.
LST = $(ASRC:.s=.lst) $(SRC:.c=.lst)
# Add target processor to flags.
CPFLAGS += -mmcu=$(MCU)
ASFLAGS += -mmcu=$(MCU)
LDFLAGS += -mmcu=$(MCU)
XSIZE += --mcu=$(MCU) --flash 8192
# Default target.
.PHONY : all
all: begin build_init gccversion sizebefore $(TARGET).hex sizeafter burn finished end
# Eye candy.
.PHONY : begin
begin:
$(BEGIN)
.PHONY : finish
finished:
$(FINISH)
.PHONY : end
end:
$(END)
# Display size of file.
.PHONY : sizebefore
sizebefore:
@echo Size before:
-$(ELFSIZE)
.PHONY : sizeafter
sizeafter:
@echo Size after:
$(HEXSIZE)
.PHONY : xsize
xsize:
$(XSIZE)
.PHONY : build_init
build_init:
$(BUILD_INIT)
.PHONY : build_no
build_no:
$(BUILD_NO)
# Display compiler version information.
.PHONY : gccversion
gccversion :
$(COMPILE) --version
.PHONY : burn
burn :
avrdude -p m8 -c pony-stk200 -E noreset -U flash:w:$(TARGET).hex -U flash

$(TARGET).hex
# Create AVROBJ format file from ELF output file. (Future release)
#%.obj: %.elf
# $(OBJCOPY) -O avrobj -R .eeprom $< $@
# Create COFF format file from ELF output file.
%.cof: %.elf
$(ELFCOFF) loadelf $< mapfile $*.map writecof $@
# Create final output files (.hex, .eep) from ELF output file.
%.hex: %.elf
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
$(BUILD_NO)
%.eep: %.elf
-$(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
$(OBJDUMP) -h -S $< > $@
# Link: create ELF output file from object files.
.SECONDARY : $(TRG).elf
.PRECIOUS : $(OBJ)
%.elf: $(OBJ)
$(COMPILE) $(LDFLAGS) $(OBJ) $(LIBFLAGS) --output $@
# Compile: create object files from C source files.
%.o : %.c
$(COMPILE) -c $(CPFLAGS) -I$(DIRINC) $< -o $@
# Assemble: create object files from assembler files.
%.o : %.s
$(ASSEMBLE) -c $(ASFLAGS) -I$(DIRINC) $< -o $@
# Target: clean project.
.PHONY : clean
clean: begin clean_list finished end
.PHONY : clean_list
clean_list :
$(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)
# Automatically generate C source code dependencies. (Code taken from the GNU make user manual.)
# Note that this will work with sh (bash) and sed that is shipped with WinAVR (see the SHELL variable defined above).
# This may not work with other shells or other seds.
%.d: %.c
set -e; $(COMPILE) -MM $(CPFLAGS) $< \
| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
[ -s $@ ] || rm -f $@
include $(SRC:.c=.d)
# List assembly only source file dependencies here:
_________________________________________________________________
Jag kopierade den från ett exempel på avrfreaks.net. Sen har jag lagt till en rad som gör att programmet bränns in i avren direkt när det är kompilerat. För det använde jag avrdude, gratis att ladda hem.