Hello,

On Sun, May 14, 2006 at 07:32:57PM +0200, Ralf Wildenhues wrote:
> Hmm.  You could "sort -u" the list of directories to create at "make
> dist" time.

nice idea.  Attached please find a patch which implements it.

The patch eliminates the following
        dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`
        $(mkdir_p) ...
for each distributed file which is not a directory, eliminating
4 processes for each of them.

The new code is only five processes, so the gain is obvious.

The patch passes the testsuite.

Have a nice day,
        Stepan Kasal
2006-05-22  Stepan Kasal  <[EMAIL PROTECTED]>

        * lib/am/distdir.am: Do not call $(mkdir_p) for each
        distributed file, collect them and create them in one run.

Index: lib/am/distdir.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/distdir.am,v
retrieving revision 1.64
diff -u -r1.64 distdir.am
--- lib/am/distdir.am   19 Mar 2006 05:04:28 -0000      1.64
+++ lib/am/distdir.am   23 May 2006 10:04:51 -0000
@@ -60,7 +60,7 @@
 ##
        @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
        topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
-       list='$(DISTFILES)'; for file in $$list; do \
+       list='$(DISTFILES)'; dist_files=; for file in $$list; do \
 ##
 ## Yet another hack to support SUN make.
 ##
@@ -106,6 +106,22 @@
 ## be prepended latter.
            $(top_srcdir)/*) file=`echo "$$file" | sed 
"s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
          esac; \
+         dist_files="$$dist_files $$file"; \
+       done; \
+##
+## Make the subdirectories for the files.
+## (The DISTDIRS list can be incomplete, because files in subdirectories can
+## be specified for `dist' conditionally.)
+##
+       case $$dist_files in */*) \
+         ( cd "$(distdir)"; \
+           $(mkdir_p) `for file in $$dist_files; do echo "$$file"; done \
+             | sed -n -e 's,/[^/]*$$,,p' | sort -u`; \
+         ) ;; \
+       esac; \
+##
+##
+       for file in $$dist_files; do \
 ##
 ## Always look for the file in the build directory first.  That way
 ## for something like yacc output we will correctly pick up the latest
@@ -114,18 +130,6 @@
 ##
          if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 ##
-## Make the subdirectory for the file.  This is going to make `dist'
-## really crawl, but it seems like the only way to do it, given that
-## files in subdirectories can be specified for `dist' conditionally.
-##
-         dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
-         if test "$$dir" != "$$file" && test "$$dir" != "."; then \
-           dir="/$$dir"; \
-           $(mkdir_p) "$(distdir)$$dir"; \
-         else \
-           dir=''; \
-         fi; \
-##
 ## Use cp, not ln.  There are situations in which "ln" can fail.  For
 ## instance a file to distribute could actually be a cross-filesystem
 ## symlink -- this can easily happen if "gettextize" was run on the
@@ -142,6 +146,7 @@
 ## source files _and_ generated files.  It is also important when the
 ## directory exists only in $(srcdir), because some vendor Make (such
 ## as Tru64) will magically create an empty directory in `.'
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
            if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
              cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
            fi; \

Reply via email to