#!/bin/sh
 
# This script build all Linux projects.
# Usage: buildAllLinuxProjects [scons arguments]
commandLineArgs=$*

NUM_ERRORS=0


# Display a start message:
echo 
echo 
echo "Building all Linux projects"
echo "==========================="
echo "Build arguments passed to scons: $commandLineArgs"

# AMD_OUTPUT should be set by parent script
if [ "x${AMD_OUTPUT}x" = "xx" ]
then
    # If not, it means this script was invoked by unknown means.
    export AMD_OUTPUT=${AMD_CODEXL}/../
fi

echo
echo
echo "========================================== "
echo "----------- Start building --------------- "
echo "cd ${AMD_CODEXL}"
cd ${AMD_CODEXL}
echo "scons CXL_common_dir=${AMD_CODEXL}/../Common CXL_prefix=$AMD_OUTPUT $commandLineArgs"
date
echo "========================================== "

eval "scons -C ${AMD_CODEXL} CXL_common_dir=${AMD_CODEXL}/../Common CXL_prefix=$AMD_OUTPUT $commandLineArgs"
RC=$?
if [ ${RC} -ne 0 ]
then
    echo "*** ERROR during the build of this subcomponent ***"
fi

echo "========================================== "
echo "----------- End building ----------------- "
date
echo "========================================== "

NUM_ERRORS=`expr ${NUM_ERRORS} + ${RC}`
if [ ${NUM_ERRORS} -ne 0 ]
then
    echo "*** ERROR ***"
    echo "*** the build failed - see the logs for details ***"
    exit 1
else
    echo "*** SUCCESS ***" 
fi

exit 0
