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