#!/bin/csh 
sed "s%^packagedir =.*%packagedir = '$cwd/';%" < makeframe.m > tmp
/bin/rm makeframe.m
mv tmp makeframe.m

sed "s%^packagedir =.*%packagedir = '$cwd/';%" < makemovie.m > tmp
/bin/rm makemovie.m
mv tmp makemovie.m

sed "s%^packagedir =.*%packagedir = '$cwd/';%" < mpeg_read.m > tmp
/bin/rm mpeg_read.m
mv tmp mpeg_read.m

chmod a+r *
setenv  NOEXECUTABLES 1

if (-f  ./lnx86.tgz) then
  setenv  NOEXECUTABLES 0
  tar xzf lnx86.tgz
  /bin/rm lnx86.tgz
  echo "$user" | mail -s "movie package installed for Linux"\
	andreas@familie-wiegmann.de
  echo " "
  echo "I installed the movie package successfully for Linux."
endif

if (-f  ./alpha.tgz) then
  setenv  NOEXECUTABLES 0
  tar xzf alpha.tgz
  /bin/rm alpha.tgz
  echo "$user" | mail -s "movie package installed for ALPHA"\
	andreas@familie-wiegmann.de
  echo " "
  echo "I installed the movie package successfully for ALPHA."
endif

if (-f  ./hp700.tgz) then
  setenv  NOEXECUTABLES 0
  tar xzf hp700.tgz
  /bin/rm hp700.tgz
  echo "$user" | mail -s "movie package installed for HP700"\
	andreas@familie-wiegmann.de
  echo " "
  echo "I installed the movie package successfully for HP700."
endif

if (-f  ./sparc.tgz) then
  setenv  NOEXECUTABLES 0
  tar xzf sparc.tgz
  /bin/rm sparc.tgz
  echo "$user" | mail -s "movie package installed for SPARC"\
	andreas@familie-wiegmann.de
  echo " "
  echo "I installed the movie package successfully for SPARC."
endif

if (-f  ./solaris.tgz) then
  setenv  NOEXECUTABLES 0
  tar xzf solaris.tgz
  /bin/rm solaris.tgz
  echo "$user" | mail -s "movie package installed for SOLARIS"\
	andreas@familie-wiegmann.de
  echo " "
  echo "I installed the movie package successfully for SOLARIS."
endif

if (-f  ./sgi.tgz) then
  setenv  NOEXECUTABLES 0
  tar xzf sgi.tgz
  /bin/rm sgi.tgz
  echo "$user" | mail -s "movie package installed for SGI"\
	andreas@familie-wiegmann.de
  echo " "
  echo "I installed the movie package successfully for SGI."
endif

if ($NOEXECUTABLES) then
  if ((-d ./LNX86) || (-d ./ALPHA) || (-d ./SGI) || (-d ./HP700) || (-d ./SUN4) || (-d ./SOL2)) then
    echo " "
    echo "WARNING: I didn't find any tgz file with executables."
    echo " "
    echo "       But I did detect a directory with executables."
    echo "       In principle, this package should be compatible"
    echo "       with older executables. However, if you experience"
    echo "       any problems, please make sure to transfer one of"
    echo " "
    echo "       alpha.tgz, hp700.tgz, sgi.tgz, solaris.tgz,"
    echo "       lnx86.tgz and/or sparc.tgz"
    echo " "
    echo "       from http://vicmasoft.com/ALWsMMs/index.html"
    echo "       and MAKE SURE TO MOVE IT TO THIS DIRECTORY."
    echo " "
    echo "       Then run $0 again. If you continue to experience"
    echo "       problems, contact andreas@familie-wiegmann.de."
    echo " "
  else	
    echo " "
    echo "ERROR: I didn't find any tgz file with executables."
    echo "       Please make sure to transfer one of" 
    echo " "
    echo "       alpha.tgz, hp700.tgz, sgi.tgz, solaris.tgz,"
    echo "       lnx86.tgz and/or sparc.tgz"
    echo " "
    echo "       from http://vicmasoft.com/ALWsMMs/index.html"
    echo "       and MAKE SURE TO MOVE IT TO THIS DIRECTORY."
    echo " "
    echo "       Then run $0 again. If you continue to see this"
    echo "       message, contact andreas@familie-wiegmann.de."
    echo " "
  endif
endif
