aboutsummaryrefslogtreecommitdiff
path: root/avr-ioe.mk
blob: fb818e8ec7b3d5e9cd8addf69a5fe6ca1f3e4305 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
ifndef IOE_PREFIX
	IOE_PREFIX = .
endif

IOE_SRC = $(IOE_PREFIX)/src/spi.c \
		  $(IOE_PREFIX)/src/usart.c \
		  $(IOE_PREFIX)/src/timer.c \
		  $(IOE_PREFIX)/src/tasks.c \
		  $(IOE_PREFIX)/src/pcint.c \
		  $(IOE_PREFIX)/src/sensor_dht22.c \

IOE_OBJ = $(patsubst %.c,%.o,$(IOE_SRC))
IOE_DEP = $(patsubst %.c,%.d,$(IOE_SRC))


ifndef IOE_ONLYPATHS # Following section can be suppressed by defining this variable

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),help)
-include $(IOE_DEP)
endif
endif

ifndef F_CPU
	$(error Please define F_CPU variable in makefile before including avr-ioe.mk)
endif
ifndef MMCU
	$(error Pleade define MMCU variable in makefile before including avr-ioe.mk)
endif
IOE_CFLAGS ?= -Os -ffunction-sections -fdata-sections -fshort-enums -Wall \
			  -DF_CPU=$(F_CPU) -mmcu=$(MMCU)
IOE_GCC ?= avr-gcc

ifndef IOE_SHORTOUTPUT
$(IOE_OBJ): %.o: %.c
	$(IOE_GCC) $(IOE_CFLAGS) -c -o $@ $<

$(IOE_DEP): %.d: %.c
	$(IOE_GCC) -MM -MG -MT '$*.o $@' $(IOE_CFLAGS) -c -o $@ $<

.PHONY: ioeclean
ioeclean::
	$(RM) $(IOE_OBJ)
	$(RM) $(IOE_DEP)
else
$(IOE_OBJ): %.o: %.c
	@echo " IOE CC   $@"
	@$(IOE_GCC) $(IOE_CFLAGS) -c -o $@ $<

$(IOE_DEP): %.d: %.c
	@echo " IOE DEP  $@"
	@$(IOE_GCC) -MM -MG -MT '$*.o $@' $(IOE_CFLAGS) -c -o $@ $<

.PHONY: ioeclean
ioeclean::
	@echo " IOE CLEAN OBJ"
	@$(RM) $(IOE_OBJ)
	@echo " IOE CLEAN DEP"
	@$(RM) $(IOE_DEP)
endif

endif