automake-ng
[Top][All Lists]
Advanced

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

[Automake-NG] [FYI] [ng] refactor: remove all uses of '$(am__strip_dir)'


From: Stefano Lattarini
Subject: [Automake-NG] [FYI] [ng] refactor: remove all uses of '$(am__strip_dir)'
Date: Wed, 8 Aug 2012 12:36:49 +0200

Prefer using GNU make built-in '$(notdir)' instead.  This change doesn't
offer any serious simplification, but is just a step in the general
direction of moving more non-trivial processing to GNU make.

* lib/am/lib.am: Rewritten some install/uninstall rules to avoid
using '$(am__strip_dir)'.
* lib/am/lisp.am: Likewise.
* lib/am/ltlib.am: Likewise.
* lib/am/python.am: Likewise.
* lib/am/texinfos.am: Likewise.
* lib/am/header-vars.mk (am__strip_dir): Remove.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 lib/am/header-vars.mk |  3 ---
 lib/am/libs.am        | 10 +++++-----
 lib/am/lisp.am        | 28 ++++++++++++----------------
 lib/am/ltlib.am       |  8 ++++----
 lib/am/python.am      | 25 ++++---------------------
 lib/am/texinfos.am    | 27 ++++++++++-----------------
 6 files changed, 35 insertions(+), 66 deletions(-)

diff --git a/lib/am/header-vars.mk b/lib/am/header-vars.mk
index b4306cd..b21b927 100644
--- a/lib/am/header-vars.mk
+++ b/lib/am/header-vars.mk
@@ -356,9 +356,6 @@ NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
 
-# Strip all directories.
-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.
diff --git a/lib/am/libs.am b/lib/am/libs.am
index ece5212..164af58 100644
--- a/lib/am/libs.am
+++ b/lib/am/libs.am
@@ -63,11 +63,11 @@ endif !%?BASE%
 ## useless; sh never actually executes this command.  Read the GNU
 ## Standards for a little enlightenment on this.
        @$(POST_INSTALL)
-       @list='$(%DIR%_LIBRARIES)'; test -n "$(%NDIR%dir)" || list=; \
-       for p in $$list; do \
-         if test -f $$p; then \
-?BASE?     $(am__strip_dir) \
-?!BASE?            f=$$p; \
+?BASE? @list='$(notdir $(%DIR%_LIBRARIES))'; \
+?!BASE?        @list='$(%DIR%_LIBRARIES)'; \
+       test -n "$(%NDIR%dir)" || list=; \
+       for f in $$list; do \
+         if test -f $$f; then \
 ## Must ranlib after installing because mod time changes.
 ## cd to target directory because AIX ranlib messes up with whitespace
 ## in the argument.
diff --git a/lib/am/lisp.am b/lib/am/lisp.am
index c6fb923..7135e3a 100644
--- a/lib/am/lisp.am
+++ b/lib/am/lisp.am
@@ -61,25 +61,21 @@ install-%DIR%LISP: $(%DIR%_LISP) $(ELCFILES)
        @if test "$(EMACS)" != no && test -n "$(%NDIR%dir)"; then \
 ## Funny invocation because Makefile variable can be empty, leading to
 ## a syntax error in sh.
-         list='$(%DIR%_LISP)'; \
-         if test -n "$$list"; then \
+         $(if $(%DIR%_LISP), \
            echo " $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)'"; \
            $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)" || exit 1; \
-         fi; \
-         for p in $$list; do \
-## A lisp file can be in the source directory or the build directory.
-           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-?BASE?     $(am__strip_dir) \
-?!BASE?            f=$$p; \
-           echo " $(%DIR%LISP_INSTALL) '$$d$$p' '$(DESTDIR)$(%NDIR%dir)/$$f'"; 
\
-           $(%DIR%LISP_INSTALL) "$$d$$p" "$(DESTDIR)$(%NDIR%dir)/$$f" || exit 
$$?; \
+           $(foreach i, $(%DIR%_LISP), \
+             p=$(call am.vpath.rewrite,$i); \
+?BASE?       f=$(notdir $i); \
+?!BASE?              f=$i; \
+             echo " $(%DIR%LISP_INSTALL) '$$p' '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
+             $(%DIR%LISP_INSTALL) "$$p" "$(DESTDIR)$(%NDIR%dir)/$$f" || exit 
$$?; \
 ## Only install .elc file if it exists.
-           if test -f $${p}c; then \
-             echo " $(%DIR%LISP_INSTALL) '$${p}c' 
'$(DESTDIR)$(%NDIR%dir)/$${f}c'"; \
-             $(%DIR%LISP_INSTALL) "$${p}c" "$(DESTDIR)$(%NDIR%dir)/$${f}c" || 
exit $$?; \
-           else : ; fi; \
-         done; \
-       else : ; fi
+             if test -f $${p}c; then \
+               echo " $(%DIR%LISP_INSTALL) '$${p}c' 
'$(DESTDIR)$(%NDIR%dir)/$${f}c'"; \
+               $(%DIR%LISP_INSTALL) "$${p}c" "$(DESTDIR)$(%NDIR%dir)/$${f}c" 
|| exit $$?; \
+             else : ; fi;)) \
+         :; else :; fi;
 endif %?INSTALL%
 
 
diff --git a/lib/am/ltlib.am b/lib/am/ltlib.am
index d80b66f..543f7dc 100644
--- a/lib/am/ltlib.am
+++ b/lib/am/ltlib.am
@@ -87,10 +87,10 @@ if %?INSTALL%
 .PHONY uninstall-am: uninstall-%DIR%LTLIBRARIES
 uninstall-%DIR%LTLIBRARIES:
        @$(NORMAL_UNINSTALL)
