automake-patches
[Top][All Lists]
Advanced

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

Faster `make uninstall'; fast install for JAVA.


From: Ralf Wildenhues
Subject: Faster `make uninstall'; fast install for JAVA.
Date: Sun, 7 Sep 2008 09:50:36 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

The next in the series.  Since uninstall is generally easier to do
efficiently than install, let's fix that first.  Note that, simply
by entering the destination directory, we can avoid all command line
length issues.  I chose to echo the commands issued in subshells, so
that cut and pasting multiple lines of commands works seamlessly,
never mind the fact that the subshells are not really used in the
actual code.

Since java install is just like java uninstall, let's fix that here,
too.

python's uninstall formerly didn't print output for removing the
byte-compiled stuff.  I don't see why we should hide that, so
this patch prints it, too.

Also, there is some nice factorization of the nobase `$(srcdir)/'
stripping code in inst-vars.am.  Yes, it is quite unreadable,
sorry about that.

This patch as well as the couple of previous ones have the following
chance of hitting an undocumented incompatibility:

If the user has '.' early in her $PATH, _and_ that build directory
has replacements of, say, `rm' or `ranlib', then these changes will
alter the behavior of the install and uninstall target.  I figured
this is both sufficiently remote, and easily fixable by the user
(set RANLIB, and/or use an absolute PATH entry, to override programs)
that I think we can safely ignore it.

Cheers,
Ralf

        Faster `make uninstall'; fast install for JAVA.

        * lib/am/inst-vars.am (am__nobase_strip_setup)
        (am__nobase_strip): New macros.
        (am__nobase_list): Factorize.
        * lib/am/data.am (uninstall-%DIR%%PRIMARY%): Use them, for a
        constant number of forks per uninstall.
        * lib/am/libs.am (uninstall-%DIR%LIBRARIES): Likewise.
        * lib/am/lisp.am (uninstall-%DIR%LISP): Likewise.
        * lib/am/progs.am (uninstall-%DIR%PROGRAMS): Fast uninstall.
        * lib/am/python.am (uninstall-%DIR%PYTHON): Fast uninstall.
        Echo all `rm' commands that are are executed.
        * lib/am/java.am (install-%DIR%JAVA, uninstall-%DIR%JAVA):
        Fast install and uninstall.

diff --git a/lib/am/inst-vars.am b/lib/am/inst-vars.am
index eb0bba1..4fa0d22 100644
--- a/lib/am/inst-vars.am
+++ b/lib/am/inst-vars.am
@@ -27,6 +27,13 @@ am__vpath_adj = case $$p in \
 am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
 ## Number of files to install concurrently.
 am__install_max = 40
+## Take a $list of nobase files, strip $(srcdir) from them.
+## Split apart in setup variable and an action that can be used
+## in backticks or in a pipe.
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
 ## Take a $list of nobase files, collect them, indexed by their
 ## srcdir-stripped dirnames.  For up to am__install_max files, output
 ## a line containing the dirname and the files, space-separated.
@@ -34,14 +41,13 @@ am__install_max = 40
 ## string concatenation in most shells, and should avoid line length
 ## limitations, while still offering only negligible performance impact
 ## through spawning more install commands than absolutely needed.
