diff options
Diffstat (limited to 'avr-ioe.mk')
-rw-r--r-- | avr-ioe.mk | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/avr-ioe.mk b/avr-ioe.mk new file mode 100644 index 0000000..1248f11 --- /dev/null +++ b/avr-ioe.mk @@ -0,0 +1,47 @@ +ifndef IOE_PREFIX + IOE_PREFIX = . +endif + +IOE_SRC_SPI = $(IOE_PREFIX)/src/spi.c +IOE_SRC_USART = $(IOE_PREFIX)/src/usart.c +IOE_SRC = $(IOE_SRC_SPI) $(IOE_SRC_USART) + +IOE_OBJ_SPI = $(patsubst %.c,%.o,$(IOE_SRC_SPI)) +IOE_OBJ_USART = $(patsubst %.c,%.o,$(IOE_SRC_USART)) +IOE_OBJ = $(patsubst %.c,%.o,$(IOE_SRC)) + +IOE_DEP_SPI = $(patsubst %.c,%.d,$(IOE_SRC_SPI)) +IOE_DEP_USART = $(patsubst %.c,%.d,$(IOE_SRC_USART)) +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 +IOE_CFLAGS += -DF_CPU=$(F_CPU) -mmcu=$(MMCU) +IOE_GCC ?= avr-gcc + +$(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) + +endif |