#!/bin/sh
# A script to install all files of the XWho-system considering the architecture
# of the binaries.

client=src/xwho
server=src/xwhod
appdef=src/XWho.ad
manpage=src/xwho.man
config=config/xwho.config.sample
defrc=config/xwhorc.default.sample

DIST=/usr/local/dist/DIR/X11/R5/local/xwho

if [ ! -w $client ] || [ ! -w $server ]
then
	echo "$0: $client or $server not writeable"
fi
if [ ! -r $appdef ]
then
	echo "$0: $appdef not readable"
fi
if [ ! -r $manpage ]
then
	echo "$0: $manpage not readable"
fi
if [ ! -r $config ]
then
	echo "$0: $config not readable"
fi
if [ ! -r $defrc ]
then
	echo "$0: $defrc not readable"
fi

strip $client $server
chgrp dist $client $server
chmod 751 $client $server

if [ -x /lib/cpp ]
then
	CPP=/lib/cpp
else
	if [ -x /usr/ccs/lib/cpp ]
	then
		CPP=/usr/ccs/lib/cpp
	else
		echo "$0: cpp not found"
		exit 1
	fi
fi
$CPP $appdef | sed -e 's/^#.*//' >/tmp/XWho

case `uname` in

'HP-UX')
	for r in hphalle0 hpschlichter18 hphalle1 hphalle2 hphalle3 hphalle4 hphalle5 hphalle6 hphalle7 hphalle8 hphalle9 hphalle10
	do
		echo "*** $r"
		rsh $r mv $DIST/xwho $DIST/xwho.last
		rsh $r mv $DIST/xwhod $DIST/xwhod.last
		rcp $client $server $r:$DIST

		rcp /tmp/XWho $r:$DIST
		rcp $manpage $r:$DIST/xwho.1
		rcp $config $r:$DIST/xwho.config
		rcp $defrc $r:$DIST/xwhorc.default
	done

	echo "*** done"
	;;

'SunOS' | 'ULTRIX' | 'IRIX')
	mv $DIST/xwho $DIST/xwho.last
	mv $DIST/xwhod $DIST/xwhod.last
	cp $client $server $DIST
	cp /tmp/XWho $DIST
	cp $manpage $DIST/xwho.1
	cp $config $DIST/xwho.config
	cp $defrc $DIST/xwhorc.default

	echo "*** done"
	;;

*)
	echo "$0: can't install from this system"

esac

rm /tmp/XWho
