automake-ng
[Top][All Lists]
Advanced

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

[Automake-NG] [FYI] [ng] tags: use more GNU make features


From: Stefano Lattarini
Subject: [Automake-NG] [FYI] [ng] tags: use more GNU make features
Date: Thu, 9 Aug 2012 19:32:41 +0200

* lib/am/tags.am (am__uniquify_input, am__define_uniq_tagged_files):
Remove, their role taken over by ...
(am.tags.files.uniq): ... this new (memoized) variable.
All rules adjusted.
(tags-am): Use $(CURDIR) instead of `pwd` to compute the absolute
path of the current working directory.
(GTAGS): Use $(abs_top_builddir) instead of `cd $(top_builddir) && pwd`
to compute the absolute path of the top-level build directory.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 lib/am/tags.am | 39 +++++++++++----------------------------
 1 file changed, 11 insertions(+), 28 deletions(-)

diff --git a/lib/am/tags.am b/lib/am/tags.am
index 368911d..b7874f7 100644
--- a/lib/am/tags.am
+++ b/lib/am/tags.am
@@ -14,31 +14,18 @@
 ## You should have received a copy of the GNU General Public License
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Read a list of newline-separated strings from the standard input,
-# and print each of them once, without duplicates.  Input order is
-# *not* preserved.
-am__uniquify_input = $(AWK) '\
-  BEGIN { nonempty = 0; } \
-  { items[$$0] = 1; nonempty = 1; } \
-  END { if (nonempty) { for (i in items) print i; }; } \
-'
-
-# Make sure the list of sources is unique.  This is necessary because,
-# e.g., the same source file might be shared among _SOURCES variables
-# for different programs/libraries.
-am__define_uniq_tagged_files = \
-  list='$(am.tags.files)'; \
-  unique=`for i in $$list; do \
-## Handle VPATH correctly.
-    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-  done | $(am__uniquify_input)`
+# Use $(sort) rather than $(am.util.uniq) here, because the former is
+# faster on long lists, and we don't care about the order of the list
+# anyway.
+am.tags.files.unique = \
+ $(call am.memoize,am.tags.files.unique,$(sort $(am.tags.files)))
 
 ## ---- ##
 ## ID.  ##
 ## ---- ##
 
 ID: $(am.tags.files)
-       $(am__define_uniq_tagged_files); mkid -fID $$unique
+       mkid -fID $(am.tags.files.unique)
 
 
 ## ------ ##
@@ -60,7 +47,6 @@ tags-am: $(TAGS_DEPENDENCIES) $(am.tags.files)
 ## We use the positional parameters to build the subdir list with
 ## absolute names, without the need to worry about white space in `pwd`.
        set x; \
-       here=`pwd`; \
 ## Exuberant Ctags wants --etags-include,
 ## GNU Etags             --include
 ## Furthermore Exuberant Ctags 5.5.4 fails to create TAGS files
@@ -78,13 +64,13 @@ tags-am: $(TAGS_DEPENDENCIES) $(am.tags.files)
 ?SUBDIRS?        if test "$$subdir" = .; then :; else \
 ?SUBDIRS?          test ! -f $$subdir/TAGS || \
 ## Note that the = is mandatory for --etags-include.
-?SUBDIRS?            set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+?SUBDIRS?            set "$$@" "$$include_option=$(CURDIR)/$$subdir/TAGS"; \
 ?SUBDIRS?        fi; \
 ?SUBDIRS?      done; \
-       $(am__define_uniq_tagged_files); \
 ## Remove the 'x' we added first:
        shift; \
 ## Make sure we have something to run etags on.
+       unique='$(am.tags.files.unique)'; \
        if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
          test -n "$$unique" || unique=$$empty_fix; \
          if test $$# -gt 0; then \
@@ -113,11 +99,10 @@ endif !%?SUBDIRS%
 
 CTAGS: ctags
 ctags-am: $(TAGS_DEPENDENCIES) $(am.tags.files)
-       $(am__define_uniq_tagged_files); \
 ## Make sure we have something to run ctags on.
-       test -z "$(CTAGS_ARGS)$$unique" \
+       test -z "$(CTAGS_ARGS)$(am.tags.files.unique)" \
          || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-            $$unique
+            $(am.tags.files.unique)
 
 
 ## --------------- ##
@@ -126,9 +111,7 @@ ctags-am: $(TAGS_DEPENDENCIES) $(am.tags.files)
 
 .PHONY: GTAGS
 GTAGS:
-       here=`cd $(top_builddir) && pwd` \
-         && cd $(top_srcdir) \
-         && gtags -i $(GTAGS_ARGS) "$$here"
+       cd $(top_srcdir) && gtags -i $(GTAGS_ARGS) '$(abs_top_builddir)'
 
 
 ## ------- ##
-- 
1.7.12.rc0




reply via email to

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