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