meta-tizen: tizen-platform-config: Update relocated git repo (IVI)
[scm/bb/tizen-distro.git] / oe-init-build-env
index cc30a3b..5249513 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# OE Build Enviroment Setup Script
+# OE Build Environment Setup Script
 #
 # Copyright (C) 2006-2011 Linux Foundation
 #
 # being sourced.   To workaround the shell limitation use "set arg1" prior 
 # to sourcing this script.
 #
-if [ -z "$ZSH_NAME" ] && [ "x$0" = "x./oe-init-build-env" ]; then
-   echo "Error: This script needs to be sourced. Please run as '. ./oe-init-build-env'"
+if [ -n "$BASH_SOURCE" ]; then
+   OEROOT="`dirname $BASH_SOURCE`"
+elif [ -n "$ZSH_NAME" ]; then
+   OEROOT="`dirname $0`"
 else
-   if [ -n "$BASH_SOURCE" ]; then
-      OEROOT="`dirname $BASH_SOURCE`"
-   else
-      OEROOT="`pwd`"
-   fi
-   OEROOT=`readlink -f "$OEROOT"`
-   export OEROOT
-   . $OEROOT/scripts/oe-buildenv-internal && \
-        $OEROOT/scripts/oe-setup-builddir && \
-        [ -n "$BUILDDIR" ] && cd $BUILDDIR
-   unset OEROOT
-   unset BBPATH
+   OEROOT="`pwd`"
+fi
+if [ -n "$BBSERVER" ]; then
+   unset BBSERVER
+fi
+THIS_SCRIPT=$OEROOT/oe-init-build-env
+
+if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
+   echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'"
+   exit 1
+fi
+
+OEROOT=`readlink -f "$OEROOT"`
+export OEROOT
+. $OEROOT/scripts/oe-buildenv-internal && \
+     $OEROOT/scripts/oe-setup-builddir && \
+     [ -n "$BUILDDIR" ] && cd $BUILDDIR
+unset OEROOT
+unset BBPATH
+unset THIS_SCRIPT
+
+# Shutdown any bitbake server if the BBSERVER variable is not set
+if [ -z "$BBSERVER" ] && [ -f bitbake.lock ] ; then
+    grep ":" bitbake.lock > /dev/null && BBSERVER=`cat bitbake.lock` bitbake --status-only
+    if [ $? = 0 ] ; then
+       echo "Shutting down bitbake memory resident server with bitbake -m"
+       BBSERVER=`cat bitbake.lock` bitbake -m
+    fi
 fi