From: Stefano Lattarini Date: Tue, 31 Jul 2012 17:03:57 +0000 (+0200) Subject: [ng] header vars: remove function $(am__mkdir) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5cd47293bb33b793f36a288a9bb90091b906850f;p=thirdparty%2Fautomake.git [ng] header vars: remove function $(am__mkdir) That function expanded unconditionally to: test -d $1 || $(MKDIR_P) $1 This formulation was supposed to help avoiding extra forks (due to the leading "test -d" check), but it didn't actually do so. In fact, in the situations '$(am__mkdir)' was most used (typically indirectly, through other private variables like '$(am__ensure_target_dir_exists)') the Makefile had already determined by other means (e.g., tricky uses of the '$(wildcard)' built-in) that the relevant directory didn't exist and thus *had* to be created, so the fork of $(MKDIR_P) has to happen anyway. In fact, the use of '$(am__mkdir)' often ended up causing *more forks*, because it eventually expanded to recipes like: target: recipe test -d non-existent || $(MKDIR_P) non-existent ... rest of the recipe ... forcing make to spawn a shell to execute the first line of the recipe -- which, containing the shell metacharacters "||", couldn't be spawned directly -- shell which in turn had to spawn $(MKDIR_P). Whereas with a simpler target: recipe $(MKDIR_P) non-existent ... rest of the recipe ... make would span $(MKDIR_P) directly itself, thus saving a shell execution -- and speeding up the recipe. * lib/am/header-vars.mk (am__mkdir): Remove. (am__ensure_dir_exists): Simply use $(MKDIR_P) directly. Signed-off-by: Stefano Lattarini --- diff --git a/lib/am/header-vars.mk b/lib/am/header-vars.mk index e86f5b3c3..0e0dab868 100644 --- a/lib/am/header-vars.mk +++ b/lib/am/header-vars.mk @@ -119,8 +119,6 @@ unexport CDPATH # FIXME: maybe normalize/sanitize $(V)? V ?= 0 -am__mkdir = test -d $1 || $(MKDIR_P) $1 - # In a recipe, ensure the given directory exists, creating it if # necessary; but tries to do so avoiding useless forks, stats, and # extra recipe text (the latter is useful when doing "make V=1"). @@ -130,7 +128,7 @@ am__mkdir = test -d $1 || $(MKDIR_P) $1 # usage patterns, one of them should always be true in non-VPATH # builds. am__ensure_dir_exists = \ - $(if $(filter .,$1),:,$(if $(wildcard $1/),:,$(call am__mkdir,$1))) + $(if $(filter .,$1),:,$(if $(wildcard $1/),:,$(MKDIR_P) $1)) # Ensure the directory containing the target of the current recipe # exists, by creating it if necessary.