-
Notifications
You must be signed in to change notification settings - Fork 10
/
ctags.mk
53 lines (48 loc) · 1.21 KB
/
ctags.mk
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
CTAGS ?= /usr/bin/ctags-exuberant
CSCOPE ?= /usr/bin/cscope
MKID ?= /usr/bin/mkid
#
# This requires GNUMake and that /bin/sh is bash.
# NOTES:
# $${src:0:1} returns the first character in the variable.
# nullglob: Stop *.h glob from being '*.h' if no headers present.
#
cscope.files:
@echo "Generating ctags file list for $(TARGET)" 1>&2
@set -e; \
for src in $(SRC) $(CPPSRC); \
do \
if [ "$${src:0:1}" = "/" ]; \
then \
echo $${src}; \
else \
echo $(abspath $${src}); \
fi; \
done > $@
@set -e; \
shopt -s nullglob; \
for inc in $(CURDIR) $(EXTRAINCDIRS); \
do \
for hdr in $${inc}/*.h; \
do \
if [ "$${hdr:0:1}" = "/" ]; \
then \
echo $${hdr}; \
else \
echo $(abspath $${hdr}); \
fi; \
done; \
done >> $@
@cat $@ | tr '\n' '\0' >$@.0
ctags: cscope.files
@echo "Generating index files for $(TARGET)" 1>&2
@${CTAGS} --totals --fields=+iaS --extra="+qf" --c++-kinds="+p" -L $< >tags.log 2>&1
@rm tags.log
@${CTAGS} -e --totals --fields=+iaS --extra="+qf" --c++-kinds="-p" -L $< >TAGS.log 2>&1
@rm TAGS.log
@$(CSCOPE) -b -q -i $< >cscope.log 2>&1
@rm cscope.log
@$(MKID) --files0-from=$<.0
ctags_clean:
rm -rf tags TAGS cscope* ID
.PHONY: ctags ctags_clean cscope.files