#!/bin/sh
#
#	$Source: /u1/u1_sipb/src/lib/RCS/makewhatis,v $
#	$Author: root $
#	$Locker:  $
#	$Log:	makewhatis,v $
# Revision 1.2  85/02/09  10:22:29  root
# modified to look in sipb man pages
# 
# Revision 1.1  85/02/09  10:21:32  root
# Initial revision
# 
# 
# Revision 1.6  84/07/18  12:00:23  dgg
# Fixed syntax, removed /tmp/whatis2 with other junk files, added switch to
# allow it to happen in the current directory instead of in the running system,
# 
# Revision 1.5  84/07/17  17:09:35  dgg
# Tried to make it possible to send this thing a parameter if we want to
# do it in the current directory instead of in the running system.
# 
# Revision 1.4  84/07/10  09:26:07  jim
# Added use of ${DESTDIR} to specify root of /usr/lib/whatis file.
# 
# Revision 1.3  84/07/09  14:35:57  jim
# Changed # /bin/sh to #! /bin/sh
# 
# Revision 1.2  84/07/09  14:08:49  jim
# Comment out the cd /usr/man line and changed ed ---> ex
# 
# Revision 1.1  84/07/09  14:05:52  jim
# Initial revision
# 
#

rm -f /tmp/whatis /tmp/whatis$$ /tmp/whatis2
if [ $# = 0 ]
then
	cd /mit/web/man
fi
for i in man1  #man5 mann
do
	cd $i
	/usr/lib/getNAME *.*
	cd ..
done >/tmp/whatis
ex - /tmp/whatis <<\!
g/\\-/s//-/
g/\\\*-/s//-/
g/ VAX-11/s///
1,$s/.TH [^ ]* \([^ 	]*\).*	\([^-]*\)/\2(\1)	/
g/	 /s//	/g
w /tmp/whatis2
q
!
/usr/ucb/expand -24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100 /tmp/whatis2 | sort >/tmp/whatis$$
if [ $# = 0 ]
then
	/usr/ucb/unexpand -a /tmp/whatis$$ > /mit/web/man/whatis
	chmod 644 /mit/web/man/whatis
else
	/usr/ucb/unexpand -a /tmp/whatis$$ > whatis
	chmod 644 whatis
fi
rm -f /tmp/whatis /tmp/whatis$$ /tmp/whatis2