-am__nobase_list = \
-  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`; \
+am__nobase_list = $(am__nobase_strip_setup); \
   for p in $$list; do echo "$$p $$p"; done | \
   sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
   $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
     if (++n[$$2] == $(am__install_max)) \
       { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
-    END { for (dir in files) print dir " " files[dir] }'
+    END { for (dir in files) print dir, files[dir] }'
 ## Collect up to 40 files per line from stdin.
 am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
diff --git a/lib/am/data.am b/lib/am/data.am
index a7039c0..63db01d 100644
--- a/lib/am/data.am
+++ b/lib/am/data.am
@@ -70,12 +70,12 @@ if %?INSTALL%
 .PHONY uninstall-am: uninstall-%DIR%%PRIMARY%
 uninstall-%DIR%%PRIMARY%:
        @$(NORMAL_UNINSTALL)
-?!BASE?        @$(am__vpath_adj_setup) \
-       address@hidden'$(%DIR%_%PRIMARY%)'; for p in $$list; do \
-         %BASE?$(am__strip_dir):$(am__vpath_adj)% \
-         echo " rm -f '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
-         rm -f "$(DESTDIR)$(%NDIR%dir)/$$f"; \
-       done
+       @list='$(%DIR%_%PRIMARY%)'; \
+?BASE? files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+?!BASE?        $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files
 endif %?INSTALL%
 
 
diff --git a/lib/am/java.am b/lib/am/java.am
index 98a1fcf..f183bee 100644
--- a/lib/am/java.am
+++ b/lib/am/java.am
@@ -50,10 +50,10 @@ install-%DIR%JAVA: class%DIR%.stamp
 ## A single .java file can be compiled into multiple .class files.  So
 ## we just install all the .class files that got built into this
 ## directory.  This is not optimal, but will have to do for now.
-       @test -z "$(%DIR%_JAVA)" || for p in *.class; do \
-         echo " $(INSTALL_DATA) '$$p' '$(DESTDIR)$(%NDIR%dir)/$$p'"; \
-         $(INSTALL_DATA) "$$p" "$(DESTDIR)$(%NDIR%dir)/$$p" || exit $$?; \
-       done
+       @test -n "$(%DIR%_JAVA)" || exit 0; \
+       set x *.class; shift; test "$$1" != "*.class" || exit 0; \
+       echo " $(INSTALL_DATA)" "$$@" "'$(DESTDIR)$(%NDIR%dir)/$$p'"; \
+       $(INSTALL_DATA) "$$@" "$(DESTDIR)$(%NDIR%dir)"
 endif %?INSTALL%
 
 
@@ -65,10 +65,10 @@ if %?INSTALL%
 .PHONY uninstall-am: uninstall-%DIR%JAVA
 uninstall-%DIR%JAVA:
        @$(NORMAL_UNINSTALL)
-       @test -z "$(%DIR%_JAVA)" || for p in *.class; do \
-         echo " rm -f '$(DESTDIR)$(%NDIR%dir)/$$p'"; \
-         rm -f "$(DESTDIR)$(%NDIR%dir)/$$p"; \
-       done
+       @test -n "$(%DIR%_JAVA)" || exit 0; \
+       set x *.class; shift; test "$$1" != "*.class" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" "$$@" ")"; \
+       cd "$(DESTDIR)$(%NDIR%dir)" && rm -f "$$@"
 endif %?INSTALL%
 
 
diff --git a/lib/am/libs.am b/lib/am/libs.am
index 450a105..0064009 100644
--- a/lib/am/libs.am
+++ b/lib/am/libs.am
@@ -83,11 +83,12 @@ if %?INSTALL%
 .PHONY uninstall-am: uninstall-%DIR%LIBRARIES
 uninstall-%DIR%LIBRARIES:
        @$(NORMAL_UNINSTALL)
-       @list='$(%DIR%_LIBRARIES)'; for p in $$list; do \
-         %BASE?$(am__strip_dir):f=$$p;% \
-         echo " rm -f '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
-         rm -f "$(DESTDIR)$(%NDIR%dir)/$$f"; \
-       done
+       @list='$(%DIR%_LIBRARIES)'; \
+?BASE? files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+?!BASE?        $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
+       test -n "$$files" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f "$$files" )"; \
+       cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files
 endif %?INSTALL%
 
 
diff --git a/lib/am/lisp.am b/lib/am/lisp.am
index a7759d7..bda2bcc 100644
--- a/lib/am/lisp.am
+++ b/lib/am/lisp.am
@@ -115,14 +115,16 @@ if %?INSTALL%
 uninstall-%DIR%LISP:
        @$(NORMAL_UNINSTALL)
 ## Do not uninstall anything if EMACS was not found.
-       @if test "$(EMACS)" != no; then \
-?!BASE?          $(am__vpath_adj_setup) \
-         list='$(%DIR%_LISP)'; for p in $$list; do \
-           %BASE?$(am__strip_dir):$(am__vpath_adj)% \
-           echo " rm -f '$(DESTDIR)$(%NDIR%dir)/$$f' 
'$(DESTDIR)$(%NDIR%dir)/$${f}c'"; \
-           rm -f "$(DESTDIR)$(%NDIR%dir)/$$f" "$(DESTDIR)$(%NDIR%dir)/$${f}c"; 
\
-         done; \
-       else : ; fi
+       @test "$(EMACS)" != no || exit 0; \
+       list='$(%DIR%_LISP)'; \
+?BASE? files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+?!BASE?        $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
+       test -n "$$files" || exit 0; \
+       filesc=`echo "$$files" | sed 's|$$|c|'`; \
+       echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files || exit $$?; \
+       echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$filesc ")"; \
+       cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$filesc
 endif %?INSTALL%
 
 
diff --git a/lib/am/progs.am b/lib/am/progs.am
index 83a8f1b..cc4cf4a 100644
--- a/lib/am/progs.am
+++ b/lib/am/progs.am
@@ -63,14 +63,17 @@ if %?INSTALL%
 .PHONY uninstall-am: uninstall-%DIR%PROGRAMS
 uninstall-%DIR%PROGRAMS:
        @$(NORMAL_UNINSTALL)
-       @list='$(%DIR%_PROGRAMS)'; for p in $$list; do \
-## Remove any leading directory before applying $(transform).
-         f=`echo "$$p" | sed 
's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
-## Prepend the directory part if nobase_ is used.
-?!BASE?          f=`echo "$$p" | sed 's|[^/]*$$||'`"$$f"; \
-         echo " rm -f '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
-         rm -f "$(DESTDIR)$(%NDIR%dir)/$$f"; \
-       done
+       @list='$(%DIR%_PROGRAMS)'; \
+       files=`for p in $$list; do echo "$$p"; done | \
+## Remove any leading directory before applying $(transform),
+## but keep the directory part in the hold buffer, in order to
+## reapply it again afterwards in the nobase case.  Append $(EXEEXT).
+         sed 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/; \
+?!BASE?               x;s,[^/]*$$,,;G;s,\n,,; \
+              '`; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files
 endif %?INSTALL%
 
 
