#!/bin/sh
#
#   This file prompts for command files directory.

#   If the install architecture is not the selected architecture,
#   prompt to copy command files at all.

if [ ! -f $ITMPDIR/CommandPrompt ]; then
   touch $ITMPDIR/CommandPrompt
   
   if [ .$INSTALLARCH != .$selected_arch ]; then
      printm GenerateCommandFiles $selected_arch $INSTALLARCH $TARGET
      promptname=GenerateCommandFiles
      curans="x"
      while [ .$curans != .n -a .$curans != .c ]; do
         defanswer=c; . printp
      done
      CMDDIR=""
      export CMDDIR
   fi 

   if [ .$curans != .n ]; then
      while [ .$CMDDIR = "." ]; do
         printm CommandFiles $selected_arch $TARGET
         promptname=CommandFiles
         if [ ! -f $ITMPDIR/DetCommandDir ]; then
            if [ .$def_cmddir = . ]; then
               defanswer="/usr/local/bin"
            else
               defanswer=$def_cmddir
            fi
         else
            defanswer=`cat $ITMPDIR/DetCommandDir`
         fi
         . printp
         cdir=$curans

         if [ ! -d "$cdir" ]; then
            printm NoCommandDir $cdir
            promptname=NoCommandDir; defanswer=c; . printp
            if [ ."$curans" = .c ]; then
               if [ -d "$cdir" ]; then
                  CMDDIR=$cdir
                  export CMDDIR
               fi
            fi
         else
            CMDDIR=$cdir
            export CMDDIR
         fi

      done
   fi
        if [ ! -f $ITMPDIR/CommandDir ]; then
           echo $CMDDIR > $ITMPDIR/CommandDir
           echo "var cmddir $CMDDIR" >> $ITMPDIR/InstEnv
        fi
fi
