automake-ng
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Automake-NG] [PATCH] [ng] dirstamp: remove, use inlined parent dire


From: Stefano Lattarini
Subject: Re: [Automake-NG] [PATCH] [ng] dirstamp: remove, use inlined parent directory creation instead
Date: Thu, 24 May 2012 10:29:35 +0200

On 05/21/2012 04:19 PM, Stefano Lattarini wrote:
> 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).
> 
Pushed now.

Regards,
  Stefano



reply via email to

[Prev in Thread] Current Thread [Next in Thread]