diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-05-17 11:40:49 +0200 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-05-21 16:16:14 +0200 |
commit | 9ccf085a8d0ada7ce5096360dfa76cd7a792afab (patch) | |
tree | 2586785802712a85b49376ac79d4aac2fab3733f /t/spy-wildcard.sh | |
parent | 8d899acbab58dd806deda03862d64cbafff2cb6a (diff) | |
download | automake-9ccf085a8d0ada7ce5096360dfa76cd7a792afab.tar.gz |
[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>
Diffstat (limited to 't/spy-wildcard.sh')
-rwxr-xr-x | t/spy-wildcard.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/t/spy-wildcard.sh b/t/spy-wildcard.sh new file mode 100755 index 000000000..83ebde78d --- /dev/null +++ b/t/spy-wildcard.sh @@ -0,0 +1,36 @@ +#! /bin/sh +# Copyright (C) 2012 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Check that the behaviour of the $(wildcard) builtin in corner cases +# matches the assumptions done in our recipes. + +. ./defs || Exit 1 + +mkdir dir +echo dummy > file + +cat > Makefile <<'END' +.PHONY: test +test: + test x'$(wildcard dir)' = x'dir' + test x'$(wildcard file)' = x'file' + test x'$(wildcard dir/)' = x'dir/' + test x'$(wildcard file/.)' = x'' +END + +$MAKE test + +: |