Merge branch 'msvc'
[platform/upstream/automake.git] / lib / am / tags.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003,
3 ## 2004, 2007, 2008, 2009  Free Software Foundation, Inc.
4
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2, or (at your option)
8 ## any later version.
9
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ## GNU General Public License for more details.
14
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 ## ---- ##
19 ## ID.  ##
20 ## ---- ##
21
22 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
23 ## Make sure the list of sources is unique.
24         list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
25         unique=`for i in $$list; do \
26 ## Handle VPATH correctly.
27             if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
28           done | \
29           $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
30               END { if (nonempty) { for (i in files) print i; }; }'`; \
31         mkid -fID $$unique
32
33
34 ## ------ ##
35 ## TAGS.  ##
36 ## ------ ##
37
38 ETAGS = etags
39 .PHONY: tags
40 if %?SUBDIRS%
41 AM_RECURSIVE_TARGETS += tags TAGS
42 endif %?SUBDIRS%
43 tags: TAGS
44
45 TAGS: %TAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \
46                 $(TAGS_FILES) $(LISP)
47 ## We use the positional parameters to build the subdir list with
48 ## absolute names, without the need to worry about white space in `pwd`.
49         set x; \
50         here=`pwd`; \
51 ## It is tempting to use if/endif here, but don't: the previous
52 ## backslash will cause bad results (automake doesn't `see' the `if').
53 ## Exuberant Ctags wants --etags-include,
54 ## GNU Etags             --include
55 ## Furthermore Exuberant Ctags 5.5.4 fails to create TAGS files
56 ## when no files are supplied, despite any --etags-include option.
57 ## A workaround is to pass `.' as a file.  This is what $empty_fix is for.
58 ?SUBDIRS?       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
59 ?SUBDIRS?         include_option=--etags-include; \
60 ?SUBDIRS?         empty_fix=.; \
61 ?SUBDIRS?       else \
62 ?SUBDIRS?         include_option=--include; \
63 ?SUBDIRS?         empty_fix=; \
64 ?SUBDIRS?       fi; \
65 ?SUBDIRS?       list='$(SUBDIRS)'; for subdir in $$list; do \
66 ## Do nothing if we're trying to look in `.'.
67 ?SUBDIRS?         if test "$$subdir" = .; then :; else \
68 ?SUBDIRS?           test ! -f $$subdir/TAGS || \
69 ## Note that the = is mandatory for --etags-include.
70 ?SUBDIRS?             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
71 ?SUBDIRS?         fi; \
72 ?SUBDIRS?       done; \
73 ## Make sure the list of sources is unique.
74         list='$(SOURCES) $(HEADERS) %CONFIG% $(LISP) $(TAGS_FILES)'; \
75         unique=`for i in $$list; do \
76 ## Handle VPATH correctly.
77             if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
78           done | \
79           $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
80               END { if (nonempty) { for (i in files) print i; }; }'`; \
81 ## Remove the `x' we added first:
82         shift; \
83 ## Make sure we have something to run etags on.
84         if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
85           test -n "$$unique" || unique=$$empty_fix; \
86           if test $$# -gt 0; then \
87             $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
88               "$$@" $$unique; \
89           else \
90             $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
91               $$unique; \
92           fi; \
93         fi
94
95
96 ## ------------- ##
97 ## vi-style tags ##
98 ## ------------- ##
99
100 CTAGS = ctags
101 .PHONY: CTAGS ctags
102 if %?SUBDIRS%
103 AM_RECURSIVE_TARGETS += ctags CTAGS
104 endif %?SUBDIRS%
105 ctags: CTAGS
106
107 ## We have a dummy name here because `tags' has already been in use
108 ## for a long time to mean Emacs-style tags.  Oops.  This means the
109 ## dependencies here are useless.
110 CTAGS: %CTAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \
111                 $(TAGS_FILES) $(LISP)
112 ## Make sure the list of sources is unique.
113         list='$(SOURCES) $(HEADERS) %CONFIG% $(LISP) $(TAGS_FILES)'; \
114         unique=`for i in $$list; do \
115 ## Handle VPATH correctly.
116             if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
117           done | \
118           $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
119               END { if (nonempty) { for (i in files) print i; }; }'`; \
120 ## Make sure we have something to run ctags on.
121         test -z "$(CTAGS_ARGS)$$unique" \
122           || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
123              $$unique
124
125
126 ## --------------- ##
127 ## `Global' tags.  ##
128 ## --------------- ##
129
130 .PHONY: GTAGS
131 GTAGS:
132         here=`$(am__cd) $(top_builddir) && pwd` \
133           && $(am__cd) $(top_srcdir) \
134           && gtags -i $(GTAGS_ARGS) "$$here"
135
136
137 ## ------- ##
138 ## cscope  ##
139 ## ------- ##
140
141 if %?TOPDIR_P%
142
143 CSCOPE = cscope
144 .PHONY: cscope clean-cscope
145 AM_RECURSIVE_TARGETS += cscope
146
147 cscope: cscope.files
148         test ! -s cscope.files \
149           || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
150
151 clean-cscope:
152         -rm -f cscope.files
153
154 cscope.files: clean-cscope %CSCOPEDIRS% cscopelist
155
156 endif %?TOPDIR_P%
157
158 .PHONY: cscopelist
159 cscopelist: %CSCOPEDIRS% $(HEADERS) $(SOURCES) $(LISP)
160         list='$(SOURCES) $(HEADERS) $(LISP)'; \
161         case "$(srcdir)" in \
162           [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
163           *) sdir=$(subdir)/$(srcdir) ;; \
164         esac; \
165         for i in $$list; do \
166           if test -f "$$i"; then \
167             echo "$(subdir)/$$i"; \
168           else \
169             echo "$$sdir/$$i"; \
170           fi; \
171         done >> $(top_builddir)/cscope.files
172
173
174 ## ---------- ##
175 ## Cleaning.  ##
176 ## ---------- ##
177
178 .PHONY distclean-am: distclean-tags
179
180 distclean-tags:
181         -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
182 if %?TOPDIR_P%
183         -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
184 endif %?TOPDIR_P%