From e13dc1d5eef200d13d8f3ecb4b3edfd779c81f67 Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Fri, 10 Feb 2012 10:57:37 -0500 Subject: [PATCH] Provide a way to add additional TARGET search directories. E.g. in a makefile do: TARGETDIRS += ../targets This will search for targets in ../targets as well as $(CONTIKI)/platforms A error will occur if more than one targets with the same name are found. --- Makefile.include | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile.include b/Makefile.include index 710725806..ceccb9c7b 100644 --- a/Makefile.include +++ b/Makefile.include @@ -107,7 +107,7 @@ endif ### Include target makefile (TODO Unsafe?) -target_makefile := $(wildcard $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET)) +target_makefile := $(wildcard ${realpath $(CONTIKI)}/platform/$(TARGET)/Makefile.$(TARGET) ${foreach TDIR, $(TARGETDIRS), $(TDIR)/$(TARGET)/Makefile.$(TARGET)}) # Check if the target makefile exists, and create the object directory if necessary. ifeq ($(strip $(target_makefile)),) @@ -116,7 +116,10 @@ else ifeq (${wildcard $(OBJECTDIR)},) DUMMY := ${shell mkdir $(OBJECTDIR)} endif - include $(CONTIKI)/platform/$(TARGET)/Makefile.$(TARGET) + ifneq (1, ${words $(target_makefile)}) + ${error More than one TARGET Makefile found: $(target_makefile)} + endif + include $(target_makefile) endif ### Forward comma-separated list of arbitrary defines to the compiler @@ -126,13 +129,13 @@ CFLAGS += ${addprefix -D,${subst $(COMMA), ,$(DEFINES)}} ### Setup directory search path for source and header files -CONTIKI_TARGET_DIRS_CONCAT = ${addprefix $(CONTIKI)/platform/$(TARGET)/, \ +CONTIKI_TARGET_DIRS_CONCAT = ${addprefix ${dir $(target_makefile)}, \ $(CONTIKI_TARGET_DIRS)} CONTIKI_CPU_DIRS_CONCAT = ${addprefix $(CONTIKI_CPU)/, \ $(CONTIKI_CPU_DIRS)} SOURCEDIRS = . $(PROJECTDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) \ - $(CONTIKI_CPU_DIRS_CONCAT) $(CONTIKIDIRS) $(APPDIRS) + $(CONTIKI_CPU_DIRS_CONCAT) $(CONTIKIDIRS) $(APPDIRS) ${dir $(target_makefile)} vpath %.c $(SOURCEDIRS) vpath %.S $(SOURCEDIRS)