]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] header vars: remove function $(am__mkdir)
authorStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 31 Jul 2012 17:03:57 +0000 (19:03 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 1 Aug 2012 08:06:06 +0000 (10:06 +0200)
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 <stefano.lattarini@gmail.com>
lib/am/header-vars.mk

index e86f5b3c3328bdc2dc2c2cc5bea0e225d7762d6c..0e0dab86836c254d8a6ce818cd8cb34ff90d6a01 100644 (file)
@@ -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.