#!/bin/sh
#
#     @(#)gigbatch	31.1 96/04/03
#
# script for generating a batch job to render still files

TMPDIR=/usr/tmp/gigb$$
mkdir -p $TMPDIR
export TMPDIR

GIGSA="gig_sa"
GIGARG=""
intfiles="intjob giglist videoback gigbatch0 "

if [ -x $GIG_D_BIN/$GIGSA.mips2 ]
then
  if hinv -t cpu | fgrep -s R4 
  then
    GIGSA=$GIGSA.mips2
  fi
fi

if [ -x $GIG_D_BIN/gig_saULTRA ]
then
  if uname -a | fgrep -s sun4u 
  then
    GIGSA=gig_saULTRA
  fi
fi

/bin/rm -f $TMPDIR/$$.int > /dev/null

set -- `getopt vr:i:o:dp: $*`
if [ $? != 0 -o $# -eq 1 ]
then
  echo usage: gigbatch [option] stillname1 stillname2 ... 
  echo options:
  echo "      -i intercolfile"
  echo "      -r rendercommand"
  echo "      -o outputcommand"
  echo "      -v render verbose"
  echo "      -p projectname"
  echo eg.
  echo "      gigbatch -r size:100x100:25x25+50x50 -r alias:2,-2 -v -i extra test"
  echo "      gigbatch -o path:/usr/tmp -o basename:hallo -o extension:tga test"
  echo ""
  echo " alias:2,-2   renders video setting from render menu:"
  echo "               |---|---|---|---|"
  echo "               |   |   |   | h | 0    h = high"
  echo "           |---|---|---|---|---|"
  echo "           |   |   |   |   |   | 1    v = video"
  echo "       |---|---|---|---|---|---|"
  echo "       |   |   |   |   | v |   | 2    d = default"
  echo "   |---|---|---|---|---|---|---|"
  echo "   | l |   |   | d |   |   |   | 3    l = low"
  echo "   |---|---|---|---|---|---|---|"
  echo "     3   2   1   0  -1  -2  -3"
  echo ""
  exit
fi
for i in $*
do
  case $i in
  -d)       GIGARG="$GIGARG -d"; shift;;
  -v | -V)  GIGARG="$GIGARG -r verbose"; shift;;
  -r)       GIGARG="$GIGARG -r $2"; shift 2;;
  -o)       GIGARG="$GIGARG -o $2"; shift 2;;
  -p)       GIGARG="$GIGARG -p $2"; shift 2;;
  -i)       intfiles="$intfiles $2"; shift 2;;
  --)       shift; break;;
  esac
done

while [ $# != 0 ] 
do
  echo addbatch \(\"$1\"\ \)\; >> $TMPDIR/$$.int;
  shift
# compatibility with older gigbatch that allowed intercol files after 
# first batchname
  if [ $# != 0 ]
  then
    if test -r $1.int;
    then
      intfiles=${intfiles}" "$1
      shift
    fi
  fi
done
$GIGSA $GIGARG $intfiles $TMPDIR/$$ gigbatch1
/bin/rm -r $TMPDIR
