echo " "
echo "This shell file builds the RMCOBOL runtime (runcobol) along with"
echo "the intermediate modules needed to create the runtime system."
echo " "
echo " "
echo "The module liosys21.c must be compiled according to the type of"
echo "record-locking supported by your system."
echo " "
echo "Enter the number corresponding to the type of record locking function"
echo "your system supports:"
echo " "
echo "  1) No record locking supported  2) locking()  3) lockf()  4) fcntl()"
read locktype
if (test $locktype)
  then if (test $locktype = "4")
         then  LIOFLAG=LIOFLAG=-DFCNTL
         elif (test $locktype = "3")
         then  LIOFLAG=LIOFLAG=-DLOCKF
         elif (test $locktype = "2")
         then  LIOFLAG=LIOFLAG=-DLOCKING
         elif (test $locktype != "1")
	 then echo "Invalid selection"
	      exit
       fi
fi
echo " "
echo "The module runsys21.c must be compiled according to the type of"
echo "tty interface calls supported:"
echo " "
echo "    1) ioctl() (sys 3 or later)   2) sgtty() (ver 7 or Berkeley)"
read systype
if (test $systype)
then if (test $systype = "2")
     then  SYSFLAG=SYSFLAG=-DVER7
     elif (test $systype != "1")
     then echo "Invalid selection"
	  exit
     fi
fi
echo " "
echo "The module runinf21.c must be compiled according to the type of"
echo "terminal library package:"
echo " "
echo "    1) termlib (termcap)      2) curses (terminfo)"
read trmtype
LINKRUN=linkrun.term
if (test $trmtype)
then if (test $trmtype = "2")
     then  TRMFLAG=TRMFLAG=-DCURSES
           LINKRUN=linkrun.curs
     elif (test $trmtype != "1")
     then echo "Invalid selection"
	  exit
     fi
fi
echo " "
echo "Creating the RM/COBOL Runtime (runcobol)"
make -f makerun  "CFLAGS=-O" $LIOFLAG $SYSFLAG $TRMFLAG
if test $? != "0"
then echo "Failed to create runcoboli.a"
     if test -f runcoboli.a
        then rm runcoboli.a
     fi
     exit 1
fi
echo " "
echo "sh linkrun"
sh $LINKRUN
if test $? != "0"
then echo "Failed to create runcobol"
     exit 1
fi
echo "runcobol has been successfully generated"
echo "Now preparing the runtime directory for distribution . . ."
echo " "
cp $LINKRUN ../runtime/linkrun
ln runcobol ../runtime
ln install ../runtime
ln runconfig.c ../runtime
ln runconfig.o ../runtime
ln sub.c ../runtime
ln sub.o ../runtime
if test -f runcoboli.a
  then ln runcoboli.a ../runtime
  else ln runcoboli.o ../runtime
fi
ls -l ../runtime
echo " "
echo "You are now ready to install the compiler and runtime."