-       @list='$(%DIR%_LTLIBRARIES)'; test -n "$(%NDIR%dir)" || list=; \
-       for p in $$list; do \
-?BASE?   $(am__strip_dir) \
-?!BASE?          f=$$p; \
+?BASE? @list='$(notdir $(%DIR%_LTLIBRARIES))'; \
+?!BASE?        @list='$(%DIR%_LTLIBRARIES)'; \
+       test -n "$(%NDIR%dir)" || list=; \
+       for f in $$list; do \
 ?LIBTOOL?        echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) 
--mode=uninstall rm -f '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
 ?LIBTOOL?        $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) 
--mode=uninstall rm -f "$(DESTDIR)$(%NDIR%dir)/$$f"; \
 ?!LIBTOOL?       echo " rm -f '$(DESTDIR)$(%NDIR%dir)/$$f'"; \
diff --git a/lib/am/python.am b/lib/am/python.am
index 2ac22cc..d4b6626 100644
--- a/lib/am/python.am
+++ b/lib/am/python.am
@@ -26,24 +26,11 @@ am__installdirs += "$(DESTDIR)$(%NDIR%dir)"
 ?!EXEC?.PHONY install-data-am: install-%DIR%PYTHON
 install-%DIR%PYTHON: $(%DIR%_PYTHON)
        @$(NORMAL_INSTALL)
+       @$(if $(%DIR%_PYTHON),$(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)")
 if %?BASE%
-       @list='$(%DIR%_PYTHON)'; dlist=; list2=; test -n "$(%NDIR%dir)" || 
list=; \
-       if test -n "$$list"; then \
-         echo " $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)'"; \
-         $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)" || exit 1; \
-       fi; \
-       for p in $$list; do \
-## A file can be in the source directory or the build directory.
-         if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
-         if test -f $$b$$p; then \
-## Compute basename of source file.  Unless this is a nobase_ target, we
-## want to install 'python/foo.py' as '$(DESTDIR)$(%NDIR%dir)/foo.py',
-## not '$(DESTDIR)$(%NDIR%dir)/python/foo.py'.
-           $(am__strip_dir) \
-           dlist="$$dlist $$f"; \
-           list2="$$list2 $$b$$p"; \
-         else :; fi; \
-       done; \
+       @test -n "$(%NDIR%dir)" && test -n "$(%DIR%_PYTHON)" || exit 0; \
+       dlist='$(notdir $(%DIR%_PYTHON))'; \
+       list2='$(foreach i,$(%DIR%_PYTHON),$(call am.vpath.rewrite,$i))'; \
        for file in $$list2; do echo $$file; done | $(am__base_list) | \
        while read files; do \
 ## Don't perform translation, since script name is important.
@@ -58,10 +45,6 @@ if %?BASE%
        else :; fi
 else !%?BASE%
        @list='$(%DIR%_PYTHON)'; test -n "$(%NDIR%dir)" || list=; \
-       if test -n "$$list"; then \
-         echo " $(MKDIR_P) '$(DESTDIR)$(%NDIR%dir)'"; \
-         $(MKDIR_P) "$(DESTDIR)$(%NDIR%dir)" || exit 1; \
-       fi; \
        $(am__nobase_list) | while read dir files; do \
          xfiles=; for p in $$files; do \
 ## A file can be in the source directory or the build directory.
diff --git a/lib/am/texinfos.am b/lib/am/texinfos.am
index 71c497a..116053c 100644
--- a/lib/am/texinfos.am
+++ b/lib/am/texinfos.am
@@ -135,26 +135,19 @@ install-html-am: am--install-html
 am--install-html: $(HTMLS)
        @$(NORMAL_INSTALL)
        $(call am__create_installdir,$(htmldir))
-       @list='$(HTMLS)'; list2=; test -n "$(htmldir)" || list=; \
-       for p in $$list; do \
-         if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \
-         $(am__strip_dir) \
-## This indirection is required to work around a bug of the Solaris 10
-## shell /usr/xpg4/bin/sh.  The description of the bug can be found at
-## <http://lists.gnu.org/archive/html/bug-autoconf/2011-11/msg00005.html>
-## and the report of the original failure can be found at automake
-## bug#10026 <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10026#23>
-         d2=$$d$$p; \
-         if test -d "$$d2"; then \
+       @list=''; \
+       $(if $(and $(HTMLS),$(htmldir)),$(foreach i,$(HTMLS), \
+         p=$(call am.vpath.rewrite,$i); \
+         f=$(notdir $i); \
+         if test -d "$$p"; then \
            echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/$$f'"; \
            $(MKDIR_P) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \
-           echo " $(INSTALL_DATA) '$$d2'/* '$(DESTDIR)$(htmldir)/$$f'"; \
-           $(INSTALL_DATA) "$$d2"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \
+           echo " $(INSTALL_DATA) '$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \
+           $(INSTALL_DATA) "$$p"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \
          else \
-           list2="$$list2 $$d2"; \
-         fi; \
-       done; \
-       test -z "$$list2" || { echo "$$list2" | $(am__base_list) | \
+           list="$$list $$p"; \
+         fi;)) \
+       test -z "$$list" || { echo "$$list" | $(am__base_list) | \
        while read files; do \
          echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(htmldir)'"; \
          $(INSTALL_DATA) $$files "$(DESTDIR)$(htmldir)" || exit $$?; \
-- 
1.7.12.rc0




reply via email to

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