summaryrefslogtreecommitdiff
path: root/lib/am/library.am
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2012-05-17 11:40:49 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2012-05-21 16:16:14 +0200
commit9ccf085a8d0ada7ce5096360dfa76cd7a792afab (patch)
tree2586785802712a85b49376ac79d4aac2fab3733f /lib/am/library.am
parent8d899acbab58dd806deda03862d64cbafff2cb6a (diff)
downloadautomake-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 'lib/am/library.am')
-rw-r--r--lib/am/library.am10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/am/library.am b/lib/am/library.am
index 686b648ed..0d5ac9e70 100644
--- a/lib/am/library.am
+++ b/lib/am/library.am
@@ -13,7 +13,9 @@
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
-%LIBRARY%: $(%XLIBRARY%_OBJECTS) $(%XLIBRARY%_DEPENDENCIES) $(EXTRA_%XLIBRARY%_DEPENDENCIES) %DIRSTAMP%
- %SILENT%-rm -f %LIBRARY%
- %VERBOSE%$(%XLIBRARY%_AR) %LIBRARY% $(%XLIBRARY%_OBJECTS) $(%XLIBRARY%_LIBADD)
- %SILENT%$(RANLIB) %LIBRARY%
+%LIBRARY%: $(%XLIBRARY%_OBJECTS) $(%XLIBRARY%_DEPENDENCIES) \
+ $(EXTRA_%XLIBRARY%_DEPENDENCIES)
+ %SILENT%rm -f $@
+ %SILENT%$(am__ensure_target_dir_exists)
+ %VERBOSE%$(%XLIBRARY%_AR) $@ $(%XLIBRARY%_OBJECTS) $(%XLIBRARY%_LIBADD)
+ %SILENT%$(RANLIB) $@