#!/bin/bash

. buildsys/functions

ProcessArgs $*
Assert LoadConfigs
Assert SetupLogDir
Assert SetupResFile

if [ "$BUILD_DIST" != "yes" ]
then
   echo "BUILD_DIST=SKIPPED" >> $RESFILE
   exit 0
fi

cd ../../..

SetState BuildingDistribution
ArchiveLogs

if [ "$DEP" != "none" ]
then
   OSPL_HOME=$DEPWORKDIR
   export OSPL_HOME
fi

SPLICE_PLATFORM=$SETUP_TYPE
export SPLICE_PLATFORM
. ./configure -full
if [ "$CONFIGURATION" != "OK" ]
then
   echo  "ERROR: configuration - dcps_build_dist"
   exit 1
fi

echo "BUILD_DIST=RUNNING" >> $RESFILE
ArchiveLogs

cd install || 
{ 
    echo "ERROR: could not cd to install dir - dcps_build_dist"; 
    exit 2; 
}

make
exit 0