diff --git a/lib/am/python.am b/lib/am/python.am
index 7a1cdb2..5d23486 100644
--- a/lib/am/python.am
+++ b/lib/am/python.am
@@ -95,15 +95,20 @@ if %?INSTALL%
 .PHONY uninstall-am: uninstall-%DIR%PYTHON
 uninstall-%DIR%PYTHON:
        @$(NORMAL_UNINSTALL)
-?!BASE?        @$(am__vpath_adj_setup) \
-       address@hidden'$(%DIR%_PYTHON)'; dlist=''; for p in $$list; do\
-         %BASE?$(am__strip_dir):$(am__vpath_adj)% \
-         rm -f "$(DESTDIR)$(%NDIR%dir)/$$f"; \
+       @list='$(%DIR%_PYTHON)'; \
+?BASE? files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+?!BASE?        $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
+       test -n "$$files" || exit 0; \
+       filesc=`echo "$$files" | sed 's|$$|c|'`; \
+       fileso=`echo "$$files" | sed 's|$$|o|'`; \
+       echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$files || exit $$?; \
 ## This is to remove the .pyc and .pyo byte compiled versions (a bit
 ## of a hack).
-         rm -f "$(DESTDIR)$(%NDIR%dir)/$${f}c"; \
-         rm -f "$(DESTDIR)$(%NDIR%dir)/$${f}o"; \
-       done
+       echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$filesc ")"; \
+       cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$filesc || exit $$?; \
+       echo " ( cd '$(DESTDIR)$(%NDIR%dir)' && rm -f" $$fileso ")"; \
+       cd "$(DESTDIR)$(%NDIR%dir)" && rm -f $$fileso
 endif %?INSTALL%
 
 




reply via email to

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