commit fad4c1e7c92ec1d19ed93975cddb33391daf8197
Author: Thomas Schöpping <tschoepp@cit-ec.uni-bielefeld.de>
Date:   Mon Jan 21 13:24:15 2019 +0100

    Bash scripts: introduced a new function to check dependencies.
    This function is used by setup.sh to ensure that git, make, etc. are available.

diff --git a/setup.sh b/setup.sh
index 42e1d9d..0b787a9 100755
--- a/setup.sh
+++ b/setup.sh
@@ -263,6 +263,40 @@ function setLogFile {
   return 0
 }
 
+### check whether commands are available #######################################
+# Checks whether the specified commands are available and can be executed.
+#
+# usage:      checkCommand [<command> <command> ...]
+# arguments:  <command>
+#                 Name of the command to check.
+# return:     0
+#                 All requested commands are available.
+#             >0
+#                 Number of requested commands that were not found.
+#             -1
+#                 No argument given.
+#
+function checkCommands {
+  local status=0
+
+  # return if no argument was specified
+  if [ $# -eq 0 ]; then
+    return -1
+  fi
+
+  # check all specified commands
+  while [ $# -gt 0 ]; do
+    command -v $1 &>/dev/null
+    if [ $? -ne 0 ]; then
+      printWarning "Command '$1' not available.\n"
+      status=$((status + 1))
+    fi
+    shift 1
+  done
+
+  return $status
+}
+
 ################################################################################
 # SPECIFIC FUNCTIONS                                                           #
 ################################################################################
@@ -333,12 +367,21 @@ function printHelp {
 #                 Warning: Setup aborted by user.
 #             -1
 #                 Error: Unexpected user input.
+#             -2
+#                 Error: Missing dependecny.
 #
 function stm32flashSetup {
   local amirobltdir=$(dirname $(realpath ${BASH_SOURCE[0]}))
   local stm32flashdir=${amirobltdir}/Host/Source/stm32flash
   local userdir=$(pwd)
 
+  # check dependencies
+  checkCommands git make gcc g++
+  if [ $? -ne 0 ]; then
+    printError "Missing dependencies detected.\n"
+    return -2
+  fi
+
   # if the stm32flash folder is not empty
   if [ ! -z "$(ls -A $stm32flashdir)" ]; then
     printWarning "$stm32flashdir is not empty. Delete and reinitialize? [y/n]\n"
@@ -423,6 +466,13 @@ function serialBootSetup {
   local serialbootdir=${amirobltdir}/Host/Source/SerialBoot
   local userdir=$(pwd)
 
+  # check dependencies
+  checkCommands make cmake gcc g++
+  if [ $? -ne 0 ]; then
+    printError "Missing dependencies detected.\n"
+    return -2
+  fi
+
   # if a build folder already exists
   if [ -d "${serialbootdir}/build/" ]; then
     printWarning "SerialBoot has been built before. Delete and rebuild? [y/n]\n"
diff --git a/tools/compiler/GCC/gccsetup.sh b/tools/compiler/GCC/gccsetup.sh
index f3a8c6e..69a8119 100755
--- a/tools/compiler/GCC/gccsetup.sh
+++ b/tools/compiler/GCC/gccsetup.sh
@@ -263,6 +263,40 @@ function setLogFile {
   return 0
 }
 
+### check whether commands are available #######################################
+# Checks whether the specified commands are available and can be executed.
+#
+# usage:      checkCommand [<command> <command> ...]
+# arguments:  <command>
+#                 Name of the command to check.
+# return:     0
+#                 All requested commands are available.
+#             >0
+#                 Number of requested commands that were not found.
+#             -1
+#                 No argument given.
+#
+function checkCommands {
+  local status=0
+
+  # return if no argument was specified
+  if [ $# -eq 0 ]; then
+    return -1
+  fi
+
+  # check all specified commands
+  while [ $# -gt 0 ]; do
+    command -v $1 &>/dev/null
+    if [ $? -ne 0 ]; then
+      printWarning "Command '$1' not available.\n"
+      status=$((status + 1))
+    fi
+    shift 1
+  done
+
+  return $status
+}
+
 ################################################################################
 # SPECIFIC FUNCTIONS                                                           #
 ################################################################################
diff --git a/tools/compiler/compilersetup.sh b/tools/compiler/compilersetup.sh
index b7370aa..19b1e00 100755
--- a/tools/compiler/compilersetup.sh
+++ b/tools/compiler/compilersetup.sh
@@ -263,6 +263,40 @@ function setLogFile {
   return 0
 }
 
+### check whether commands are available #######################################
+# Checks whether the specified commands are available and can be executed.
+#
+# usage:      checkCommand [<command> <command> ...]
+# arguments:  <command>
+#                 Name of the command to check.
+# return:     0
+#                 All requested commands are available.
+#             >0
+#                 Number of requested commands that were not found.
+#             -1
+#                 No argument given.
+#
+function checkCommands {
+  local status=0
+
+  # return if no argument was specified
+  if [ $# -eq 0 ]; then
+    return -1
+  fi
+
+  # check all specified commands
+  while [ $# -gt 0 ]; do
+    command -v $1 &>/dev/null
+    if [ $? -ne 0 ]; then
+      printWarning "Command '$1' not available.\n"
+      status=$((status + 1))
+    fi
+    shift 1
+  done
+
+  return $status
+}
+
 ################################################################################
 # SPECIFIC FUNCTIONS                                                           #
 ################################################################################
diff --git a/tools/ide/QtCreator/QtCreatorSetup.sh b/tools/ide/QtCreator/QtCreatorSetup.sh
index 0cf40a2..14c33f0 100755
--- a/tools/ide/QtCreator/QtCreatorSetup.sh
+++ b/tools/ide/QtCreator/QtCreatorSetup.sh
@@ -263,6 +263,40 @@ function setLogFile {
   return 0
 }
 
+### check whether commands are available #######################################
+# Checks whether the specified commands are available and can be executed.
+#
+# usage:      checkCommand [<command> <command> ...]
+# arguments:  <command>
+#                 Name of the command to check.
+# return:     0
+#                 All requested commands are available.
+#             >0
+#                 Number of requested commands that were not found.
+#             -1
+#                 No argument given.
+#
+function checkCommands {
+  local status=0
+
+  # return if no argument was specified
+  if [ $# -eq 0 ]; then
+    return -1
+  fi
+
+  # check all specified commands
+  while [ $# -gt 0 ]; do
+    command -v $1 &>/dev/null
+    if [ $? -ne 0 ]; then
+      printWarning "Command '$1' not available.\n"
+      status=$((status + 1))
+    fi
+    shift 1
+  done
+
+  return $status
+}
+
 ################################################################################
 # SPECIFIC FUNCTIONS                                                           #
 ################################################################################
diff --git a/tools/ide/idesetup.sh b/tools/ide/idesetup.sh
index 971353c..9cf991d 100755
--- a/tools/ide/idesetup.sh
+++ b/tools/ide/idesetup.sh
@@ -263,6 +263,40 @@ function setLogFile {
   return 0
 }
 
+### check whether commands are available #######################################
+# Checks whether the specified commands are available and can be executed.
+#
+# usage:      checkCommand [<command> <command> ...]
+# arguments:  <command>
+#                 Name of the command to check.
+# return:     0
+#                 All requested commands are available.
+#             >0
+#                 Number of requested commands that were not found.
+#             -1
+#                 No argument given.
+#
+function checkCommands {
+  local status=0
+
+  # return if no argument was specified
+  if [ $# -eq 0 ]; then
+    return -1
+  fi
+
+  # check all specified commands
+  while [ $# -gt 0 ]; do
+    command -v $1 &>/dev/null
+    if [ $? -ne 0 ]; then
+      printWarning "Command '$1' not available.\n"
+      status=$((status + 1))
+    fi
+    shift 1
+  done
+
+  return $status
+}
+
 ################################################################################
 # SPECIFIC FUNCTIONS                                                           #
 ################################################################################
