Rev Author Line No. Line
1110 kaklik 1  
2 NAME := sd-reader
3 HEX := $(NAME).hex
4 OUT := $(NAME).out
5 MAP := $(NAME).map
6 SOURCES := $(wildcard *.c)
7 HEADERS := $(wildcard *.h)
8 OBJECTS := $(patsubst %.c,%.o,$(SOURCES))
9  
10 MCU := atmega168
11 MCU_AVRDUDE := m168
12 MCU_FREQ := 16000000UL
13  
14 CC := avr-gcc
15 OBJCOPY := avr-objcopy
16 SIZE := avr-size -A
17 DOXYGEN := doxygen
18  
19 CFLAGS := -Wall -pedantic -mmcu=$(MCU) -std=c99 -g -Os -DF_CPU=$(MCU_FREQ)
20  
21 all: $(HEX)
22  
23 clean:
24 rm -f $(HEX) $(OUT) $(MAP) $(OBJECTS)
25 rm -rf doc/html
26  
27 flash: $(HEX)
28 avrdude -y -p $(MCU_AVRDUDE) -U flash:w:$(HEX)
29  
30 $(HEX): $(OUT)
31 $(OBJCOPY) -R .eeprom -O ihex $< $@
32  
33 $(OUT): $(OBJECTS)
34 $(CC) $(CFLAGS) -o $@ -Wl,-Map,$(MAP) $^
35 @echo
36 @$(SIZE) $@
37 @echo
38  
39 %.o: %.c $(HEADERS)
40 $(CC) $(CFLAGS) -c -o $@ $<
41  
42 %.pp: %.c
43 $(CC) $(CFLAGS) -E -o $@ $<
44  
45 %.ppo: %.c
46 $(CC) $(CFLAGS) -E $<
47  
48 doc: $(HEADERS) $(SOURCES) Doxyfile
49 $(DOXYGEN) Doxyfile
50  
51 .PHONY: all clean flash doc
52