Rev 2108 Rev 2293
1 PRG = scope 1 PRG = scope
2 OBJ = main.o ./libs/usart.o ./libs/spi.o 2 OBJ = main.o ./libs/usart.o ./libs/spi.o
3 MCU_TARGET = atmega8 3 MCU_TARGET = atmega8
4 AVRDUDE_PART = m8 4 AVRDUDE_PART = m8
5   5  
6 OPTIMIZE = -O1 6 OPTIMIZE = -O1
7 # OPTIMIZE = -Os 7 # OPTIMIZE = -Os
8   8  
9 CC = avr-gcc 9 CC = avr-gcc
10 override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) 10 override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
11 OBJCOPY = avr-objcopy 11 OBJCOPY = avr-objcopy
12 OBJDUMP = avr-objdump 12 OBJDUMP = avr-objdump
13   13  
14 all: hex 14 all: hex
15   15  
16 ./libs/spi.o: ./libs/spi.h 16 ./libs/spi.o: ./libs/spi.h
17 ./libs/usart.o: ./libs/usart.h 17 ./libs/usart.o: ./libs/usart.h
18 #./libs/timer.o: ./libs/timer.h 18 #./libs/timer.o: ./libs/timer.h
19   19  
20 hex: $(PRG).hex 20 hex: $(PRG).hex
21   21  
22 %.hex: %.elf 22 %.hex: %.elf
23 $(OBJCOPY) -j .text -j .data -O ihex $< $@ 23 $(OBJCOPY) -j .text -j .data -O ihex $< $@
24   24  
25 $(PRG).elf: $(OBJ) 25 $(PRG).elf: $(OBJ)
26 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) 26 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
27   27  
28 load: $(PRG).hex 28 load: $(PRG).hex
29 avrdude -p $(AVRDUDE_PART) -c stk500v2 -P /dev/ttyUSB1 -B 2 -U flash:w:$< 29 avrdude -p $(AVRDUDE_PART) -c stk500v2 -P /dev/ttyUSB0 -B 2 -U flash:w:$<
30   30  
31 clean: 31 clean:
32 rm -rf *.o $(PRG).elf $(PRG).hex ./libs/*.o 32 rm -rf *.o $(PRG).elf $(PRG).hex ./libs/*.o
33   33