Make some error strings more generic
[pgsql.git] / src / tools / make_ctags
blobad027c71e3ddeff2e28f0d51f6feca12e8e64c91
1 #!/bin/sh
3 # src/tools/make_ctags [-e] [-n]
4 # If -e is specified, generate tags files for emacs.
5 # If -n is specified, don't create symbolic links of tags file.
6 usage="Usage: $0 [-e][-n]"
7 if [ $# -gt 2 ]
8 then echo $usage
9 exit 1
12 EMACS_MODE=
13 NO_SYMLINK=
14 IS_EXUBERANT=
15 PROG="ctags"
16 TAGS_OPT="-a -f"
17 TAGS_FILE="tags"
18 FLAGS=
19 IGNORE_IDENTIFIES=
21 while [ $# -gt 0 ]
23 if [ $1 = "-e" ]
24 then EMACS_MODE="Y"
25 elif [ $1 = "-n" ]
26 then NO_SYMLINK="Y"
27 else
28 echo $usage
29 exit 1
31 shift
32 done
34 if [ ! "$EMACS_MODE" ]
35 then (command -v ctags >/dev/null) || \
36 { echo "'ctags' program not found" 1>&2; exit 1; }
39 ctags --version 2>&1 | grep Exuberant && IS_EXUBERANT="Y"
41 if [ "$EMACS_MODE" ]
42 then TAGS_FILE="TAGS"
43 if [ "$IS_EXUBERANT" ]
44 then PROG="ctags -e"
45 else (command -v etags >/dev/null) || \
46 { echo "neither 'etags' nor exuberant 'ctags' program not found" 1>&2; exit 1; }
47 PROG="etags"
48 TAGS_OPT="-a -o"
52 # List of kinds supported by Exuberant Ctags 5.8
53 # generated by ctags --list-kinds
54 # --c-kinds was called --c-types before 2003
55 # c classes
56 # d macro definitions
57 # e enumerators (values inside an enumeration)
58 # f function definitions
59 # g enumeration names
60 # l local variables [off]
61 # m class, struct, and union members
62 # n namespaces
63 # p function prototypes [off]
64 # s structure names
65 # t typedefs
66 # u union names
67 # v variable definitions
68 # x external and forward variable declarations [off]
70 if [ "$IS_EXUBERANT" ]
71 then FLAGS="--c-kinds=+dfmstuv"
72 elif [ ! "$EMACS_MODE" ]
73 then FLAGS="-dt"
76 # Use -I option to ignore a macro
77 if [ "$IS_EXUBERANT" ]
78 then IGNORE_IDENTIFIES="-I pg_node_attr+"
81 trap "ret=$?; rm -rf /tmp/$$; exit $ret" 0 1 2 3 15
82 rm -f ./$TAGS_FILE
84 # this is outputting the tags into the file 'tags', and appending
85 find `pwd`/ \( -name tmp_install -prune -o -name tmp_check -prune \) \
86 -o \( -name "*.[chly]" -o -iname "*makefile*" -o -name "*.mk" -o -name "*.in" \
87 -o -name "*.sql" -o -name "*.p[lm]" \) -type f -print |
88 xargs $PROG $TAGS_OPT $TAGS_FILE $FLAGS $IGNORE_IDENTIFIES
90 # Sorting non-Exuberant ctags file allows for fast searching of the tags file.
91 # Since etags file has a header that we cannot sort in with the other entries
92 # we skip the sort step.
93 if [ ! "$IS_EXUBERANT" -a ! "$EMACS_MODE" ]
94 then LC_ALL=C
95 export LC_ALL
96 sort $TAGS_FILE >/tmp/$$ && mv /tmp/$$ $TAGS_FILE
99 # create symbolic links
100 if [ ! "$NO_SYMLINK" ]
101 then find . \( -name 'CVS' -prune \) -o \( -name .git -prune \) -o -type d -print |
102 while read DIR
103 do [ "$DIR" != "." ] && ln -f -s `echo "$DIR" | sed 's;/[^/]*;/..;g'`/$TAGS_FILE "$DIR"/$TAGS_FILE
104 done