From ca414ef92868765514a2261c357a51dedd965f81 Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Sun, 7 Sep 2008 11:10:26 +0200 Subject: [PATCH] Fast install and uninstall for SCRIPTS. * lib/am/scripts.am [%?INSTALL%]: Include inst-vars.am independent of `%?BASE%'. (install-%DIR%SCRIPTS): Install multiple scripts at once, using awk and a number of sed scripts. (uninstall-%DIR%SCRIPTS): Compute the installed names, and remove them, all at once. (%DIR%SCRIPT_INSTALL) [!BASE]: No need to use install-sh any more. Signed-off-by: Ralf Wildenhues --- ChangeLog | 10 +++++++ Makefile.in | 62 ++++++++++++++++++++++++++++++++-------- lib/am/scripts.am | 72 ++++++++++++++++++++++++++++------------------- 3 files changed, 103 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3f9f74320..6cdaa973c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2008-09-07 Ralf Wildenhues + Fast install and uninstall for SCRIPTS. + * lib/am/scripts.am [%?INSTALL%]: Include inst-vars.am + independent of `%?BASE%'. + (install-%DIR%SCRIPTS): Install multiple scripts at once, + using awk and a number of sed scripts. + (uninstall-%DIR%SCRIPTS): Compute the installed names, and + remove them, all at once. + (%DIR%SCRIPT_INSTALL) [!BASE]: No need to use install-sh any + more. + Multi-file install for PROGRAMS. * lib/am/progs.am (install-%DIR%PROGRAMS): Allow to install several programs with one install invocation, when not using diff --git a/Makefile.in b/Makefile.in index 0086251b2..5ece957f0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -52,6 +52,27 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ mkinstalldirs = $(SHELL) $(top_srcdir)/lib/mkinstalldirs CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +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/||" +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] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(bindir)" binSCRIPT_INSTALL = $(INSTALL_SCRIPT) SCRIPTS = $(bin_SCRIPTS) @@ -269,22 +290,39 @@ $(am__aclocal_m4_deps): install-binSCRIPTS: $(bin_SCRIPTS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" - @list='$(bin_SCRIPTS)'; for p in $$list; do \ + @list='$(bin_SCRIPTS)'; \ + for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - if test -f $$d$$p; then \ - f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ - echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \ - $(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f" || exit $$?; \ - else :; fi; \ - done + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = ""; list[""] = "" } { \ + if ($$2 == $$4) tgt = $$3; else tgt = $$3 "/" $$4; \ + files[tgt] = files[tgt] " " $$1; dirs[$$3] = 1; \ + if (++n[tgt] == $(am__install_max)) \ + { list[++lno] = tgt " " files[tgt]; n[tgt] = 0; files[tgt] = "" } } \ + END { d = ""; for (dir in dirs) d = d " " dir; print d; \ + for (l in list) print list[l]; \ + for (dir in files) print dir, files[dir] }' | { \ + read dirs; \ + while read dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(binSCRIPT_INSTALL) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(binSCRIPT_INSTALL) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + }; \ + done; } uninstall-binSCRIPTS: @$(NORMAL_UNINSTALL) - @list='$(bin_SCRIPTS)'; for p in $$list; do \ - f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ - echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ - rm -f "$(DESTDIR)$(bindir)/$$f"; \ - done + @list='$(bin_SCRIPTS)'; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. diff --git a/lib/am/scripts.am b/lib/am/scripts.am index 56f491a8c..6db83daeb 100644 --- a/lib/am/scripts.am +++ b/lib/am/scripts.am @@ -16,9 +16,7 @@ ## along with this program. If not, see . if %?INSTALL% -if ! %?BASE% include inst-vars.am -endif ! %?BASE% endif %?INSTALL% ## ------------ ## @@ -28,31 +26,48 @@ endif %?INSTALL% if %?INSTALL% ## if doesn't work properly for Automake variables yet. am__installdirs += "$(DESTDIR)$(%NDIR%dir)" -%DIR%SCRIPT_INSTALL = %BASE?$(INSTALL_SCRIPT):$(install_sh_SCRIPT)% +%DIR%SCRIPT_INSTALL = $(INSTALL_SCRIPT) .PHONY install-%EXEC?exec:data%-am: install-%DIR%SCRIPTS install-%DIR%SCRIPTS: $(%DIR%_SCRIPTS) @$(NORMAL_INSTALL) test -z "$(%NDIR%dir)" || $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)" -?!BASE? @$(am__vpath_adj_setup) \ ## Funny invocation because Makefile variable can be empty, leading to ## a syntax error in sh. - %BASE?@%list='$(%DIR%_SCRIPTS)'; for p in $$list; do \ -?!BASE? $(am__vpath_adj) p=$$f; \ + @list='$(%DIR%_SCRIPTS)'; \ +?!BASE? $(am__nobase_strip_setup); \ + for p in $$list; do \ ## A file can be in the source directory or the build directory. if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - if test -f $$d$$p; then \ -## If the _SCRIPTS variable has an entry like foo/bar, install it as -## $(destdir)/bar, not $(destdir)/foo/bar. The user can make a -## new dir variable or use a nobase_ target for the latter case. -## However in all cases $(transform) applies only to the basename, -## so we have to strip the directory part. - f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ -## Prepend the directory part if nobase_ is used. -?!BASE? f=`echo "$$p" | sed 's|[^/]*$$||'`"$$f"; \ - echo " $(%DIR%SCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(%NDIR%dir)/$$f'"; \ - $(%DIR%SCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(%NDIR%dir)/$$f" || exit $$?; \ - else :; fi; \ - done +## A script may or may not exist. + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ +## We now have a list of "sourcefile newline (nobase-)target" pairs. +## Turn that into "sourcefile source_base target_dir xformed_target_base", +## with newlines being turned into spaces in a second step. + sed -e 'p;s,.*/,,;n' \ +?BASE? -e 'h;s|.*|.|' \ +?!BASE? -e "s|$$srcdirstrip/||" -e 'h;s|[^/]*$$||; s|^$$|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = ""; list[""] = "" } { \ + if ($$2 == $$4) tgt = $$3; else tgt = $$3 "/" $$4; \ + files[tgt] = files[tgt] " " $$1; dirs[$$3] = 1; \ + if (++n[tgt] == $(am__install_max)) \ + { list[++lno] = tgt " " files[tgt]; n[tgt] = 0; files[tgt] = "" } } \ + END { d = ""; for (dir in dirs) d = d " " dir; print d; \ + for (l in list) print list[l]; \ + for (dir in files) print dir, files[dir] }' | { \ + read dirs; \ +?!BASE? for dir in $$dirs; do test . = $$dir || { \ +?!BASE? echo " $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)/$$dir'"; \ +?!BASE? $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)/$$dir" || exit $$?; \ +?!BASE? }; done; \ + while read dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(%DIR%SCRIPT_INSTALL) $$files '$(DESTDIR)$(%NDIR%dir)$$dir'"; \ + $(%DIR%SCRIPT_INSTALL) $$files "$(DESTDIR)$(%NDIR%dir)$$dir" || exit $$?; \ + }; \ + done; } endif %?INSTALL% @@ -64,16 +79,15 @@ if %?INSTALL% .PHONY uninstall-am: uninstall-%DIR%SCRIPTS uninstall-%DIR%SCRIPTS: @$(NORMAL_UNINSTALL) -?!BASE? @$(am__vpath_adj_setup) \ - %BASE?@%list='$(%DIR%_SCRIPTS)'; for p in $$list; do \ -?!BASE? $(am__vpath_adj) p=$$f; \ -## Remove any leading directory before applying $(transform). - f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ -## 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%_SCRIPTS)'; \ +?BASE? files=`for p in $$list; do echo "$$p"; done | \ +?BASE? sed -e 's,.*/,,;$(transform)'`; \ +?!BASE? $(am__nobase_strip_setup); \ +?!BASE? files=`$(am__nobase_strip) \ +?!BASE? -e 'h;s,.*/,,;$(transform);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% -- 2.47.2