#! /bin/sh

# installmodule: installs binfile and initfile in module-directory

if [ "$3" = "" ] ; then
  echo 'usage: installmodule binfile initfile module-directory'
  exit 1
fi

binfilepath=$1
initfilepath=$2
moduledir=$3

if [ ! -d "$moduledir" ]; then
    # Make all necessary directories.
    Ds="$moduledir"
    D="$moduledir"
    while
	D=`expr "$D//" "\(.*\)/[^/]*//"`
	test ! -d "$D"
    do
	Ds="$D $Ds"
    done
    mkdir "$Ds"
fi


binfile=`basename $binfilepath`
initfile=`basename $initfilepath`

if [ -f $moduledir/$binfile ] ; then
  /bin/rm $moduledir/$binfile
fi
if [ -f $moduledir/$initfile ] ; then
  /bin/rm $moduledir/$initfile
fi
/bin/cp $initfilepath $binfilepath $moduledir
# don't strip here, only strip when packing up for distribution
# strip $moduledir/$binfile
chmod 775 $moduledir/$binfile
chmod 664 $moduledir/$initfile
