Pliki dla programistów ATMEG

# avr-gcc makefile

# Typ AVRa
MMCU = atmega8

# CzÄ?stotliwoĹ?Ä? zegara
F_CPU = 1000000

# Typ programatora
PROGRAMMER = stk500v2
PROGRAMMER_PORT = /dev/ttyUSB0

# Nazwa wynikowego pliku hex
PROJECT = test

# Pliki ĹşrĂłdĹ?owe
SOURCES = test.c

CC = avr-gcc
OBJCOPY = avr-objcopy

CDEFS = -DF_CPU=$(F_CPU)UL

CFLAGS = $(CDEFS)
CFLAGS += -mmcu=$(MMCU) -g -Os -Wall

OBJECTS = $(SOURCES:.c=.o)

$(PROJECT).hex: $(PROJECT).out
$(OBJCOPY) -O ihex -R .eeprom $(PROJECT).out $(PROJECT).hex

$(PROJECT).out:  $(OBJECTS)
$(CC)  $(CFLAGS) $^ -o $@ -lm

$.o:%.c
$(CC) $(CFLAGS) $< -o $@

program_flash: $(PROJECT).hex
avrdude -c $(PROGRAMMER) -p $(MMCU) -P $(PROGRAMMER_PORT) -U flash:w:$(PROJECT).hex

clean:
rm -f $(OBJECTS)
rm -f $(PROJECT).out
rm -f $(PROJECT).hex

.PHONY: clean program_flash