systags.sh revision 1541
11541Srgrimes#! /bin/sh
21541Srgrimes#
31541Srgrimes# Copyright (c) 1992, 1993
41541Srgrimes#	The Regents of the University of California.  All rights reserved.
51541Srgrimes#
61541Srgrimes# Redistribution and use in source and binary forms, with or without
71541Srgrimes# modification, are permitted provided that the following conditions
81541Srgrimes# are met:
91541Srgrimes# 1. Redistributions of source code must retain the above copyright
101541Srgrimes#    notice, this list of conditions and the following disclaimer.
111541Srgrimes# 2. Redistributions in binary form must reproduce the above copyright
121541Srgrimes#    notice, this list of conditions and the following disclaimer in the
131541Srgrimes#    documentation and/or other materials provided with the distribution.
141541Srgrimes# 3. All advertising materials mentioning features or use of this software
151541Srgrimes#    must display the following acknowledgement:
161541Srgrimes#	This product includes software developed by the University of
171541Srgrimes#	California, Berkeley and its contributors.
181541Srgrimes# 4. Neither the name of the University nor the names of its contributors
191541Srgrimes#    may be used to endorse or promote products derived from this software
201541Srgrimes#    without specific prior written permission.
211541Srgrimes#
221541Srgrimes# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
231541Srgrimes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241541Srgrimes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251541Srgrimes# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
261541Srgrimes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
271541Srgrimes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
281541Srgrimes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
291541Srgrimes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
301541Srgrimes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311541Srgrimes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321541Srgrimes# SUCH DAMAGE.
331541Srgrimes#
341541Srgrimes#	@(#)systags.sh	8.1 (Berkeley) 6/10/93
351541Srgrimes#
361541Srgrimes# systags.sh - construct a system tags file using dependence relations
371541Srgrimes#	in a .depend file
381541Srgrimes#
391541Srgrimes# First written May 16, 1992 by Van Jacobson, Lawrence Berkeley Laboratory.
401541Srgrimes#
411541Srgrimes# from: $Header: systags.sh,v 1.7 92/07/12 08:18:21 torek Exp $
421541Srgrimes
431541Srgrimesrm -f tags tags.tmp tags.cfiles tags.sfiles tags.hfiles
441541SrgrimesMACHINE=`machine`
451541Srgrimessed -e "s,\./machine/,../../$MACHINE/include/,g" \
461541Srgrimes    -e 's,[a-z][^/ 	]*/\.\./,,g' .depend | awk   '{
471541Srgrimes		for (i = 1; i <= NF; ++i) {
481541Srgrimes			t = substr($i, length($i) - 1)
491541Srgrimes			if (t == ".c")
501541Srgrimes				cfiles[$i] = 1;
511541Srgrimes			else if (t == ".h")
521541Srgrimes				hfiles[$i] = 1;
531541Srgrimes			else if (t == ".s")
541541Srgrimes				sfiles[$i] = 1;
551541Srgrimes		}
561541Srgrimes	};
571541Srgrimes	END {
581541Srgrimes		for (i in cfiles)
591541Srgrimes			print i > "tags.cfiles";
601541Srgrimes		for (i in sfiles)
611541Srgrimes			print i > "tags.sfiles";
621541Srgrimes		for (i in hfiles)
631541Srgrimes			print i > "tags.hfiles";
641541Srgrimes	}'
651541Srgrimes
661541Srgrimesctags -t -d -w `cat tags.cfiles tags.hfiles tags.sfiles`
671541Srgrimesegrep -o "^ENTRY\(.*\)|^ALTENTRY\(.*\)" `cat tags.sfiles` | \
681541Srgrimes    sed "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3	\1	/^\2(\3\4$/;" >> tags
691541Srgrimes
701541Srgrimesmv tags tags.tmp
711541Srgrimessort -u tags.tmp > tags
721541Srgrimesrm tags.tmp tags.cfiles tags.sfiles tags.hfiles
73