.PHONY: clean distclean doc test

ROOT_DIR := $(shell pwd | sed "s/\/source//g")

include $(ROOT_DIR)/config/make/tools.mk

ifeq ($(BOARD), stm32f4-discovery)
include $(ROOT_DIR)/config/make/stm32f4xx.mk
endif

OS_LIB = kosmos-$(ARCH)-$(BOARD)$(DBG_EXT)
LIBS += $(OS_LIB)

INCLUDES += \
	$(SRC_DIR)/firmware

ifeq ($(DEBUG),y)
DBG_DIR = debug
else
DBG_DIR = release
endif
OBJ_DIR := $(ROOT_DIR)/release/object/$(ARCH)/$(DBG_DIR)
EXE_DIR := $(ROOT_DIR)/release/execute/$(ARCH)/$(DBG_DIR)
MAP_DIR := $(ROOT_DIR)/release/map/$(ARCH)/$(DBG_DIR)
SIZE_DIR := $(ROOT_DIR)/release/size/$(ARCH)/$(DBG_DIR)
TEST_OBJ_DIR := $(ROOT_DIR)/test/object
TEST_EXE_DIR := $(ROOT_DIR)/test/execute/

ELF_EXT = .elf
BIN_EXT = .bin
HEX_EXT = .hex
LIB_EXT = .a
SIZE_EXT = .size
TEST_EXT =
MAP_EXT = .map

define makedep
	$(CC) -MM	\
		-MF $3	\
		-MP		\
		-MT $2	\
		$4		\
		$1
endef
