#**********************************************************************#
#*                                                                    *#
#* Copyright (c) 2001 by Sun Microsystems, Inc.                       *#
#* All rights reserved.                                               *#
#*                                                                    *#
#**********************************************************************#


uname -a | grep AIX >$DEVNULL
COND=$?
if [ $COND = 0 ]
then
  cat $COBDIR/cobver | grep 'cobol v3\.2' >$DEVNULL
  COND=$?
  if test $COND = 0;
    then
    echo "s%RDBMSFLAG=%RDBMSFLAG= -DAIXMF32 %" >>/tmp/config.current
  fi
  cat $COBDIR/cobver | grep 'cobol v4\.' >$DEVNULL
  COND=$?
  if test $COND = 0;
    then
    echo "s%RDBMSFLAG=%RDBMSFLAG= -DAIXMF32 %" >>/tmp/config.current
  fi
fi
if [ "a$KIXCLIROOT" != "a" ]
then
  echo "s%^LDFLAGS=%LDFLAGS= -L. -lebmexci -L $(KIXCLIROOT)/lib -lcclapi %" >>/tmp/config.current
fi
echo "s%BINDIR=%BINDIR=$WORKDIR%" >>/tmp/config.current
if [ "$appl_lang_cob_acu" = "$SELECTED" ]
then
  echo "s%LANGOBJECTS%$(ACUOBJECTS)%" >>/tmp/config.current
  echo "s%^MBMLANG=.*%MBMLANG=-llang_acu%" >>/tmp/config.current
  echo "s%^RTCOMPILE=%RTCOMPILE=$(ACUCOMPILE)%" >>/tmp/config.current
  echo "s%^LANGLIBS=%LANGLIBS=$(ACULIBS)%" >>/tmp/config.current
  echo "s%^CFLAGS=%CFLAGS=-DACUCOBOL %" >>/tmp/config.current
fi
if [ "$appl_lang_cob_mf" = "$SELECTED" ]
then
  echo "s%LANGOBJECTS%$(MFOBJECTS)%" >>/tmp/config.current
  echo "s%^MBMLANG=.*%MBMLANG=-llang_mf%" >>/tmp/config.current
  echo "s%^RTCOMPILE=%RTCOMPILE=$(MFCOMPILE)%" >>/tmp/config.current
fi
sed -f /tmp/config.current ./input.make  >$WORKDIR/makefile.rtsfs
rm /tmp/config.current
echo "RTS install directory $WORKDIR updated."
echo "Do you want to build the COBOL runtime system ? [Y/N]"
read risp
case $risp in
  Y|y)
    if [ "$SKILLED" = "+" ]
    then
      $KIXCLS
    fi
    (cd $WORKDIR; rm -f make.out;
    make -f makefile.rtsfs clean;
    make -f makefile.rtsfs 2>&1 | tee make.out)
    echo "Type return to continue"
    read risp
  ;;
  *)
    echo "# Warning: The COBOL runtime system has not been built."
    echo "# To build the COBOL runtime system you must type the following commands:"
    echo "#"
    echo "#-------------------------------------------------------------------------------"
    echo "# cd $WORKDIR"
    echo "# make -f makefile.rtsfs clean"
    echo "# make -f makefile.rtsfs"
    echo "#-------------------------------------------------------------------------------"
    echo "#"
    echo "Type return to continue"
    read risp
  ;;
esac
exit 0
