Extract openbmc master when no input software provided

I'd like to utilize this script to do automated master builds against all
of the supported systems.  These builds will then feed into QEMU and
hardware validation jobs.

Change-Id: Iea81259b8ecfb237ae4e393b08efdc3f1a35bf28
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/build-setup.sh b/build-setup.sh
index 3aa30c6..2230f66 100755
--- a/build-setup.sh
+++ b/build-setup.sh
@@ -5,7 +5,8 @@
 # It expects a few variables which are part of Jenkins build job matrix:
 #   target = barreleye|palmetto|qemu
 #   distro = fedora|ubuntu
-#   WORKSPACE = 
+#   obmcdir = <name of openbmc src dir> (default openbmc)
+#   WORKSPACE =
 
 # Trace bash processing. Set -e so when a step fails, we fail the build
 set -xeo pipefail
@@ -13,6 +14,7 @@
 # Default variables
 target=${target:-qemu}
 distro=${distro:-ubuntu}
+obmcdir=${obmcdir:-openbmc}
 WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
 http_proxy=${http_proxy:-}
 PROXY=""
@@ -20,6 +22,12 @@
 # Timestamp for job
 echo "Build started, $(date)"
 
+# If there's no openbmc dir in WORKSPACE then just clone in master
+if [ ! -d ${WORKSPACE}/${obmcdir} ]; then
+    echo "Clone in openbmc master to ${WORKSPACE}/${obmcdir}"
+    git clone https://github.com/openbmc/openbmc ${WORKSPACE}/${obmcdir}
+fi
+
 # Work out what build target we should be running and set bitbake command
 case ${target} in
   barreleye)
@@ -147,7 +155,7 @@
 cd ${WORKSPACE}
 
 # Go into the openbmc directory (the openbmc script will put us in a build subdir)
-cd openbmc
+cd ${obmcdir}
 
 # Set up proxies
 export ftp_proxy=${http_proxy}