1#!/bin/sh
2
3# src/tools/make_ctags
4
5trap "rm -f /tmp/$$" 0 1 2 3 15
6rm -f ./tags
7
8IS_EXUBERANT=""
9ctags --version 2>&1 | grep Exuberant && IS_EXUBERANT="Y"
10
11# List of kinds supported by Exuberant Ctags 5.8
12# generated by ctags --list-kinds
13# --c-kinds was called --c-types before 2003
14#    c  classes
15#    d  macro definitions
16#    e  enumerators (values inside an enumeration)
17#    f  function definitions
18#    g  enumeration names
19#    l  local variables [off]
20#    m  class, struct, and union members
21#    n  namespaces
22#    p  function prototypes [off]
23#    s  structure names
24#    t  typedefs
25#    u  union names
26#    v  variable definitions
27#    x  external and forward variable declarations [off]
28
29if [ "$IS_EXUBERANT" ]
30then	FLAGS="--c-kinds=+dfmstuv"
31else	FLAGS="-dt"
32fi
33
34# this is outputting the tags into the file 'tags', and appending
35find `pwd`/ -type f -name '*.[chyl]' -print |
36	xargs ctags -a -f tags "$FLAGS"
37
38# Exuberant tags has a header that we cannot sort in with the other entries
39# so we skip the sort step
40# Why are we sorting this?  I guess some tag implementation need this,
41# particularly for append mode.  bjm 2012-02-24
42if [ ! "$IS_EXUBERANT" ]
43then	LC_ALL=C
44	export LC_ALL
45	sort tags >/tmp/$$ && mv /tmp/$$ tags
46fi
47
48find . \( -name 'CVS' -prune \) -o \( -name .git -prune \) -o -type d -print |
49while read DIR
50do	[ "$DIR" != "." ] && ln -f -s `echo "$DIR" | sed 's;/[^/]*;/..;g'`/tags "$DIR"/tags
51done
52