#!/bin/sh
# Some versions of make (ULTRIX?) handle if tests inside Makefiles poorly.
# This script is run automatically by make; don't run it by hand.

# install.sh 0 directory   - creates the directory if not present
# install.sh 1 directory   - ditto, but sets permissions to 777 (contrib)
# install.sh 2 site        - copies Yorick/include,doc files to site
# install.sh 3 site        - conditionally destroys site/include,doc
# install.sh 4 dir prog    - conditionally copy prog to dir/yorick

case "$1" in
  "0") shift
       for dir in $*; do
         if test ! -d $dir; then mkdir $dir; fi
       done;;
  "1") if test ! -d $2; then mkdir $2; chmod 777 $2; fi;;
  "2") if test `pwd` != `cd $2;pwd`; then
         cp include/*.i $2/include
         cp include/README $2/include
         cp doc/* $2/doc; fi;;
  "3") if test `pwd` != `cd $2;pwd`; then
         rm -f -r $2/include $2/doc; fi;;
  "4") if test -r $3; then cp $3 $2/yorick; fi;;
  *)   echo "(IMPOSSIBLE ERROR) install.sh script called incorrectly" ;;
esac

exit 0
