]> git.ipfire.org Git - thirdparty/automake.git/commit
[ng] dirstamp: remove, use inlined parent directory creation instead
authorStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 17 May 2012 09:40:49 +0000 (11:40 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 21 May 2012 14:16:14 +0000 (16:16 +0200)
commit9ccf085a8d0ada7ce5096360dfa76cd7a792afab
tree2586785802712a85b49376ac79d4aac2fab3733f
parent8d899acbab58dd806deda03862d64cbafff2cb6a
[ng] dirstamp: remove, use inlined parent directory creation instead

Since GNU make offers an efficient and simple way to refer to the directory
component of a target within its recipe (through the use of the automatic
variable "$(@D)"), and ways to avoid launching a "sub-recipe" to create
a directory if that directory already exists (through a careful the use
of the $(wildcard) builtin), we can simplify the automake pre-processing
a little by getting rid of dirstamp files creation, instead inlining the
creation of any required parent directory for a target into the recipe of
the target itself.

As a first step, instead of emitting rules like:

    sub/foo.o: sub/foo.c sub/.dirstamp
        $(CC) $(CFLAGS) sub/foo.c
    sub/.dirstamp:
        mkdir sub && touch sub/.dirstamp

we might simply emit rules like:

    sub/foo.o: sub/foo.c
        $(MKDIR_P) $(@D)
        $(CC) $(CFLAGS) sub/foo.c

But the above would be quite wasteful if we really called $(MKDIR_P) for
every created object file, since the directory $(@D) will likely already
exist (in an in-tree build, it will exist unconditionally and beforehand,
and in a VPATH build will exists after the first object file in it has
been created).

So, as hinted above, we employ few optimizations to try to avoid such
extra forks when they are not really required, thus keeping most of
the performance gains offered by dirstamp files, but without the added
pre-processing complexity.

* automake.in (preprocess_file): Add a transform for '%SILENT%', as
returned by the 'silent_flag()' subroutine.
(output_texinfo_build_rules, handle_languages, handle_programs,
handle_libraries): Drop explicit '%SILENT%' transforms for single
'.am' files as a result.
(%directory_map): Delete this global variable.
(initialize_per_input): Do not reset it.
(handle_single_transform): Don't create dependency of subdir objects
on the corresponding dirstamp file.
(handle_programs, handle_libraries): Likewise, but for subdir programs
and libraries.  And drop the '%DIRSTAMP%' transform when processing the
relevant '.am' fragment.
(output_texinfo_build_rules): Don't handle nor return a dirstamp.
(handle_texinfo_helper): Adjust, and drop the '%DIRSTAMP%' transform
when processing the relevant .am fragment.
(require_build_directory, require_build_directory_maybe): Delete.
* lib/am/header-vars.am (am__ensure_dir_exists, am__mkdir): New private
make function, used to create a directory with "maximal" possible
efficiency, especially trying to avoid extra forks when possible.
* t/ensure-dir-exists.sh: New test, checking the behaviour of the new
$(am__mkdir) function.
* t/spy-wildcard.sh: New "spy" test, verifying that the $(wildcard)
GNU make builtin really has the behaviour the $(am__ensure_dir_exists)
expects.
* t/subobj-libtool.sh: New test (subdir objects with libtool).
* t/subobj.sh: Adjust and enhance.
* t/subobj6.sh: Remove as obsolete.

* lib/am/library.am: Adjust to create required targets parent directories
with the help of $(am__ensure_dir_exists) rather than of dirstamp files,
once provided by the now-removed '%DIRSTAMP%' transforms.
* lib/am/ltlibrary.am: Likewise.
* lib/am/program.am: Likewise.
* lib/am/texi-vers.am: Likewise.
* lib/am/texibuild.am: Likewise.
* lib/am/depend2.am: Likewise.  Also ...
(am__ensure_depdir): Rewrite to using $(am__ensure_dir_exists).

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
13 files changed:
automake.in
lib/am/depend2.am
lib/am/header-vars.am
lib/am/library.am
lib/am/ltlibrary.am
lib/am/program.am
lib/am/texi-vers.am
lib/am/texibuild.am
t/ensure-dir-exists.sh [new file with mode: 0755]
t/spy-wildcard.sh [new file with mode: 0755]
t/subobj-libtool.sh [new file with mode: 0755]
t/subobj.sh
t/subobj6.sh [deleted file]