#!/bin/sh
# A BSD-like install script for SYSV systems.
# Written by Phil Hochstetler, phil@sequent.com
# Modified by  Larry Jones larry.jones@sdrc.com
  
chmodcmd=""
chowncmd=""
chgrpcmd=""
stripcmd=""
FILE=""
DIR=""
while [ X"$1" != X ]; do
    case $1 in
	-m) chmodcmd="chmod $2"
	    shift
	    shift
	    continue;;
	-o) chowncmd="chown $2"
	    shift
	    shift
	    continue;;
	-g) chgrpcmd="chgrp $2"
	    shift
	    shift
	    continue;;
	-s) stripcmd="strip"
	    shift
	    continue;;
	-*) echo "$0: unknown option $1" >&2
	    shift
	    continue;;
	*)  if [ X"$FILE" = X ]
		then FILE=$1
		else DIR=$1
	    fi
	    shift
    esac
done

if [ X"$FILE" = X -o X"$DIR" = X ]; then
	echo "Usage: install [-m ddd] [-o uid] [-g gid] [-s] srcfile dstdir" 1>&2
fi

if [ ! -d "$DIR" ]; then
	mkdir $DIR
fi
dst=$DIR/`basename $FILE`
rm -f $dst
cp $FILE $dst
if [ X"$chowncmd" != X ]; then $chowncmd $dst; fi
if [ X"$chgrpcmd" != X ]; then $chgrpcmd $dst; fi
if [ X"$stripcmd" != X ]; then $stripcmd $dst; fi
if [ X"$chmodcmd" != X ]; then $chmodcmd $dst; fi

exit 0
