PRG = fluxgate
OBJ = main.o ./libs/usart.o ./libs/spi.o ./libs/mcp4922.o
MCU_TARGET = atmega8
AVRDUDE_PART = m8
# OPTIMIZE = -O1
OPTIMIZE = -Os
CC = avr-gcc
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
all: hex
#./libs/adc.o: ./libs/adc.h
./libs/spi.o: ./libs/spi.h
./libs/usart.o: ./libs/usart.h
./libs/mcp4922.o: ./libs/mcp4922.h
#./libs/timer.o: ./libs/timer.h
hex: $(PRG).hex
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
$(PRG).elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
load: $(PRG).hex
avrdude -p $(AVRDUDE_PART) -c stk500v2 -P /dev/ttyUSB1 -B 1 -U flash:w:$<
clean:
rm -rf *.o $(PRG).elf $(PRG).hex ./libs/*.o