summaryrefslogtreecommitdiff
path: root/lib/am/tags.am
blob: fccacca492f514005d639b66866c7298e0bd4543 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
## automake - create Makefile.in from Makefile.am
## Copyright (C) 1994-2012 Free Software Foundation, Inc.

## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.

## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses/>.

## ---- ##
## ID.  ##
## ---- ##

ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
## Make sure the list of sources is unique.
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
	unique=`for i in $$list; do \
## Handle VPATH correctly.
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
	  done | \
	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
	      END { if (nonempty) { for (i in files) print i; }; }'`; \
	mkid -fID $$unique


## ------ ##
## TAGS.  ##
## ------ ##

ETAGS = etags
.PHONY: tags
if %?SUBDIRS%
AM_RECURSIVE_TARGETS += tags TAGS
endif %?SUBDIRS%
tags: TAGS

TAGS: %TAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \
		$(TAGS_FILES) $(LISP)
## 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
## when no files are supplied, despite any --etags-include option.
## A workaround is to pass '.' as a file.  This is what $empty_fix is for.
?SUBDIRS?	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
?SUBDIRS?	  include_option=--etags-include; \
?SUBDIRS?	  empty_fix=.; \
?SUBDIRS?	else \
?SUBDIRS?	  include_option=--include; \
?SUBDIRS?	  empty_fix=; \
?SUBDIRS?	fi; \
?SUBDIRS?	list='$(SUBDIRS)'; for subdir in $$list; do \
## Do nothing if we're trying to look in '.'.
?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?	  fi; \
?SUBDIRS?	done; \
## Make sure the list of sources is unique.
	list='$(SOURCES) $(HEADERS) %CONFIG% $(LISP) $(TAGS_FILES)'; \
	unique=`for i in $$list; do \
## Handle VPATH correctly.
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
	  done | \
	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
	      END { if (nonempty) { for (i in files) print i; }; }'`; \
## Remove the 'x' we added first:
	shift; \
## Make sure we have something to run etags on.
	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
	  test -n "$$unique" || unique=$$empty_fix; \
	  if test $$# -gt 0; then \
	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
	      "$$@" $$unique; \
	  else \
	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
	      $$unique; \
	  fi; \
	fi


## --------------- ##
## vi-style tags.  ##
## --------------- ##

CTAGS = ctags
.PHONY: CTAGS ctags
if %?SUBDIRS%
AM_RECURSIVE_TARGETS += ctags CTAGS
endif %?SUBDIRS%
ctags: CTAGS

## We have a dummy name here because 'tags' has already been in use
## for a long time to mean Emacs-style tags.  Oops.  This means the
## dependencies here are useless.
CTAGS: %CTAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \
		$(TAGS_FILES) $(LISP)
## Make sure the list of sources is unique.
	list='$(SOURCES) $(HEADERS) %CONFIG% $(LISP) $(TAGS_FILES)'; \
	unique=`for i in $$list; do \
## Handle VPATH correctly.
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
	  done | \
	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
	      END { if (nonempty) { for (i in files) print i; }; }'`; \
## Make sure we have something to run ctags on.
	test -z "$(CTAGS_ARGS)$$unique" \
	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
	     $$unique


## --------------- ##
## "Global tags".  ##
## --------------- ##

.PHONY: GTAGS
GTAGS:
	here=`$(am__cd) $(top_builddir) && pwd` \
	  && $(am__cd) $(top_srcdir) \
	  && gtags -i $(GTAGS_ARGS) "$$here"


## ------- ##
## cscope  ##
## ------- ##

if %?TOPDIR_P%

CSCOPE = cscope
.PHONY: cscope clean-cscope
AM_RECURSIVE_TARGETS += cscope

cscope: cscope.files
	test ! -s cscope.files \
	  || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)

clean-cscope:
	-rm -f cscope.files

cscope.files: clean-cscope %CSCOPEDIRS% cscopelist

endif %?TOPDIR_P%

.PHONY: cscopelist
cscopelist: %CSCOPEDIRS% $(HEADERS) $(SOURCES) $(LISP)
	list='$(SOURCES) $(HEADERS) $(LISP)'; \
	case "$(srcdir)" in \
	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
	  *) sdir=$(subdir)/$(srcdir) ;; \
	esac; \
	for i in $$list; do \
	  if test -f "$$i"; then \
	    echo "$(subdir)/$$i"; \
	  else \
	    echo "$$sdir/$$i"; \
	  fi; \
	done >> $(top_builddir)/cscope.files


## ---------- ##
## Cleaning.  ##
## ---------- ##

.PHONY distclean-am: distclean-tags

distclean-tags:
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
if %?TOPDIR_P%
	-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
endif %?TOPDIR_P%