#! /bin/sh

# This script starts a new shell and sets all enviroment variables, which
# are necessary for building the examples of the Office Development Kit.
# The Script was developed for the operating systems Solaris and Linux.
# Before the script could be executed the following variables have to be
# adjusted:

# Installation directory of the Software Development Kit.
# Example: SDK_HOME=/work/odk641
SDK_HOME=

# Office installation directory.
# Example: OFFICE_HOME=/opt/staroffice6.0
OFFICE_HOME=

# Directory of the make command.
# Example: SDK_MAKE=/usr/bin
SDK_MAKE=

# Directory of the C++ tools.
# Example: SDK_CPP_HOME=/usr/bin
SDK_CPP_HOME=

# Java installation directory.
# Example: SDK_JAVA_HOME=/usr/local/j2sdk1.4.0
SDK_JAVA_HOME=

# Environment variable to enable auto deployment of example components
# Example: SDK_AUTO_DEPLOYMENT=YES
# SDK_AUTO_DEPLOYMENT=YES
# export SDK_AUTO_DELOYMENT


# ANT installation directory.
# Example: SDK_ANT=/windows/daten/moving/jakarta-ant-1.4
# SDK_ANT=


# Check installation path for the StarOffice Development Kit.
if [ -z "$SDK_HOME" ]
then
    echo Error: Please insert a correct value for the variable SDK_HOME.
    exit 0
fi

export SDK_HOME

# Check installation path for the office.
if [ -z "$OFFICE_HOME" ]
then
    echo Error: Please insert a correct value for the variable OFFICE_HOME.
    exit 0
fi

export OFFICE_HOME

# Set library path.
if [ -n "$LD_LIBRARY_PATH" ]
then
    # path not empty: append colon.
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:
fi
LD_LIBRARY_PATH=$LD_LIBRARY_PATH$OFFICE_HOME/program

export LD_LIBRARY_PATH

# Set office program path.
OFFICE_PROGRAM_PATH=$OFFICE_HOME/program

export OFFICE_PROGRAM_PATH

# Get the operating system.
sd_platform=`uname -s`

# Set the directory name.
case $sd_platform in
  SunOS)
    directoryname=solsparc
    exampleout=SOLARISexample.out
    ;;

  Linux)
    directoryname=linux
    exampleout=LINUXexample.out
    ;;
esac

# Add directory of the SDK tools to the path.
#if [ -n "$PATH" ]
#then
    # Path not empty: append colon.
#    PATH=$PATH:
#fi

PATH=$SDK_HOME/$directoryname/bin:$OFFICE_PROGRAM_PATH:$PATH
LD_LIBRARY_PATH=$SDK_HOME/$directoryname/lib:$SDK_HOME/$exampleout/lib:$OFFICE_PROGRAM_PATH:$LD_LIBRARY_PATH

# Add directory of the command make to the path, if necessary.
if [ -n "$SDK_MAKE" ]
then
    PATH=$SDK_MAKE:$PATH

    export SDK_MAKE
fi

# Add directory of the C++ tools to the path, if necessary.
if [ -n "$SDK_CPP_HOME" ]
then
    PATH=$SDK_CPP_HOME:$PATH

    export SDK_CPP_HOME
fi

# Add directory of the Java tools to the path, if necessary.
if [ -n "$SDK_JAVA_HOME" ]
then
    PATH=$SDK_JAVA_HOME/bin:$PATH

    export SDK_JAVA_HOME
fi

# Add directory of the ANT tools to the path, if necessary.
if [ -n "$SDK_ANT" ]
then
    PATH=$SDK_ANT/bin:$PATH

    export SDK_ANT
fi

export PATH

# Starting a new shell with all necessary environment variables.
echo starting shell
"$SHELL" "$@"
echo  shell terminated
