+define TargetSource_Template
+$(1): $(2)
+ @echo "[cc]: $(1) <-- $(2)"
+ @mkdir -p $(dir $(1))
+ @$(CC) $(CFLAGS_A) $(addprefix -I./,$(3)) $(addprefix -D, $(4)) -c -o $(1) $(2)
+endef
+
+
+
+define TargetSourceList_Template
+$(1): $(2)
+ @echo "[cc]: $(1) <-- $(2)"
+ @mkdir -p $(dir $(1))
+ @$(CC) $(CFLAGS_A) $(addprefix -I./,$(3)) $(addprefix -D, $(4)) $(LIST_OPT) -c -o /dev/null $(2) > $(1)
+endef
+
+# ----------------------------------------------------------------------------
+# Function: find_source_file
+# Arguments: 1: name of the binary file (.o extension) to search
+# 2: list of directorys to search for file
+# Returns: Returns paths to source file (mathing the pattern in
+# $(SOURCE_PATTERN)
+# ----------------------------------------------------------------------------
+SOURCE_PATTERN := %.S %.c
+find_source_file = $(firstword $(foreach d, $(2), \
+ $(filter $(SOURCE_PATTERN), \
+ $(wildcard $(d)$(notdir $(patsubst %.o,%,$1)).*) \
+ ) \
+ ) )
+
+
+$(foreach a, $(ALGORITHMS), \
+ $(foreach b, $($(a)_OBJ), \
+ $(eval $(call TargetSource_Template, \
+ $(BIN_DIR)$(call lc, $(a))/$(b), \
+ $(call find_source_file, $(b), $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR) ),\
+ $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR), \
+ $($(a)_DEF), \
+ )) \
+ ) \
+)
+
+$(foreach a, $(ALGORITHMS), \
+ $(foreach b, $($(a)_TESTBIN), \
+ $(eval $(call TargetSource_Template, \
+ $(BIN_DIR)$(call lc, $(a))/$(TEST_DIR)$(b), \
+ $(call find_source_file, $(b), $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR) ),\
+ $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR), \
+ $($(a)_DEF) \
+ )) \
+ ) \
+)
+
+
+$(foreach a, $(ALGORITHMS), \
+ $(foreach b, $($(a)_OBJ), \
+ $(eval $(call TargetSourceList_Template, \
+ $(LIST_DIR)$(call lc, $(a))/$(patsubst %.o,%.s,$(b)), \
+ $(call find_source_file, $(b), $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR) ),\
+ $($(a)_DIR) $($(a)_INCDIR) $(GLOBAL_INCDIR), \
+ $($(a)_DEF), \
+ )) \
+ ) \
+)
+
+#-------------------------------------------------------------------------------
+
+define MainTestElf_Template
+$(1): $(2) $(3)
+ @mkdir -p $(dir $(1))
+ @echo "[ld]: $(1)"
+ @$(CC) $(CFLAGS_A) $(LDFLAGS)$(patsubst %.elf,%.map,$(1)) -o \
+ $(1) \
+ $(2) $(3) \