#!/bin/sh

# $PostgreSQL: pgsql/src/tools/make_ctags,v 1.12 2009/01/14 21:59:19 momjian Exp $

trap "rm -f /tmp/$$" 0 1 2 3 15
rm -f ./tags

cv=`ctags --version 2>&1 | grep Exuberant`

if [ -z "$cv" ]
then	FLAGS="-dt"
else	FLAGS="--c-types=+dfmstuv"
fi

find `pwd`/ \( -name _deadcode -prune \) -o \
		-type f -name '*.[chyl]' -print |
	xargs ctags "$FLAGS" -a -f tags

if [ -z "$cv" ]
then
	LC_ALL=C
	export LC_ALL
	sort tags >/tmp/$$ && mv /tmp/$$ tags
fi

find . \( -name 'CVS' -prune \) -o \( -name .git -prune \) -o -type d -print |
while read DIR
do	[ "$DIR" != "." ] && ln -f -s `echo "$DIR" | sed 's;/[^/]*;/..;g'`/tags "$DIR"/tags
done
