From 421f8ddaa572a813bee5169c33b277b5325fae93 Mon Sep 17 00:00:00 2001
From: Angus Gratton <gus@projectgus.com>
Date: Tue, 8 Sep 2015 10:36:19 +1000
Subject: [PATCH] Allow properly for out-of-tree components (was a hack before)

---
 common.mk | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/common.mk b/common.mk
index b143653..f1d6477 100644
--- a/common.mk
+++ b/common.mk
@@ -307,8 +307,15 @@ PROGRAM_MAKEFILE = $(firstword $(MAKEFILE_LIST))
 $(eval $(call component_compile_rules,PROGRAM))
 
 ## Include other components (this is where the actual compiler sections are generated)
-$(foreach component,$(COMPONENTS), $(eval include $(ROOT)$(component)/component.mk))
-
+##
+## if component directory exists relative to $(ROOT), use that.
+## otherwise try to resolve it as an absolute path
+$(foreach component,$(COMPONENTS), 					\
+	$(if $(wildcard $(ROOT)$(component)),				\
+		$(eval include $(ROOT)$(component)/component.mk), 	\
+		$(eval include $(component)/component.mk)		\
+	)								\
+)
 
 ## Run linker scripts via C preprocessor to evaluate macros
 $(LD_DIR)%.ld: $(ROOT)ld/%.ld | $(LD_DIR)