#!/bin/sh

#This can be 'sprsh', 'wine' or 'cygwin'
REMOTE_METHOD=sprsh

# Choose 'rntcc' for Watcom or 'rntcl' for Microsoft VC++
# (Make sure VC++ is before Watcom in your path!)
CC=${CC-rntcl}

# Important!
# Please be sure that you have the line 'veto oplock files = /*/' in your
# smb.conf if NTDRIVE is a samba file system.

# Edit
NTHOST=${NTHOST-10.0.5.13}
NTDRIVE=${NTDRIVE-k:}

# Edit
#NTHOST=10.0.5.10
#NTDRIVE='k:'

#NTHOST=localhost
#NTDRIVE='d:'

# What dir on the UNIX machine is on $NTDRIVE ?
# This variable MUST NOT end with a slash.
NTMOUNT=

# Use Simple Pike Remote SHell?
USE_SPRSH=yes

# Port for sprsh
NTPORT=4711

#These are only used if you use wine
watcom=D:\\CDROM
INCLUDE="$watcom\\H;$watcom\\H\\NT"

case "/$CC" in
  */rntcl)
    MSVC='j:\winshare\vc98'
    local='j:\winshare\local'
    REMOTE_VARIABLES="
path=$MSVC\\bin;
include=$MSVC\\Include;$local\\include
lib=$MSVC\\Lib;$local\\lib
"
    export REMOTE_VARIABLES
  ;;

  */rntcc)
    watcom='j:\winshare\WATCOM'
    local='j:\winshare\WATCOM\local'
    REMOTE_VARIABLES="
path=$watcom\\binnt;$watcom\\binw;
include=$watcom\\h;$watcom\\h\\nt;$local\\h
lib=$watcom\\lib386;$local\\lib
"
    export REMOTE_VARIABLES
  ;;
esac


# Don't edit anything below this point..

case /$0 in
  */init_nt)
    # We were executed we can find the path!
    base=`echo $0 | sed -e 's@/init_nt@@'`
    base=`(test "x$base" != "x" && cd $base ; /bin/pwd)`
  ;;

  *)
    # We were sourced, we cannot find the path...
    base=`pwd`
  ;;
esac

if [ "x$OSTYPE" = xcygwin32 ]; then
  REMOTE_METHOD=cygwin
  driveletter=`echo $base | sed -e 's@^//\(.\)/.*@\1@`
  if [ "x$driveletter" != "x" ]; then
    NTDRIVE=${driveletter}:
    NTMOUNT="//$driveletter"
  fi
  mkdir $base/cygtools 2>/dev/null || :
  (
    cd $base/tools
    cp rntcc rntcl ar nm ranlib uname bash-fixup sprsh lib lib.pike $base/cygtools || :
  )
  SHELL=bash
  
  NT_TOOL_PATH=$base/cygtools
else
  NT_TOOL_PATH=$base/tools
fi



export NT_TOOL_PATH

if [ ! -d "$NT_TOOL_PATH" ]; then
  echo Unable to find NT tools!
  return
  exit
fi

case :$PATH: in
   *:$NT_TOOL_PATH:*) ;;
   *) PATH=$NT_TOOL_PATH:$PATH ;;
esac

NTTOOLS=$NT_TOOL_PATH/lib


if [ "x$NTMOUNT" = x ]; then
  MNTREPLACE=""
  PIKE_PATH_TRANSLATE=""
else
  MNTREPLACE="s@$NTMOUNT@@g
"
  PIKE_PATH_TRANSLATE="s!^$NTMOUNT!$NTDRIVE!"
fi
IFS=' 	

'

export NTHOST NTDRIVE NTCC CC PATH NTTOOLS MNTREPLACE MNTREPLACE 
export NTPORT USE_SPRSH NTMOUNT IFS REMOTE_METHOD watcom INCLUDE
export NT_TOOL_PATH NTCOMPILER PIKE_PATH_TRANSLATE

case /$SHELL-$TERM in
   */bash-xterm)
     PROMPT_COMMAND="echo -n ]2\; $REMOTE_METHOD NT compile ]1\; $CC"
     export PROMPT_COMMAND
   ;;
esac

case /$0 in
  */init_nt)
    case /$SHELL in
      */bash)
        exec $SHELL -rcfile $NT_TOOL_PATH/bash-fixup
      ;;
      *)
        exec $SHELL
      ;;
    esac
  ;;
esac
