]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] dist: optimize calculation of list of distributed file
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 4 May 2012 00:26:30 +0000 (02:26 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 11 May 2012 11:18:18 +0000 (13:18 +0200)
Our implementation of the $(am__uniq) make function is slow as
hell when applied to big lists.  Since that function is used to
(re)calculate the list of distributed files, its inefficiency
reflects on *every* run of a Makefile generated by Automake which
distributes a lot of files.  For example, a null build of the
Automake tree now takes 20 seconds (!) on my Debian system, while
earlier it was practically instantaneous (less than half a second).

Luckily, the GNU make manual documents that the $(sort) built-in
also strip duplicates from the sorted list.  Since we don't care
about the order of the distributed files (or directories thereof),
we can use $(sort ...) instead of $(call am__uniq, ...), and live
happily.

* lib/am/distdir.am (am__dist_files)_: Uniqify content using
'$(sort)', not '$(am__uniq)'.
(am__dist_parent_dirs): Likewise.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
lib/am/distdir.am

index 273b4d6fbd34e2eaaeaf971365696c3c17d47bcf..face03ad0f4112599947034974e87ed81e1aef40 100644 (file)
 ## You should have received a copy of the GNU General Public License
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-am__dist_files = $(call am__uniq, \
-  $(am__dist_common) $(am__dist_sources) $(TEXINFOS) $(EXTRA_DIST))
+## Use 'sort', not 'am__uniq', for performance reasons.  Luckily, we
+## don't care in which order the distributed files are.
+am__dist_files = $(strip $(sort \
+  $(am__dist_common) $(am__dist_sources) $(TEXINFOS) $(EXTRA_DIST)))
 
 ## Try to avoid repeated slashed in the entries, to make the
 ## filtering in the 'am__dist_files_1' definition below more reliable.
@@ -59,8 +61,8 @@ am__dist_files_cooked = $(strip $(am__dist_files_2))
 ## will allow our rules to correctly create "$(distdir)/subdir", and not
 ## "$(distdir)/$(srcdir)/subdir" -- which, in a VPATH build where
 ## "$(subdir) = ..", would be the build directory!
-am__dist_parent_dirs = $(call am__uniq, \
-  $(filter-out ., $(patsubst ./%,%,$(dir $(am__dist_files_cooked)))))
+am__dist_parent_dirs = $(strip $(sort \
+  $(filter-out ., $(patsubst ./%,%,$(dir $(am__dist_files_cooked))))))
 
 if %?TOPDIR_P%
 distdir = $(PACKAGE)-$(VERSION)