#
# This example build is valid for OpenFusion TAO only
#

# Include paths
INCLUDES=-I./
INCLUDES=$INCLUDES\ -I..
INCLUDES=$INCLUDES\ -I$OSPL_HOME/include/dcps/C++/CCPP
INCLUDES=$INCLUDES\ -I$OSPL_HOME/include/dcps/C++/CCPP/DDS_OpenFusion_1_4_1
INCLUDES=$INCLUDES\ -I$TAO_ROOT/include

# Compiler settings.
CXX=g++
CXXFLAGS="-g -c"
CPPFLAGS=-DDDS_OpenFusion_1_4_1\ $INCLUDES

# Linker settings.
LD_SO=$CXX
LD_FLAGS=
LD_LIBS=-lstdc++

# IDL Compiler settings.
IDLC=tao_idl
IDLFLAGS="-Sc -Sp -Sd -Sv"

TAO_COMP=`which tao_idl 2> /dev/null`
if [ -z "$TAO_COMP" -o -z "$TAO_ROOT" ]
then
    echo "Setup the TAO environment first"
    exit
fi

CXX_COMP=`which $CXX 2> /dev/null`
if [ -z "$CXX_COMP" ]
then
    echo "Setup the C++ environment first"
    exit
fi

SPLICE_COMP=`which idlpp 2> /dev/null`
if [ -z "$SPLICE_COMP" ]
then
    echo "Setup the SPLICE environment first"
    exit
fi

mkdir -p bld
mkdir -p exec
cd bld

echo "Compiling IDL with TAO IDL compiler"
$IDLC $INCLUDES $IDLFLAGS ../Chat.idl

echo "Compiling IDL with SPLICE IDL compiler"
idlpp -C -l cpp ../Chat.idl

echo "Compiling IDL Typed Interfaces with TAO IDL compiler"
$IDLC $INCLUDES $IDLFLAGS ChatDcps.idl

echo "Compiling TAO User Types support code"
$CXX $CPPFLAGS $CXXFLAGS ChatC.cpp

echo "Compiling SPLICE User Types support code"
$CXX $CPPFLAGS $CXXFLAGS ChatSplDcps.cpp

echo "Compiling TAO Typed Interfaces support code"
$CXX $CPPFLAGS $CXXFLAGS ChatDcpsC.cpp

echo "Compiling Application Foo Types support code"
$CXX $CPPFLAGS $CXXFLAGS ChatDcps_impl.cpp

echo "Compiling Status checking code"
$CXX $CPPFLAGS $CXXFLAGS ../CheckStatus.cpp

echo "Compiling multitopic code"
$CXX $CPPFLAGS $CXXFLAGS ../multitopic.cpp

echo "Compiling Chatter"
$CXX $CPPFLAGS $CXXFLAGS ../Chatter.cpp

echo "Compiling MessageBoard"
$CXX $CPPFLAGS $CXXFLAGS ../MessageBoard.cpp

echo "Compiling UserLoad"
$CXX $CPPFLAGS $CXXFLAGS ../UserLoad.cpp

echo "Linking Chatter"
$LD_SO $LD_FLAGS -o ../exec/Chatter -L$OSPL_HOME/lib Chatter.o ChatC.o ChatDcpsC.o ChatDcps_impl.o ChatSplDcps.o CheckStatus.o -L$TAO_ROOT/lib -lTAO -lddsdatabase -ldcpsgapi -ldcpsccpp $LD_LIBS

echo "Linking MessageBoard"
$LD_SO $LD_FLAGS -o ../exec/MessageBoard -L$OSPL_HOME/lib MessageBoard.o ChatC.o ChatDcpsC.o ChatDcps_impl.o ChatSplDcps.o CheckStatus.o multitopic.o -L$TAO_ROOT/lib -lTAO -lddsdatabase -ldcpsgapi -ldcpsccpp $LD_LIBS

echo "Linking UserLoad"
$LD_SO $LD_FLAGS -o ../exec/UserLoad -L$OSPL_HOME/lib UserLoad.o ChatC.o ChatDcpsC.o ChatDcps_impl.o ChatSplDcps.o CheckStatus.o -L$TAO_ROOT/lib -lTAO -lddsdatabase -ldcpsgapi -ldcpsccpp $LD_LIBS

cd ..
