#!/bin/sh
#	 LinkMy file...
# Try to find a version of each named file with $HOSTNAME_ or $HOSTYPE_ at the
# start of its name, or in the $HOSTNAME or $HOSTYPE subdirectory, and link it
# to the file name.  That is, if you have a file bar that  is  has  a  special
# version  for machine type foo, you may name the file foo_bar or foo/bar, and
# "LinkMy bar" will link it to bar.  Note that we use $HOSTNAME  and  $HOSTYPE
# from the environment, or we call hostype to set it.  If this fails, we fail.
# Also, this script doesn't handle file names with embedded '/' very well;  it
# is most useful for local files.
#
if [ ! -n "$HOSTYPE" -a -f  hostype ];then eval  `hostype -she`;fi
if [ ! -n "$HOSTYPE" -a -f .hostype ];then eval `.hostype -she`;fi
if [ ! -n "$HOSTYPE" ];then echo "### Can't figure out the HOSTYPE"; exit 1;fi
#
for f
do 
	if  [ -f  $HOSTNAME'_'$f ];then
		ln		$HOSTNAME'_'$f $f
		echo ln $HOSTNAME'_'$f $f
	elif [ -f  $HOSTNAME'/'$f ];then
		ln		$HOSTNAME'/'$f $f
		echo ln $HOSTNAME'/'$f $f
	elif [ -f  $HOSTYPE'_'$f ];then
		ln		$HOSTYPE'_'$f $f
		echo ln $HOSTYPE'_'$f $f
	elif [ -f  $HOSTYPE'/'$f ];then
		ln		$HOSTYPE'/'$f $f
		echo ln $HOSTYPE'/'$f $f
	elif [ -f ${SRCDIR-/src}/hdr/$HOSTNAME'_'$f ];then
		Lc ${SRCDIR-/src}/hdr/$HOSTNAME'_'$f .
		Lc ${SRCDIR-/src}/hdr/$HOSTNAME'_'$f $f
	elif [ -f ${SRCDIR-/src}/hdr/$HOSTYPE'_'$f ];then
		Lc ${SRCDIR-/src}/hdr/$HOSTYPE'_'$f .
		Lc ${SRCDIR-/src}/hdr/$HOSTYPE'_'$f $f
	else
		echo "###Can't find $HOSTYPE $f"
	fi
done
exit
