#!/bin/sh
# ==++==
# 
#   
#    Copyright (c) 2002 Microsoft Corporation.  All rights reserved.
#   
#    The use and distribution terms for this software are contained in the file
#    named license.txt, which can be found in the root of this distribution.
#    By using this software in any fashion, you are agreeing to be bound by the
#    terms of this license.
#   
#    You must not remove this notice, or any other, from this software.
#   
# 
# ==--==

# Make command errors fatal
set -e

if test X"${TARGETCOMPLUS}" = "X" 
then
echo "ERROR: The TARGETCOMPLUS environment variable isn't set."
echo "Please source the appropriate env.sh or env.csh file."
exit 1
fi

mkdir -p ${TARGETCOMPLUS}

# Run ./configure if this is a clean build or if we don't think
# ./configure has been run before.
if [ X"$1" = "X-c" ] || ! [ -f ${ROTOR_DIR}/config.status ]
then
  if test "$NTDEBUG" = "ntsdnodbg"
  then
     ./configure -disable-debug
  else
     ./configure
  fi
fi

cd ${ROTOR_DIR}/pal/unix
if test X"$1" = "X-c"
then
make clean
make depend
fi
make

cd ${ROTOR_DIR}/tools/nmake
if test X"$1" = "X-c"
then
make clean
fi
make

cd ${ROTOR_DIR}/tools/cppmunge
if test X"$1" = "X-c"
then
make clean
fi
make

cd ${ROTOR_DIR}/tools/binplace
if test X"$1" = "X-c"
then
make clean
fi
make

cd ${ROTOR_DIR}/tools/build
if test X"$1" = "X-c"
then
make clean
fi
make

cd ${ROTOR_DIR}/tools/resourcecompiler
build $*

cd ${ROTOR_DIR}/palrt/src
build $*

cd ${CORBASE}/src
build $*

cd ${ROTOR_DIR}/fx/src
build $*

cd ${ROTOR_DIR}/managedlibraries
build $*

cd ${ROTOR_DIR}/jscript
build $*

cd ${ROTOR_DIR}/samples
build $*
