Bug 784848 - sync autotargets.mk from m-c - rs=Callek
authorChris Cooper <ccooper@deadsquid.com>
Wed, 06 Mar 2013 17:42:44 -0500
changeset 15092 d98a87973d357722387c0644a2ca041c3394994b
parent 15091 70b7a4895fb3b8db33333b5d72c5d9e5f6dc5a30
child 15093 835221125bebb7332d0a5775fbb422c66750a040
push id898
push userbugzilla@standard8.plus.com
push dateMon, 13 May 2013 17:03:31 +0000
treeherdercomm-beta@3106694b14de [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCallek
bugs784848
Bug 784848 - sync autotargets.mk from m-c - rs=Callek
config/makefiles/autotargets.mk
--- a/config/makefiles/autotargets.mk
+++ b/config/makefiles/autotargets.mk
@@ -43,18 +43,27 @@ slash_strip = \
     $(subst <--[**]-->,$(space),\
 	$(call _slashSqueeze,\
     $(subst $(space),<--[**]-->,$(1))\
   )))
 
 # Extract directory path from a dependency file.
 mkdir_stem =$(foreach val,$(getargv),$(subst /.mkdir.done,$(NULL),$(val)))
 
+# Function can be called by other functions to expand un-expanded make vars.
+# := functionality in call(able) function form
+expand = $(eval func-expand-$(1) := $($(1)))$(func-expand-$(1))
+
 ## Generate timestamp file for threadsafe directory creation
-mkdir_deps =$(foreach dir,$(getargv),$(call slash_strip,$(dir)/.mkdir.done))
+mkdir_deps = \
+  $(strip \
+  $(foreach var,$(getargv),\
+  $(foreach dir,$(call expand,var),\
+  $(call slash_strip,$(call expand,dir)/.mkdir.done) \
+  )))
 
 #######################
 ##---]  TARGETS  [---##
 #######################
 
 %/.mkdir.done: # mkdir -p -p => mkdir -p
 	$(subst $(space)-p,$(null),$(MKDIR)) -p "$(dir $@)"
 # Make the timestamp old enough for not being a problem with symbolic links
@@ -68,27 +77,29 @@ mkdir_deps =$(foreach dir,$(getargv),$(c
 .mkdir.done:
 	@echo "WARNING: $(MKDIR) -dot- requested by $(MAKE) -C $(CURDIR) $(MAKECMDGOALS)"
 	@$(TOUCH) -t 198001030000 "$@"
 
 INCLUDED_AUTOTARGETS_MK = 1
 endif #}
 
 
-## Accumulate deps and cleanup
-ifneq (,$(GENERATED_DIRS))
-  GENERATED_DIRS := $(strip $(sort $(GENERATED_DIRS)))
-  tmpauto :=$(call mkdir_deps,GENERATED_DIRS)
-  GENERATED_DIRS_DEPS +=$(tmpauto)
-  GARBAGE_DIRS        +=$(GENERATED_DIRS)
-endif
+###########################################################################
+## GENERATED_DIR(_\S+)? directory deps
+## GENERATED_DIRS_{export,lib,tools} = foo   # target specific deps
+###########################################################################
+GENERATED_DIRS += $(foreach tgt,$(MAKECMDGOALS),$(value GENERATED_DIRS_$(tgt)))
+GENERATED_DIRS := $(call expand,GENERATED_DIRS)
+GENERATED_DIRS := $(strip $(sort $(GENERATED_DIRS)))
+GARBAGE_DIRS   += $(GENERATED_DIRS)
+
+# directory deps are timestamp based to only create when needed
+AUTO_DEPS += $(if $(value GENERATED_DIRS),$(call mkdir_deps,GENERATED_DIRS))
 
 #################################################################
 # One ring/dep to rule them all:
 #   config/rules.mk::all target is available by default
 #   Add $(AUTO_DEPS) as an explicit target dependency when needed.
 #################################################################
-
-AUTO_DEPS +=$(GENERATED_DIRS_DEPS)
 AUTO_DEPS := $(strip $(sort $(AUTO_DEPS)))
 
 # Complain loudly if deps have not loaded so getargv != $(NULL)
 $(call requiredfunction,getargv)