Merge branch 'minor'
[automake.git] / lib / am / tags.am
blob151402e2312796be355968ecf540a1350147691f
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994-2017 Free Software Foundation, Inc.
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
7 ## any later version.
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ## GNU General Public License for more details.
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 # Read a list of newline-separated strings from the standard input,
18 # and print each of them once, without duplicates.  Input order is
19 # *not* preserved.
20 am__uniquify_input = $(AWK) '\
21   BEGIN { nonempty = 0; } \
22   { items[$$0] = 1; nonempty = 1; } \
23   END { if (nonempty) { for (i in items) print i; }; } \
26 # Make sure the list of sources is unique.  This is necessary because,
27 # e.g., the same source file might be shared among _SOURCES variables
28 # for different programs/libraries.
29 am__define_uniq_tagged_files = \
30   list='$(am__tagged_files)'; \
31   unique=`for i in $$list; do \
32 ## Handle VPATH correctly.
33     if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
34   done | $(am__uniquify_input)`
36 ## ---- ##
37 ## ID.  ##
38 ## ---- ##
40 ID: $(am__tagged_files)
41         $(am__define_uniq_tagged_files); mkid -fID $$unique
44 ## ------ ##
45 ## TAGS.  ##
46 ## ------ ##
48 ETAGS = etags
49 .PHONY: TAGS tags
50 if %?SUBDIRS%
51 AM_RECURSIVE_TARGETS += TAGS
52 RECURSIVE_TARGETS += tags-recursive
53 tags: tags-recursive
54 else !%?SUBDIRS%
55 tags: tags-am
56 endif !%?SUBDIRS%
57 TAGS: tags
59 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
60 ## We use the positional parameters to build the subdir list with
61 ## absolute names, without the need to worry about white space in `pwd`.
62         set x; \
63         here=`pwd`; \
64 ## Exuberant Ctags wants --etags-include,
65 ## GNU Etags             --include
66 ## Furthermore Exuberant Ctags 5.5.4 fails to create TAGS files
67 ## when no files are supplied, despite any --etags-include option.
68 ## A workaround is to pass '.' as a file.  This is what $empty_fix is for.
69 ?SUBDIRS?       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
70 ?SUBDIRS?         include_option=--etags-include; \
71 ?SUBDIRS?         empty_fix=.; \
72 ?SUBDIRS?       else \
73 ?SUBDIRS?         include_option=--include; \
74 ?SUBDIRS?         empty_fix=; \
75 ?SUBDIRS?       fi; \
76 ?SUBDIRS?       list='$(SUBDIRS)'; for subdir in $$list; do \
77 ## Do nothing if we're trying to look in '.'.
78 ?SUBDIRS?         if test "$$subdir" = .; then :; else \
79 ?SUBDIRS?           test ! -f $$subdir/TAGS || \
80 ## Note that the = is mandatory for --etags-include.
81 ?SUBDIRS?             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
82 ?SUBDIRS?         fi; \
83 ?SUBDIRS?       done; \
84         $(am__define_uniq_tagged_files); \
85 ## Remove the 'x' we added first:
86         shift; \
87 ## Make sure we have something to run etags on.
88         if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
89           test -n "$$unique" || unique=$$empty_fix; \
90           if test $$# -gt 0; then \
91             $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
92               "$$@" $$unique; \
93           else \
94             $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
95               $$unique; \
96           fi; \
97         fi
100 ## --------------- ##
101 ## vi-style tags.  ##
102 ## --------------- ##
104 CTAGS = ctags
105 .PHONY: CTAGS ctags
106 if %?SUBDIRS%
107 AM_RECURSIVE_TARGETS += CTAGS
108 RECURSIVE_TARGETS += ctags-recursive
109 ctags: ctags-recursive
110 else !%?SUBDIRS%
111 ctags: ctags-am
112 endif !%?SUBDIRS%
114 CTAGS: ctags
115 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
116         $(am__define_uniq_tagged_files); \
117 ## Make sure we have something to run ctags on.
118         test -z "$(CTAGS_ARGS)$$unique" \
119           || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
120              $$unique
123 ## --------------- ##
124 ## "Global tags".  ##
125 ## --------------- ##
127 .PHONY: GTAGS
128 GTAGS:
129         here=`$(am__cd) $(top_builddir) && pwd` \
130           && $(am__cd) $(top_srcdir) \
131           && gtags -i $(GTAGS_ARGS) "$$here"
134 ## ------- ##
135 ## cscope  ##
136 ## ------- ##
138 if %?TOPDIR_P%
139 CSCOPE = cscope
140 .PHONY: cscope clean-cscope
141 AM_RECURSIVE_TARGETS += cscope
142 cscope: cscope.files
143         test ! -s cscope.files \
144           || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
145 clean-cscope:
146         -rm -f cscope.files
147 cscope.files: clean-cscope cscopelist
148 endif %?TOPDIR_P%
150 if %?SUBDIRS%
151 RECURSIVE_TARGETS += cscopelist-recursive
152 cscopelist: cscopelist-recursive
153 else !%?SUBDIRS%
154 cscopelist: cscopelist-am
155 endif !%?SUBDIRS%
157 cscopelist-am: $(am__tagged_files)
158         list='$(am__tagged_files)'; \
159         case "$(srcdir)" in \
160           [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
161           *) sdir=$(subdir)/$(srcdir) ;; \
162         esac; \
163         for i in $$list; do \
164           if test -f "$$i"; then \
165             echo "$(subdir)/$$i"; \
166           else \
167             echo "$$sdir/$$i"; \
168           fi; \
169         done >> $(top_builddir)/cscope.files
172 ## ---------- ##
173 ## Cleaning.  ##
174 ## ---------- ##
176 .PHONY distclean-am: distclean-tags
178 distclean-tags:
179         -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
180 if %?TOPDIR_P%
181         -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
182 endif %?TOPDIR_P%