#
#                             stb225 Project
#                   ---------------------------------
#
# Copyright (C) 2008 NXP B.V.,
# All Rights Reserved.
#
# Filename: setup_linux.sh
#
#
# Rev Date       Author      Comments
#-------------------------------------------------------------------------------
#   1 20070620   batelaan    Initial
#   2 20070629   batelaan    Use make instead of gmake (same on most (all?) Linux'es).
#   3 20070802   amccurdy    Skip MontaVista setup if MV tools etc don't exist
#   4 20080128   batelaan    Remove MontaVista. Not anymore supported.
#                            (also provides old Java version).
#   5 20081002   batelaan    Check STB_USE_DISTCC

# Linux-specific setup script sourced from $PRJROOT/setup.sh

_SetOverride MAKE make

# Distcc Setup
if [ -d /usr/lib/distcc/bin ]; then
    _SetDontOverride STB_USE_DISTCC 1
    if [ "$STB_USE_DISTCC" != 0 ]; then
        echo "DISTCC is available and will be used, unless you set STB_USE_DISTCC=0 before sourcing setup.sh"

        _SetDontOverride STB_HOST_IP `/bin/hostname -i`

        if [ -f /etc/distcc/hosts ]; then
            STB_HOST_LINE_COUNT=`wc -l /etc/distcc/hosts`
            STB_NUMBER_DISTCC_CLIENTS=`echo "$STB_HOST_LINE_COUNT" | cut -d' ' -f1`
            _SetOverride STB_DISTCC_OPTIONS "-j"$(((STB_NUMBER_DISTCC_CLIENTS * 3) + 1))
            echo "STB_DISTCC_OPTIONS set to $STB_DISTCC_OPTIONS"
        fi

        _extrapath=/usr/lib/distcc/bin:$_extrapath
    fi
fi
