commit 0a42f07830784c218177e5300df757f46056da8c
Author: Thomas Schöpping <tschoepp@cit-ec.uni-bielefeld.de>
Date:   Thu Sep 28 15:34:42 2017 +0200

    Further enhancements to the bash scripts.
    Additional scripts for compiler configuration have been added.

diff --git a/compiler/GCC/gccsetup.sh b/compiler/GCC/gccsetup.sh
new file mode 100755
index 0000000..7371827
--- /dev/null
+++ b/compiler/GCC/gccsetup.sh
@@ -0,0 +1,760 @@
+################################################################################
+# AMiRo-BLT is an bootloader and toolchain designed for the Autonomous Mini    #
+# Robot (AMiRo) platform.                                                      #
+# Copyright (C) 2016..2017  Thomas Schöpping et al.                            #
+#                                                                              #
+# This program is free software: you can redistribute it and/or modify         #
+# it under the terms of the GNU General Public License as published by         #
+# the Free Software Foundation, either version 3 of the License, or            #
+# (at your option) any later version.                                          #
+#                                                                              #
+# This program is distributed in the hope that it will be useful,              #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
+# GNU General Public License for more details.                                 #
+#                                                                              #
+# You should have received a copy of the GNU General Public License            #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
+#                                                                              #
+# This research/work was supported by the Cluster of Excellence Cognitive      #
+# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
+# funded by the German Research Foundation (DFG).                              #
+################################################################################
+
+#!/bin/bash
+
+################################################################################
+# GENERIC FUNCTIONS                                                            #
+################################################################################
+
+### print an error message #####################################################
+# Prints a error <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printError <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
+function printError {
+  local string="ERROR:   $1"
+  # if a log file is specified
+  if [ -n "$LOG_FILE" ]; then
+    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
+  fi
+  printf "$(tput setaf 1)>>> $string$(tput sgr 0)" 1>&2
+}
+
+### print a warning message ####################################################
+# Prints a warning <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printMessage <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
+function printWarning {
+  local string="WARNING: $1"
+  # if a log file is specified
+  if [ -n "$LOG_FILE" ]; then
+    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
+  fi
+  printf "$(tput setaf 3)>>> $string$(tput sgr 0)"
+}
+
+### print an information message ###############################################
+# Prints an information <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printInfo <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
+function printInfo {
+  local string="INFO:    $1"
+  # if a log file is specified
+  if [ -n "$LOG_FILE" ]; then
+    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
+  fi
+  printf "$(tput setaf 2)>>> $string$(tput sgr 0)"
+}
+
+### print a message to file ####################################################
+# Appends a <message> to a log file, specified by the variable 'LOG_FILE'.
+#
+# usage       printLog <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
+function printLog {
+  local string="LOG:     $1"
+  # if a log file is specified
+  if [ -n "$LOG_FILE" ]; then
+    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
+  fi
+}
+
+### exit the script normally ###################################################
+# Prints a delimiter and exits the script normally (returns 0).
+#
+# usage:      quitScript
+# arguments:  n/a
+# return:     0
+#                 No error or warning occurred.
+#
+function quitScript {
+  printLog "exiting $(realpath ${BASH_SOURCE[0]})\n"
+  printf "######################################################################\n"
+  exit 0
+}
+
+### read a user input ##########################################################
+# Reads a single character user input from a set up <options> and stores it in
+# a given <return> variable.
+#
+# usage:      readUserInput <options> <return>
+# arguments:  <options>
+#                 String definiing the set of valid characters.
+#                 If the string is empty, the user can input any character.
+#             <return>
+#                 Variable to store the selected character to.
+# return:     n/a
+#
+function readUserInput {
+  local input=""
+  # read user input
+  while [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); do
+    read -p "your selection: " -n 1 -e input
+    if [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); then
+      printWarning "[$input] is no valid action\n"
+    fi
+  done
+  printLog "[$input] has been selected\n"
+  eval $2="$input"
+}
+
+### check whether argument is an option ########################################
+# Checks a <string> whether it is an option.
+# Options are defined to either start with '--' followed by any string, or
+# to start with a single '-' followed by a single character, or
+# to start with a single '-' followed by a single character, a '=' and any string.
+# Examples: '--option', '--option=arg', '-o', '-o=arg', '--'
+#
+# usage:      parseIsOption <string>
+# arguments:  <string>
+#                 A string to check whether it is an option.
+# return:     0
+#                 <string> is an option.
+#             -1
+#                 <string> is not an option.
+#
+function parseIsOption {
+  if [[ "$1" =~ ^-(.$|.=.*) ]] || [[ "$1" =~ ^--.* ]]; then
+    return 0
+  else
+    return -1
+  fi
+}
+
+### set the log file ###########################################################
+# Sets a specified <infile> as log file and checks whether it already exists.
+# If so, the log may either be appended to the file, its content can be cleared,
+# or no log is generated at all.
+# The resulting path is stored in <outvar>.
+#
+# usage:      setLogFile [--option=<option>] [--quiet] <infile> <outvar>
+# arguments:  --option=<option>
+#                 Select what to do if <file> already exists.
+#                 Possible values are 'a', 'r' and 'n'.
+#                 - a: append
+#                 - r: delete and restart
+#                 - n: no log
+#                 If no option is secified but <file> exists, an interactive selection is provided.
+#             --quiet
+#                 Suppress all messages.
+#             <infile>
+#                 Path of the wanted log file.
+#             <outvar>
+#                 Variable to store the path of the log file to.
+# return:     0
+#                 No error or warning occurred.
+#             -1
+#                 Error: invalid input
+#
+function setLogFile {
+  local filepath=""
+  local option=""
+  local quiet=false
+
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -o=*|--option=*)
+          option=${1#*=}; shift 1;;
+        -o*|--option*)
+          option="$2"; shift 2;;
+        -q|--quiet)
+          quiet=true; shift 1;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
+  done
+  filepath=$(realpath ${otherargs[0]})
+
+  # if file already exists
+  if [ -e $filepath ]; then
+    # if no option was specified, ask what to do
+    if [ -z "$option" ]; then
+      printWarning "log file $filepath already esists\n"
+      local userinput=""
+      printf "Select what to do:\n"
+      printf "  [A] - append log\n"
+      printf "  [R] - restart log (delete existing file)\n"
+      printf "  [N] - no log\n"
+      readUserInput "AaRrNn" userinput
+      option=${userinput,,}
+    fi
+    # evaluate option
+    case "$option" in
+      a)
+        if [ $quiet = false ]; then
+          printInfo "appending log to $filepath\n"
+        fi
+        printf "\n" >> $filepath
+        printf "######################################################################\n" >> $filepath
+        printf "\n" >> $filepath
+        ;;
+      r)
+        echo -n "" > $filepath
+        if [ $quiet = false ]; then
+          printInfo "content of $filepath wiped\n"
+        fi
+        ;;
+      n)
+        if [ $quiet = false ]; then
+          printInfo "no log file will be generated\n"
+        fi
+        filepath=""
+        ;;
+      *) # sanity check (return error)
+        printError "unexpected argument: $option\n"; return -1;;
+    esac
+  else
+    if [ $quiet = false ]; then
+      printInfo "log file set to $filepath\n"
+    fi
+  fi
+
+  eval ${otherargs[1]}="$filepath"
+
+  return 0
+}
+
+################################################################################
+# SPECIFIC FUNCTIONS                                                           #
+################################################################################
+
+### print welcome text #########################################################
+# Prints a welcome message to standard out.
+#
+# usage:      printWelcomeText
+# arguments:  n/a
+# return:     n/a
+#
+function printWelcomeText {
+  printf "######################################################################\n"
+  printf "#                                                                    #\n"
+  printf "#                     Welcome to the GCC setup!                      #\n"
+  printf "#                                                                    #\n"
+  printf "######################################################################\n"
+  printf "#                                                                    #\n"
+  printf "# Copyright (c) 2016..2017  Thomas Schöpping                         #\n"
+  printf "#                                                                    #\n"
+  printf "# This is free software; see the source for copying conditions.      #\n"
+  printf "# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR  #\n"
+  printf "# A PARTICULAR PURPOSE. The development of this software was         #\n"
+  printf "# supported by the Excellence Cluster EXC 227 Cognitive Interaction  #\n"
+  printf "# Technology. The Excellence Cluster EXC 227 is a grant of the       #\n"
+  printf "# Deutsche Forschungsgemeinschaft (DFG) in the context of the German #\n"
+  printf "# Excellence Initiative.                                             #\n"
+  printf "#                                                                    #\n"
+  printf "######################################################################\n"
+}
+
+### print help #################################################################
+# Prints a help text to standard out.
+#
+# usage:      printHelp
+# arguments:  n/a
+# return:     n/a
+#
+function printHelp {
+  printInfo "printing help text\n"
+  printf "usage:    $(basename ${BASH_SOURCE[0]}) [-h|--help] [-i|--install] [-c|--change] [-q|--quit] [--log=<file>]\n"
+  printf "\n"
+  printf "options:  -h, --help\n"
+  printf "              Print this help text.\n"
+  printf "          -i, --install\n"
+  printf "              Install another version.\n"
+  printf "          -c, --change\n"
+  printf "              Change the default version.\n"
+  printf "          -q, --quit\n"
+  printf "              Quit the script.\n"
+  printf "          --log=<file>\n"
+  printf "              Specify a log file.\n"
+}
+
+### detect installed versions ##################################################
+# Detect all installed version of arm-none-eabi-gcc, if any.
+#
+# usage:      detectInstalledVersions <binarray> <current>
+# arguments:  <binarray>
+#                 Array variable to store all detected binary paths to. 
+#             <current>
+#                 Variable to store the currently active binary to.
+# return:     n/a
+#
+function detectInstalledVersions {
+  local armgcc_command=$(command -v arm-none-eabi-gcc)
+  local armgcc_commanddir=${HOME}/gcc-none-eabi
+  local armgcc_currentbin=""
+  local armgcc_installdir=${HOME}/gcc-none-eabi
+  local armgcc_bins=()
+  local armgcc_bincnt=0
+
+  # check for already installed versions
+  if [ -n "$armgcc_command" ]; then
+    # follow the link to the actual binary
+    armgcc_commanddir=$(dirname $armgcc_command)
+    armgcc_currentbin=$armgcc_command
+    while [ -L $armgcc_currentbin ]; do
+      armgcc_currentbin=$(readlink $armgcc_currentbin)
+    done
+    # the installation location is assumed to be two directories up
+    armgcc_installdir=$(realpath $(dirname ${armgcc_currentbin})/../../)
+    # list all detected instalations
+    for dir in $(ls -d ${armgcc_installdir}/*/); do
+      if [ -f ${dir}/bin/arm-none-eabi-gcc ]; then
+        armgcc_bins[$armgcc_bincnt]=${dir}bin/arm-none-eabi-gcc
+        armgcc_bincnt=$((armgcc_bincnt + 1))
+      fi
+    done
+  fi
+
+  eval "$1=(${armgcc_bins[*]})"
+  eval $2="$armgcc_currentbin"
+}
+
+### install new version ########################################################
+# Fetches an installation package from the internet, installs it and expands
+# the $PATH environment variable (via .bashrc) if required.
+#
+# usage:      installNewVersion [-i|--install=<path>] [-l|--link=<path>]
+# argumenst:  -i, --install <path>
+#                 Path where to install the new version to.
+#             -l, --link <path>
+#                 Path where to create according links.
+# return:     0
+#                 No error or warnign occurred.
+#             1
+#                 Warning: Installation aborted by user.
+#
+function installNewVersion {
+  local installbasedir=${HOME}/gcc-arm-embedded
+  local linkdir="/usr/bin"
+
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -i=*|--install=*)
+          installbasedir=$(realpath "${1#*=}"); shift 1;;
+        -i|--install)
+          installbasedir="$2"; shift 2;;
+        -l=*|--link=*)
+          linkdir=$(realpath "${1#*=}"); shift 1;;
+        -l|--link)
+          linkdir="$2"; shift 2;;
+        *) # sanity check (exit with error)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
+  done
+
+  # read download URL form user
+  printLog "read installation url from user\n"
+  local armgcc_downloadurl=""
+  while [[ "$armgcc_downloadurl" != *".tar.bz2" ]]; do
+    read -p "Download link for the installation file: " -e armgcc_downloadurl
+    if [[ $armgcc_downloadurl != *".tar.bz2" ]]; then
+      printWarning "please specify a .tar.bz2 file\n"
+    fi
+  done
+  printLog "user selected $armgcc_downloadurl\n"
+
+  # if the file already exists, ask the user if it should be downloaded again
+  local armgcc_tarball=$(basename "$armgcc_downloadurl")
+  if [ -e "$armgcc_tarball" ]; then
+    printWarning "$armgcc_tarball already exists. Delete and redownload? [y/n]\n"
+    local userinput=""
+    readUserInput "YyNn" userinput
+    case "$userinput" in
+      Y|y)
+        rm "$armgcc_tarball"
+        wget "$armgcc_downloadurl" | tee -a $LOG_FILE
+        ;;
+      N|n)
+        ;;
+      *) # sanity check (exit with error)
+        printError "unexpected argument: $userinput\n";;
+    esac
+  else
+    wget "$armgcc_downloadurl" | tee -a $LOG_FILE
+  fi
+
+  # extract tarball
+  printInfo "extracting ${armgcc_tarball}...\n"
+  tar -jxf "$armgcc_tarball" | tee -a $LOG_FILE
+  local compilerdir=`tar --bzip2 -tf ${armgcc_tarball} | sed -e 's@/.*@@' | uniq`
+
+  # install gcc arm mebedded
+  printLog "read installation directory from user\n"
+  local installdir=""
+  read -p "Installation directory: " -i ${installbasedir}/${compilerdir} -e installdir
+  printLog "user selected $installdir\n"
+  printLog "read link directory\n"
+  read -p "Link directory: " -i $linkdir -e linkdir
+  printLog "user selected $linkdir\n"
+  # if the installation path already exists, ask user to overwrite
+  if [ -d "$installdir" ]; then
+    printWarning "$installdir already exists. Overwrite? [y/n]\n"
+    local userinput=""
+    readUserInput "YyNn" userinput
+    case "$userinput" in
+      Y|y)
+        ;;
+      N|n)
+        printWarning "installation aborted by user\n"
+        return 1
+        ;;
+      *) # sanity check (exit with error)
+        printError "invalid option: $userinput\n";;
+    esac
+  # make sure the whole ínstallation path exists
+  else
+    echo "$installdir path not exist"
+    while [ ! -d $(dirname "$installdir") ]; do
+      local dir=$(dirname "$installdir") 
+      while [ ! -d $(dirname "$dir") ]; do
+        dir=$(dirname "$dir")
+      done
+      echo "mkdir $dir"
+      mkdir "$dir"
+    done
+  fi
+  # copy the extracted compiler folder
+  cp -fR "$compilerdir" "$installdir"
+  # make sure whole link path exists
+  while [ ! -d "$linkdir" ]; do
+    local dir="$linkdir"
+    while [ ! -d $(dirname "$linkdir") ]; do
+      dir=$(dirname "$dir")
+    done
+    mkdir "$dir"
+  done
+  # create / overwrite links
+  ls ${installdir}/bin/ | xargs -i ln -sf ${installdir}/bin/{} ${linkdir}/{}
+  printInfo "default version set to $(arm-none-eabi-gcc -dumpversion)\n"
+
+  read -p "bashrc stuff"
+
+  # append the link directory to the PATH environment variable if required
+  if [[ ! "$linkdir" = *"$PATH"* ]]; then
+    local bashrc_file=${HOME}/.bashrc
+    local bashrc_identifier="##### AMiRo ENVIRONMENT CONFIGURATION #####"
+    local bashrc_note="# DO NOT EDIT THESE LINES MANUALLY!"
+    local bashrc_entry="export PATH=\$PATH:$linkdir"
+
+    # find and edit old entry, or append a new one to the file
+    local bashrc_idlines=$(grep -x -n "$bashrc_identifier" "$bashrc_file" | cut -f1 -d:) # string of line numbers
+    bashrc_idlines=(${bashrc_idlines//"\n"/" "}) # array of line numbers
+    case ${#bashrc_idlines[@]} in
+
+      # append a new entry to the BASHRC_FILE
+      0)
+        # make sure the last line is empty
+        if [[ ! $(tail -1 $bashrc_file) =~ ^[\ \t]*$ ]]; then
+          printf "\n" >> $bashrc_file
+        fi
+        # append text to file
+        sed -i '$a'"$bashrc_identifier\n$bashrc_note\n$bashrc_entry\n$bashrc_identifier\n" $bashrc_file
+        # print note
+        printInfo "Your $bashrc_file has been updated. You need to source it to apply the changes in your environment.\n"
+        read -p "  Understood!"
+        ;;
+
+      # extend the old entry
+      2)
+        # don't do anything if the line is already present
+        local bashrc_entrylines=$(grep -x -n "$bashrc_entry" $bashrc_file | cut -f1 -d:) # string of line numbers
+        bashrc_entrylines=(${bashrc_entrylines//"\n"/" "}) # array of line numbers
+        printf "$bashrc_entrylines\n"
+        if [[ ${#bashrc_entrylines[@]} = 0 ]]; then
+          # insert the entry before the closing identifier
+          sed -i "${bashrc_idlines[1]}"'i'"$bashrc_entry" $bashrc_file
+          # print note
+          printInfo "Your $bashrc_file has been updated. You need to source it to apply the changes in your environment.\n"
+          read -p "  Understood!"
+        elif [[ ${#bashrc_entrylines[@]} -eq 1 && ( ${bashrc_entrylines[0]} -lt ${bashrc_idlines[0]} || ${bashrc_entrylines[0]} -gt ${bashrc_idlines[1]} ) ]]; then
+          # print an error that there is an entry at the wrong place
+          printError "corrupted entry in your $bashrc_file detected\n"
+          printf "The following entry was found at the wrong place:\n"
+          printf "\n"
+          printf "$bashrc_entry\n"
+          printf "\n"
+          printf "To fix this, delete the line and rerun this setup.\n"
+          read -p "  Understood!"
+        elif [[ ${#bashrc_entrylines[@]} -gt 1 ]]; then
+          # print an error that there are multiple entries
+          printError "corrupted entry in your $bashrc_file detected\n"
+          printf "There are multiple identical entries in your $bashrc_file file.\n"
+          printf "To fix it, make sure that it contains the following line exactly once:\n"
+          printf "\n"
+          printf "$bashrc_entry\n"
+          printf "\n"
+          read -p "  Understood!"
+        fi
+        ;;
+
+      # error state (corrupted entry detected)
+      *)
+        printError "unable to append link directory to \$PATH variable\n"
+        printf "There seems to be a broken entry in your $bashrc_file file.\n"
+        printf "To fix it, make sure that the following line appears exactly twice and encloses your AMiRo related settings:\n"
+        printf "\n"
+        printf "$bashrc_identifier\n"
+        printf "\n"
+        read -p "  Understood!"
+        ;;
+    esac
+  fi
+
+  # clean up the current directory
+  rm "$armgcc_tarball"
+  rm -rf "$compilerdir"
+
+  return 0
+}
+
+### change default version #####################################################
+# Change the default arm-none-eabi-gcc version.
+#
+# usage:      installNewVersion <versions> <linkdir>
+# argumenst:  <versions>
+#                 Array of available versions (full path to binary).
+#             <linkdir>
+#                 Path where to delete old and create new links.
+# return:     0
+#                 No error or warnign occurred.
+#             -1
+#                 Error: no installation detected.
+#
+function changeDefaultVersion {
+  local versions=("${!1}")
+  local linkdir="$2"
+
+  # check whether an installation was detected
+  if [ ${#versions[@]} -eq 0 ]; then
+    printError "no installation detected\n"
+    return -1
+  else
+    # print all available versions
+    printInfo "choose the installation to switch to or type 'A' to abort:\n"
+    for (( cnt=0; cnt<${#versions[@]}; ++cnt )); do
+      printf "  %2u: %s\n" $(($cnt + 1)) ${versions[$cnt]}
+    done
+
+    # read user selection
+    printLog "read user slection\n"
+    local userinput=""
+    while [[ ! "$userinput" =~ ^[0-9]+$ ]] || [ ! "$userinput" -gt 0 ] || [ ! "$userinput" -le ${#versions[@]} ] && [[ ! "$userinput" =~ ^[Aa]$ ]]; do
+      read -p "your selection: " -e userinput
+      printLog "user selection: $userinput\n"
+      if [[ ! "$userinput" =~ ^[0-9]+$ ]] || [ ! "$userinput" -gt 0 ] || [ ! "$userinput" -le ${#versions[@]} ] && [[ ! "$userinput" =~ ^[Aa]$ ]]; then
+        printWarning "Please enter an integer between 1 and ${#versions[@]} or 'A' to abort.\n"
+      fi
+    done
+
+    if [[ "$userinput" =~ ^[Aa]$ ]]; then
+      printWarning "aborted by user\n"
+    else
+      local idx=$((userinput - 1))
+      # find and delete old links
+      rm `find $linkdir -maxdepth 1 -type l | grep -Ev "*[0-9]\.[0-9]\.[0-9]"`
+      # create new links
+      local bindir=$(dirname ${versions[$idx]})
+      ls $bindir | xargs -i ln -sf $bindir/{} $linkdir/{}
+      printInfo "default version set to $(arm-none-eabi-gcc -dumpversion)\n"
+    fi
+  fi
+
+  return 0
+}
+
+### main function of this script ###############################################
+# The IDE setup lets the user select an IDE of choice.
+# As of now, only QtCreator is supported.
+#
+# usage:      see function printHelp
+# arguments:  see function printHelp
+# return:     0
+#                 No error or warning occurred.
+#
+function main {
+  # print welcome/info text if not suppressed
+  if [[ $@ != *"--noinfo"* ]]; then
+    printWelcomeText
+  else
+    printf "######################################################################\n"
+  fi
+  printf "\n"
+
+  # set log file if specified
+  if [[ $@ == *"--log"* ]] || [[ $@ == *"--LOG"* ]]; then
+    # get the parameter (file name)
+    local cmdidx=1
+    while [[ ! "${!cmdidx}" = "--log"* ]] && [[ ! "${!cmdidx}" = "--LOG"* ]]; do
+      cmdidx=$[cmdidx + 1]
+    done
+    local cmd="${!cmdidx}"
+    local logfile=""
+    if [[ "$cmd" = "--log="* ]] || [[ "$cmd" = "--LOG="* ]]; then
+      logfile=${cmd#*=}
+    else
+      local filenameidx=$((cmdidx + 1))
+      logfile="${!filenameidx}"
+    fi
+    # optionally force silent appending
+    if [[ "$cmd" = "--LOG"* ]]; then
+      setLogFile --option=a --quiet "$logfile" LOG_FILE
+    else
+      setLogFile "$logfile" LOG_FILE
+      printf "\n"
+    fi
+  fi
+
+  # log script name
+  printLog "this is $(realpath ${BASH_SOURCE[0]})\n"
+
+  # if --help or -h was specified, print the help text and exit
+  if [[ $@ == *"--help"* || $@ == *"-h"* ]]; then
+    printHelp
+    printf "\n"
+    quitScript
+  fi
+
+  # detect installed versions and inform user
+  local installedversions=()
+  local currentversion=""
+  detectInstalledVersions installedversions currentversion
+  case "${#installedversions[@]}" in
+    0)
+      printInfo "no installation has been detected\n";;
+    1)
+      printInfo "1 installation has been detected:\n";;
+    *)
+      printInfo "${#installedversions[@]} installations have been detected:\n";;
+  esac
+  for (( idx=0; idx<${#installedversions[@]}; ++idx )); do
+    if [ ${installedversions[$idx]} = "$currentversion" ]; then
+      printInfo "  * ${installedversions[$idx]}\n"
+    else
+      printInfo "    ${installedversions[$idx]}\n"
+    fi
+  done
+  printf "\n"
+
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -h|--help) # already handled; ignore
+          shift 1;;
+        -i|--init)
+          if [ -z "$currentversion" ]; then
+            installNewVersion
+          else
+            installNewVersion --install=$(realpath $(dirname "$currentversion")/../../) --link=$(realpath $(dirname "$currentversion")/../../)
+          fi
+          printf "\n"; shift 1;;
+        -c|--change)
+          changeDefaultVersion installedversions[@] $(realpath $(dirname "$currentversion")/../../); printf "\n"; shift 1;;
+        -q|--quit)
+          quitScript; shift 1;;
+        --log=*|--LOG=*) # already handled; ignore
+          shift 1;;
+        --log|--LOG) # already handled; ignore
+          shift 2;;
+        --noinfo) # already handled; ignore
+          shift 1;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
+  done
+
+  # interactive menu
+  while ( true ); do
+    # main menu info prompt and selection
+    printInfo "GCC setup main menu\n"
+    printf "Please select one of the following actions:\n"
+    printf "  [I] - install another version\n"
+    printf "  [C] - change default version\n"
+    printf "  [Q] - quit this setup\n"
+    local userinput=""
+    readUserInput "IiCcQq" userinput
+    printf "\n"
+
+    # evaluate user selection
+    case "$userinput" in
+      I|i)
+        if [ -z "$currentversion" ]; then
+          installNewVersion
+        else
+          installNewVersion --install=$(realpath $(dirname "$currentversion")/../../) --link=$(realpath $(dirname "$currentversion")/../../)
+        fi
+        printf "\n";;
+      C|c)
+        changeDefaultVersion installedversions[@] $(realpath $(dirname "$currentversion")/../../); printf "\n";;
+      Q|q)
+        quitScript;;
+      *) # sanity check (exit with error)
+        printError "unexpected argument: $userinput\n";;
+    esac
+  done
+
+  exit 0
+}
+
+################################################################################
+# SCRIPT ENTRY POINT                                                           #
+################################################################################
+
+main "$@"
diff --git a/compiler/compilersetup.sh b/compiler/compilersetup.sh
new file mode 100755
index 0000000..b2f0d00
--- /dev/null
+++ b/compiler/compilersetup.sh
@@ -0,0 +1,437 @@
+################################################################################
+# AMiRo-BLT is an bootloader and toolchain designed for the Autonomous Mini    #
+# Robot (AMiRo) platform.                                                      #
+# Copyright (C) 2016..2017  Thomas Schöpping et al.                            #
+#                                                                              #
+# This program is free software: you can redistribute it and/or modify         #
+# it under the terms of the GNU General Public License as published by         #
+# the Free Software Foundation, either version 3 of the License, or            #
+# (at your option) any later version.                                          #
+#                                                                              #
+# This program is distributed in the hope that it will be useful,              #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
+# GNU General Public License for more details.                                 #
+#                                                                              #
+# You should have received a copy of the GNU General Public License            #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
+#                                                                              #
+# This research/work was supported by the Cluster of Excellence Cognitive      #
+# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
+# funded by the German Research Foundation (DFG).                              #
+################################################################################
+
+#!/bin/bash
+
+################################################################################
+# GENERIC FUNCTIONS                                                            #
+################################################################################
+
+### print an error message #####################################################
+# Prints a error <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printError <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
+function printError {
+  local string="ERROR:   $1"
+  # if a log file is specified
+  if [ -n "$LOG_FILE" ]; then
+    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
+  fi
+  printf "$(tput setaf 1)>>> $string$(tput sgr 0)" 1>&2
+}
+
+### print a warning message ####################################################
+# Prints a warning <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printMessage <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
+function printWarning {
+  local string="WARNING: $1"
+  # if a log file is specified
+  if [ -n "$LOG_FILE" ]; then
+    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
+  fi
+  printf "$(tput setaf 3)>>> $string$(tput sgr 0)"
+}
+
+### print an information message ###############################################
+# Prints an information <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printInfo <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
+function printInfo {
+  local string="INFO:    $1"
+  # if a log file is specified
+  if [ -n "$LOG_FILE" ]; then
+    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
+  fi
+  printf "$(tput setaf 2)>>> $string$(tput sgr 0)"
+}
+
+### print a message to file ####################################################
+# Appends a <message> to a log file, specified by the variable 'LOG_FILE'.
+#
+# usage       printLog <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
+function printLog {
+  local string="LOG:     $1"
+  # if a log file is specified
+  if [ -n "$LOG_FILE" ]; then
+    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
+  fi
+}
+
+### exit the script normally ###################################################
+# Prints a delimiter and exits the script normally (returns 0).
+#
+# usage:      quitScript
+# arguments:  n/a
+# return:     0
+#                 No error or warning occurred.
+#
+function quitScript {
+  printLog "exiting $(realpath ${BASH_SOURCE[0]})\n"
+  printf "######################################################################\n"
+  exit 0
+}
+
+### read a user input ##########################################################
+# Reads a single character user input from a set up <options> and stores it in
+# a given <return> variable.
+#
+# usage:      readUserInput <options> <return>
+# arguments:  <options>
+#                 String definiing the set of valid characters.
+#                 If the string is empty, the user can input any character.
+#             <return>
+#                 Variable to store the selected character to.
+# return:     n/a
+#
+function readUserInput {
+  local input=""
+  # read user input
+  while [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); do
+    read -p "your selection: " -n 1 -e input
+    if [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); then
+      printWarning "[$input] is no valid action\n"
+    fi
+  done
+  printLog "[$input] has been selected\n"
+  eval $2="$input"
+}
+
+### check whether argument is an option ########################################
+# Checks a <string> whether it is an option.
+# Options are defined to either start with '--' followed by any string, or
+# to start with a single '-' followed by a single character, or
+# to start with a single '-' followed by a single character, a '=' and any string.
+# Examples: '--option', '--option=arg', '-o', '-o=arg', '--'
+#
+# usage:      parseIsOption <string>
+# arguments:  <string>
+#                 A string to check whether it is an option.
+# return:     0
+#                 <string> is an option.
+#             -1
+#                 <string> is not an option.
+#
+function parseIsOption {
+  if [[ "$1" =~ ^-(.$|.=.*) ]] || [[ "$1" =~ ^--.* ]]; then
+    return 0
+  else
+    return -1
+  fi
+}
+
+### set the log file ###########################################################
+# Sets a specified <infile> as log file and checks whether it already exists.
+# If so, the log may either be appended to the file, its content can be cleared,
+# or no log is generated at all.
+# The resulting path is stored in <outvar>.
+#
+# usage:      setLogFile [--option=<option>] [--quiet] <infile> <outvar>
+# arguments:  --option=<option>
+#                 Select what to do if <file> already exists.
+#                 Possible values are 'a', 'r' and 'n'.
+#                 - a: append
+#                 - r: delete and restart
+#                 - n: no log
+#                 If no option is secified but <file> exists, an interactive selection is provided.
+#             --quiet
+#                 Suppress all messages.
+#             <infile>
+#                 Path of the wanted log file.
+#             <outvar>
+#                 Variable to store the path of the log file to.
+# return:     0
+#                 No error or warning occurred.
+#             -1
+#                 Error: invalid input
+#
+function setLogFile {
+  local filepath=""
+  local option=""
+  local quiet=false
+
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -o=*|--option=*)
+          option=${1#*=}; shift 1;;
+        -o*|--option*)
+          option="$2"; shift 2;;
+        -q|--quiet)
+          quiet=true; shift 1;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
+  done
+  filepath=$(realpath ${otherargs[0]})
+
+  # if file already exists
+  if [ -e $filepath ]; then
+    # if no option was specified, ask what to do
+    if [ -z "$option" ]; then
+      printWarning "log file $filepath already esists\n"
+      local userinput=""
+      printf "Select what to do:\n"
+      printf "  [A] - append log\n"
+      printf "  [R] - restart log (delete existing file)\n"
+      printf "  [N] - no log\n"
+      readUserInput "AaRrNn" userinput
+      option=${userinput,,}
+    fi
+    # evaluate option
+    case "$option" in
+      a)
+        if [ $quiet = false ]; then
+          printInfo "appending log to $filepath\n"
+        fi
+        printf "\n" >> $filepath
+        printf "######################################################################\n" >> $filepath
+        printf "\n" >> $filepath
+        ;;
+      r)
+        echo -n "" > $filepath
+        if [ $quiet = false ]; then
+          printInfo "content of $filepath wiped\n"
+        fi
+        ;;
+      n)
+        if [ $quiet = false ]; then
+          printInfo "no log file will be generated\n"
+        fi
+        filepath=""
+        ;;
+      *) # sanity check (return error)
+        printError "unexpected argument: $option\n"; return -1;;
+    esac
+  else
+    if [ $quiet = false ]; then
+      printInfo "log file set to $filepath\n"
+    fi
+  fi
+
+  eval ${otherargs[1]}="$filepath"
+
+  return 0
+}
+
+################################################################################
+# SPECIFIC FUNCTIONS                                                           #
+################################################################################
+
+### print welcome text #########################################################
+# Prints a welcome message to standard out.
+#
+# usage:      printWelcomeText
+# arguments:  n/a
+# return:     n/a
+#
+function printWelcomeText {
+  printf "######################################################################\n"
+  printf "#                                                                    #\n"
+  printf "#              Welcome to the AMiRo-BLT compiler setup!              #\n"
+  printf "#                                                                    #\n"
+  printf "######################################################################\n"
+  printf "#                                                                    #\n"
+  printf "# Copyright (c) 2016..2017  Thomas Schöpping                         #\n"
+  printf "#                                                                    #\n"
+  printf "# This is free software; see the source for copying conditions.      #\n"
+  printf "# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR  #\n"
+  printf "# A PARTICULAR PURPOSE. The development of this software was         #\n"
+  printf "# supported by the Excellence Cluster EXC 227 Cognitive Interaction  #\n"
+  printf "# Technology. The Excellence Cluster EXC 227 is a grant of the       #\n"
+  printf "# Deutsche Forschungsgemeinschaft (DFG) in the context of the German #\n"
+  printf "# Excellence Initiative.                                             #\n"
+  printf "#                                                                    #\n"
+  printf "######################################################################\n"
+}
+
+### print help #################################################################
+# Prints a help text to standard out.
+#
+# usage:      printHelp
+# arguments:  n/a
+# return:     n/a
+#
+function printHelp {
+  printInfo "printing help text\n"
+  printf "usage:    $(basename ${BASH_SOURCE[0]}) [-h|--help] [--GCC] [-q|--quit] [--log=<file>]\n"
+  printf "\n"
+  printf "options:  -h, --help\n"
+  printf "              Print this help text.\n"
+  printf "          --GCC\n"
+  printf "              Enter GCC setup.\n"
+  printf "          -q, --quit\n"
+  printf "              Quit the script.\n"
+  printf "          --log=<file>\n"
+  printf "              Specify a log file.\n"
+}
+
+### enter GCC setup ############################################################
+# Enter the arm-none-eabi-gcc setup.
+#
+# usage:      gccSetup
+# arguments:  n/a
+# return:     n/a
+function gccSetup {
+  printInfo "entering GCC setup...\n"
+  printf "\n"
+  if [ -z "$LOG_FILE" ]; then
+    $(realpath $(dirname ${BASH_SOURCE[0]}))/GCC/gccsetup.sh --noinfo
+  else
+    $(realpath $(dirname ${BASH_SOURCE[0]}))/GCC/gccsetup.sh --LOG="$LOG_FILE" --noinfo
+  fi
+}
+
+### main function of this script ###############################################
+# The IDE setup lets the user select an IDE of choice.
+# As of now, only QtCreator is supported.
+#
+# usage:      see function printHelp
+# arguments:  see function printHelp
+# return:     0
+#                 No error or warning occurred.
+#
+function main {
+  # print welcome/info text if not suppressed
+  if [[ $@ != *"--noinfo"* ]]; then
+    printWelcomeText
+  else
+    printf "######################################################################\n"
+  fi
+  printf "\n"
+
+  # set log file if specified
+  if [[ $@ == *"--log"* ]] || [[ $@ == *"--LOG"* ]]; then
+    # get the parameter (file name)
+    local cmdidx=1
+    while [[ ! "${!cmdidx}" = "--log"* ]] && [[ ! "${!cmdidx}" = "--LOG"* ]]; do
+      cmdidx=$[cmdidx + 1]
+    done
+    local cmd="${!cmdidx}"
+    local logfile=""
+    if [[ "$cmd" = "--log="* ]] || [[ "$cmd" = "--LOG="* ]]; then
+      logfile=${cmd#*=}
+    else
+      local filenameidx=$((cmdidx + 1))
+      logfile="${!filenameidx}"
+    fi
+    # optionally force silent appending
+    if [[ "$cmd" = "--LOG"* ]]; then
+      setLogFile --option=a --quiet "$logfile" LOG_FILE
+    else
+      setLogFile "$logfile" LOG_FILE
+      printf "\n"
+    fi
+  fi
+
+  # log script name
+  printLog "this is $(realpath ${BASH_SOURCE[0]})\n"
+
+  # if --help or -h was specified, print the help text and exit
+  if [[ $@ == *"--help"* || $@ == *"-h"* ]]; then
+    printHelp
+    printf "\n"
+    quitScript
+  fi
+
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -h|--help) # already handled; ignore
+          shift 1;;
+        --GCC)
+          gccSetup; printf "\n"; shift 1;;
+        -q|--quit)
+          quitScript; printf "\n"; shift 1;;
+        --log=*|--LOG=*) # already handled; ignore
+          shift 1;;
+        --log|--LOG) # already handled; ignore
+          shift 2;;
+        --noinfo) # already handled; ignore
+          shift 1;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
+  done
+
+  # interactive menu
+  while ( true ); do
+    # main menu info prompt and selection
+    printInfo "AMiRo-BLT compiler setup main menu\n"
+    printf "Please select one of the following actions:\n"
+    printf "  [G] - enter GCC setup\n"
+    printf "  [Q] - quit this setup\n"
+    local userinput=""
+    readUserInput "GgQq" userinput
+    printf "\n"
+
+    # evaluate user selection
+    case "$userinput" in
+      G|g)
+        gccSetup; printf "\n";;
+      Q|q)
+        quitScript;;
+      *) # sanity check (exit with error)
+        printError "unexpected argument: $userinput\n"; printf "\n";;
+    esac
+  done
+
+  exit 0
+}
+
+################################################################################
+# SCRIPT ENTRY POINT                                                           #
+################################################################################
+
+main "$@"
diff --git a/ide/QtCreator/QtCreatorSetup.sh b/ide/QtCreator/QtCreatorSetup.sh
index e7a2fb8..c7158eb 100755
--- a/ide/QtCreator/QtCreatorSetup.sh
+++ b/ide/QtCreator/QtCreatorSetup.sh
@@ -27,256 +27,249 @@
 # GENERIC FUNCTIONS                                                            #
 ################################################################################
 
-### print an error
-# arguments:
-#   - error string [required]
-# return: n/a
+### print an error message #####################################################
+# Prints a error <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printError <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
 function printError {
   local string="ERROR:   $1"
-
   # if a log file is specified
-  if [ ! -z $LOG_FILE ]; then
+  if [ -n "$LOG_FILE" ]; then
     printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
   fi
   printf "$(tput setaf 1)>>> $string$(tput sgr 0)" 1>&2
 }
 
-### print a warning
-# arguments:
-#   - warning string [required]
-# return: n/a
+### print a warning message ####################################################
+# Prints a warning <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printMessage <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
 function printWarning {
   local string="WARNING: $1"
-
   # if a log file is specified
-  if [ ! -z $LOG_FILE ]; then
+  if [ -n "$LOG_FILE" ]; then
     printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
   fi
-  printf "$(tput setaf 3)>>> $string$(tput sgr 0)" 1>&2
+  printf "$(tput setaf 3)>>> $string$(tput sgr 0)"
 }
 
-### print an information text
-# arguments:
-#   - information string [required]
-# return: n/a
+### print an information message ###############################################
+# Prints an information <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printInfo <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
 function printInfo {
   local string="INFO:    $1"
-
   # if a log file is specified
-  if [ ! -z $LOG_FILE ]; then
+  if [ -n "$LOG_FILE" ]; then
     printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
   fi
-  printf "$(tput setaf 2)>>> $string$(tput sgr 0)" 1>&2
+  printf "$(tput setaf 2)>>> $string$(tput sgr 0)"
 }
 
-### print a message to the log file
-# arguments:
-#   - information string [required]
-# return: n/a
+### print a message to file ####################################################
+# Appends a <message> to a log file, specified by the variable 'LOG_FILE'.
+#
+# usage       printLog <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
 function printLog {
   local string="LOG:     $1"
-
   # if a log file is specified
-  if [ ! -z $LOG_FILE ]; then
+  if [ -n "$LOG_FILE" ]; then
     printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
   fi
 }
 
-### exit the script normally
-# arguments: n/a
-# return: 0 (success)
+### exit the script normally ###################################################
+# Prints a delimiter and exits the script normally (returns 0).
+#
+# usage:      quitScript
+# arguments:  n/a
+# return:     0
+#                 No error or warning occurred.
+#
 function quitScript {
-  printInfo "exiting $(realpath ${BASH_SOURCE[0]})\n"
-  printf "\n"
+  printLog "exiting $(realpath ${BASH_SOURCE[0]})\n"
   printf "######################################################################\n"
-
   exit 0
 }
 
-### read a user input
-# arguments:
-#   --numchars, -n  maximum number of characters to read
-#   --options, -o   possible chacters to select (only applies if numchars=1)
-#   --out, -e       output variable to store the user input to
-# return: error code
-#   -  0: no error
-#   - -1: error: invalid arguments
+### read a user input ##########################################################
+# Reads a single character user input from a set up <options> and stores it in
+# a given <return> variable.
+#
+# usage:      readUserInput <options> <return>
+# arguments:  <options>
+#                 String definiing the set of valid characters.
+#                 If the string is empty, the user can input any character.
+#             <return>
+#                 Variable to store the selected character to.
+# return:     n/a
+#
 function readUserInput {
-  # parse arguments
-  local arguments=$(getopt -l num-chars:,options:,out: -o n:o:e: -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
-    return -1
-  fi
-  eval set -- "$arguments"
-
-  # evaluate arguments
-  local numchars=0
-  local options=""
-  local outvar=""
-  while [ true ]; do
-    case "$1" in
-      --num-chars|-n)
-        numchars=$2; shift 2
-        ;;
-      --options|-o)
-        options="$2"; shift 2
-        ;;
-      --out|-e)
-        outvar=$2; shift 2
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (return error)
-        printError "unexpected argument: $1\n"; return -1
-        ;;
-    esac
-  done
-
+  local input=""
   # read user input
-  local _userinput=""
-  while [ -z $_userinput ] || ( [ $numchars == 1 ] && [ ! -z "$options" ] && [[ ! $_userinput =~ ^["$options"]$ ]] ); do
-    if [ $numchars == 0 ]; then
-      read -p "your selection: " -e _userinput
-    else
-      read -p "your selection: " -n $numchars -e _userinput
-    fi
-    if [ -z $_userinput ] || ( [ $numchars == 1 ] && [ ! -z "$options" ] && [[ ! $_userinput =~ ^["$options"]$ ]] ); then
-      printWarning "[$_userinput] is no valid action\n"
+  while [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); do
+    read -p "your selection: " -n 1 -e input
+    if [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); then
+      printWarning "[$input] is no valid action\n"
     fi
   done
-  printLog "[$_userinput] has been selected\n"
-  if [ ! -z "$outvar" ]; then
-    eval $outvar="$_userinput"
-  fi
-
-  return 0
+  printLog "[$input] has been selected\n"
+  eval $2="$input"
 }
 
-### set the log file
-# arguments:
-#   --file, -f    name of file [required]
-#   --option, -o  option if file already exists [optional]
-#                 a: append
-#                 r: delete and restart
-#                 n: disable log
-#                 A: silent append (no message in the log file)
-# return: error code
-#   -  0: no error
-#   -  1: warning: file already exists
-#   -  2: warning: no file specified
-#   - -1: error: invalid arguments
-function setLogFile {
-  # parse arguments
-  local arguments=$(getopt -l file:,option: -o f:o: -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
+### check whether argument is an option ########################################
+# Checks a <string> whether it is an option.
+# Options are defined to either start with '--' followed by any string, or
+# to start with a single '-' followed by a single character, or
+# to start with a single '-' followed by a single character, a '=' and any string.
+# Examples: '--option', '--option=arg', '-o', '-o=arg', '--'
+#
+# usage:      parseIsOption <string>
+# arguments:  <string>
+#                 A string to check whether it is an option.
+# return:     0
+#                 <string> is an option.
+#             -1
+#                 <string> is not an option.
+#
+function parseIsOption {
+  if [[ "$1" =~ ^-(.$|.=.*) ]] || [[ "$1" =~ ^--.* ]]; then
+    return 0
+  else
     return -1
   fi
-  eval set -- "$arguments"
+}
 
-  # evaluate arguments
-  local fname=""
+### set the log file ###########################################################
+# Sets a specified <infile> as log file and checks whether it already exists.
+# If so, the log may either be appended to the file, its content can be cleared,
+# or no log is generated at all.
+# The resulting path is stored in <outvar>.
+#
+# usage:      setLogFile [--option=<option>] [--quiet] <infile> <outvar>
+# arguments:  --option=<option>
+#                 Select what to do if <file> already exists.
+#                 Possible values are 'a', 'r' and 'n'.
+#                 - a: append
+#                 - r: delete and restart
+#                 - n: no log
+#                 If no option is secified but <file> exists, an interactive selection is provided.
+#             --quiet
+#                 Suppress all messages.
+#             <infile>
+#                 Path of the wanted log file.
+#             <outvar>
+#                 Variable to store the path of the log file to.
+# return:     0
+#                 No error or warning occurred.
+#             -1
+#                 Error: invalid input
+#
+function setLogFile {
+  local filepath=""
   local option=""
-  while [ true ]; do
-    case "$1" in
-      --file|f)
-        if [ ! -z $2 ]; then
-          fname="$(dirname $2)/$(basename $2)"
-        else
-          fname=""
-        fi
-        shift 2
-        ;;
-      --option|-o)
-        case $2 in
-          A)
-            option="A"
-            ;;
-          a)
-            option="a"
-            ;;
-          r)
-            option="r"
-            ;;
-          n)
-            option="n"
-            ;;
-          *) # sanity check (return error)
-            printError "unexpected argument: $1\n"; return -1
-            ;;
-        esac
-        shift 2
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (return error)
-        printError "unexpected argument: $1\n"; return -1
-        ;;
-    esac
+  local quiet=false
+
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -o=*|--option=*)
+          option=${1#*=}; shift 1;;
+        -o*|--option*)
+          option="$2"; shift 2;;
+        -q|--quiet)
+          quiet=true; shift 1;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
   done
+  filepath=$(realpath ${otherargs[0]})
 
-  # if no log file was specified
-  if [ -z $fname ]; then
-    printWarning "no log file specified (no log will be genreated)\n"
-    LOG_FILE=""
-    return 2
   # if file already exists
-  elif [ -f $fname ]; then
+  if [ -e $filepath ]; then
     # if no option was specified, ask what to do
-    if [ -z $option ]; then
-      printWarning "log file ${fname} already esists\n"
-      printf "Options:\n"
+    if [ -z "$option" ]; then
+      printWarning "log file $filepath already esists\n"
+      local userinput=""
+      printf "Select what to do:\n"
       printf "  [A] - append log\n"
       printf "  [R] - restart log (delete existing file)\n"
       printf "  [N] - no log\n"
-      readUserInput --num-chars=1 --options="AaRrNn" --out=userinput
+      readUserInput "AaRrNn" userinput
       option=${userinput,,}
     fi
-
     # evaluate option
-    case $option in
-      A)
-        LOG_FILE=$(realpath $fname)
-        ;;
+    case "$option" in
       a)
-        printInfo "appending log to existing file\n"
-        LOG_FILE=$(realpath $fname)
-        printf "\n" >> $LOG_FILE
-        printf "######################################################################\n" >> $LOG_FILE
-        printf "\n" >> $LOG_FILE
+        if [ $quiet = false ]; then
+          printInfo "appending log to $filepath\n"
+        fi
+        printf "\n" >> $filepath
+        printf "######################################################################\n" >> $filepath
+        printf "\n" >> $filepath
         ;;
       r)
-        printInfo "old log file deleted, starting clean\n"
-        LOG_FILE=$(realpath $fname)
-        rm $LOG_FILE
+        echo -n "" > $filepath
+        if [ $quiet = false ]; then
+          printInfo "content of $filepath wiped\n"
+        fi
         ;;
       n)
-        printInfo "no log file will be generated\n"
-        LOG_FILE=""
+        if [ $quiet = false ]; then
+          printInfo "no log file will be generated\n"
+        fi
+        filepath=""
         ;;
       *) # sanity check (return error)
-        printError "unexpected argument: $1\n"; return -1
-        ;;
+        printError "unexpected argument: $option\n"; return -1;;
     esac
-
-    return 1
   else
-    printInfo "log file set to $(realpath $fname)\n"
-    LOG_FILE=$(realpath $fname)
-    return 0
+    if [ $quiet = false ]; then
+      printInfo "log file set to $filepath\n"
+    fi
   fi
+
+  eval ${otherargs[1]}="$filepath"
+
+  return 0
 }
 
 ################################################################################
 # SPECIFIC FUNCTIONS                                                           #
 ################################################################################
 
-### print welcome text
-# arguments: n/a
-# return: n/a
+### print welcome text #########################################################
+# Prints a welcome message to standard out.
+#
+# usage:      printWelcomeText
+# arguments:  n/a
+# return:     n/a
+#
 function printWelcomeText {
   printf "######################################################################\n"
   printf "#                                                                    #\n"
@@ -297,104 +290,127 @@ function printWelcomeText {
   printf "######################################################################\n"
 }
 
-### print help text
-# arguments: n/a
-# return: n/a
+### print help #################################################################
+# Prints a help text to standard out.
+#
+# usage:      printHelp
+# arguments:  n/a
+# return:     n/a
+#
 function printHelp {
   printInfo "printing help text\n"
-  printf "usage:  $(basename ${BASH_SOURCE[0]}) [options]\n"
-  printf "options:\n"
-  printf "  --help, -h              Print this help text.\n"
-  printf "  --clean, -c             Delete project files.\n"
-  printf "  --wipe, -w              Delete project and .user files.\n"
-  printf "  --LightRing, -L         Create a project for the LightRing module.\n"
-  printf "  --PowerManagement, -P   Create a project for the PowerManagement module.\n"
-  printf "  --DiWheelDrive, -D      Create a project for the DiWheelDrive module.\n"
-  printf "  --All, -A               Create projects for all modules.\n"
-  printf "  --quit, -q              Quit the script.\n"
-  printf "  --log=<file>            Specify a log file.\n"
+  printf "usage:    $(basename ${BASH_SOURCE[0]}) [-h|--help] [-c|--clean] [-w|--wipe] [--LightRing] [--PowerManagement] [--DiWheelDrive] [-a|--all] [-q|--quit] [--log=<file>]\n"
+  printf "\n"
+  printf "options:  -h, --help\n"
+  printf "              Print this help text.\n"
+  printf "          -c, --clean\n"
+  printf "              Delete project files.\n"
+  printf "          -w, --wipe\n"
+  printf "              Delete project and .user files.\n"
+  printf "          --LightRing\n"
+  printf "              Create project for the LightRing module.\n"
+  printf "          --PowerManagement\n"
+  printf "              Create project for the PowerManagement module.\n"
+  printf "          --DiWheelDrive\n"
+  printf "              Create project for the DiWheelDrive module.\n"
+  printf "          -a, --all\n"
+  printf "              Create projects for all modules.\n"
+  printf "          -q, --quit\n"
+  printf "              Quit the script.\n"
+  printf "          --log=<file>\n"
+  printf "              Specify a log file.\n"
 }
 
-### read directory where to create/delete projects
-# arguments:
-#   - $1: variable to store the path to [required]
-# return: n/a
+### read directory where to create/delete projects #############################
+# Read the directory where to create/delete project files from user.
+#
+# usage:      getProjectDir <pathvar>
+# arguments:  <pathvar>
+#                 Variable to store the selected path to.
+# return:     n/a
+#
 function getProjectDir {
-  printLog "reading path for project files\n"
-  local amirobltdir="$(realpath $(dirname ${BASH_SOURCE[0]})/../../Target/)"
-  local pojectdir=""
-  read -p "Path where to create/delete project files: " -i $amirobltdir -e projectdir
-  printLog "user selected path $(realpath $projectdir)\n"
-  eval $1="$(realpath $projectdir)"
+  printLog "reading path for project files from user...\n"
+  local amirobltdir=$(realpath $(dirname $(realpath ${BASH_SOURCE[0]}))/../../Target/)
+  local input=""
+  read -p "Path where to create/delete project files: " -i $amirobltdir -e input
+  printLog "user selected path $(realpath $input)\n"
+  eval $1="$(realpath $input)"
 }
 
-### retrieves the ARM-NONE-EABI-GCC include directory
-# arguments:
-#   - $1: variable to store the path to [required]
-# return:
-#  -  0: no error
-#  - -1: error: arm-none-eabi-gcc not found
+### retrieves the ARM-NONE-EABI-GCC include directory ##########################
+# Retrieves the include directory of the currently set arm-none-eabi-gcc.
+#
+# usage:      retrieveGccIncludeDir <path>
+# arguments:  <path>
+#                 Variable to store the path to.
+# return:    0
+#                 No error or warning occurred.
+#            -1
+#                 Error: Command 'arm-none-eabi-gcc' not found.
+#
 function retrieveGccIncludeDir {
   # retrieve binary path or link
-  local binpath="$(which arm-none-eabi-gcc)"
+  local binpath=$(which arm-none-eabi-gcc)
   if [ -z "$binpath" ]; then
-    printError "arm-none-eabi-gcc not found\n"
+    printError "command 'arm-none-eabi-gcc' not found\n"
     return -1
-  fi
+  else 
 
-  # traverse any links
-  while [ -L "$binpath" ]; do
-    binpath=$(readlink $binpath)
-  done
-  printInfo "gcc-arm-none-eabi detected: $binpath\n"
+    # traverse any links
+    while [ -L "$binpath" ]; do
+      binpath=$(readlink $binpath)
+    done
+    printInfo "gcc-arm-none-eabi detected: $binpath\n"
 
-  # return include path
-  eval $1=$(realpath $(dirname ${binpath})/../arm-none-eabi/include/)
+    # return include path
+    eval $1=$(realpath $(dirname ${binpath})/../arm-none-eabi/include/)
 
-  return 0
+    return 0
+  fi
 }
 
-### delete project files
-# arguments:
-#  --path, -p <path>  path where to delete the project files
-#  --out, -o <var>    variable to store the path to
-#  --wipe, -w         delete .user files as well
+### delete project files #######################################################
+# Deletes all project files and optionally .user files, too.
+#
+# usage:      deleteProjects [-p|--path=<path>] [-o|--out=<var>] [-w|-wipe]
+# arguments:  -p, --path <path>
+#                 Path where to delete the project files.
+#             -o, --out <var>
+#                 Variable to store the path to.
+#             -w, --wipe
+#                 Delete .user files as well.
 # return:
 #  -  0: no error
 #  -  1: warning: function aborted by user
 #  - -1: error: unexpected user input
 function deleteProjects {
-  # parse arguments
-  local arguments=$(getopt -l path:,out:,wipe -o p:o:w -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
-    return -1
-  fi
-  eval set -- "$arguments"
-
   local projectdir=""
   local outvar=""
   local wipe=false
 
-  # handle command line arguments
-  while [ true ]; do
-    case $1 in
-      --path|-p)
-        projectdir="$2"; shift 2
-        ;;
-      --out|-o)
-        outvar=$2; shift 2
-        ;;
-      --wipe|-w)
-        wipe=true; shift 1
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (exit with error)
-        printError "unexpected argument: $1\n"; return 1
-        ;;
-    esac
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -p=*|--path=*)
+          projectdir=$(realpath "${1#*=}"); shift 1;;
+        -p|--path)
+          projectdir=$(realpath "$2"); shift 2;;
+        -o=*|--out=*)
+          outvar=${1#*=}; shift 1;;
+        -o|--out)
+          outvar=$2; shift 2;;
+        -w|--wipe)
+          wipe=true; shift 1;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
   done
 
   # print message
@@ -440,46 +456,59 @@ function deleteProjects {
   return 0
 }
 
-### create LightRing project files
-# arguments:
-#  --path, -p <path>  path where to create the project files
-#  --out, -o <var>    variable to store the path to
-# return:
-#  -  0: no error
-#  -  1: warning: function aborted by user
-#  - -1: error: unexpected user input
+### create LightRing project files #############################################
+# Create project files for the LightRing module.
+#
+# usage:      createLightRingProject [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>]
+# arguments:  -p, --path <path>
+#                 Path where to create the project files.
+#             --gcc=<path>
+#                 Path to the GCC include directory.
+#             -o, --out <var>
+#                 Variable to store the path to.
+#             --gccout=<var>
+#                 Variable to store the path to the GCC include directory to.
+# return:     0
+#                 No error or warning occurred.
+#
 function createLightRingProject {
-  # parse arguments
-  local arguments=$(getopt -l path:,out: -o p:o: -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
-    return -1
-  fi
-  eval set -- "$arguments"
-
   local projectdir=""
+  local gccincludedir=""
   local outvar=""
+  local gccoutvar=""
 
-  # handle command line arguments
-  while [ true ]; do
-    case $1 in
-      --path|-p)
-        projectdir="$2"; shift 2
-        ;;
-      --out|-o)
-        outvar=$2; shift 2
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (exit with error)
-        printError "unexpected argument: $1\n"; return 1
-        ;;
-    esac
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -p=*|--path=*)
+          projectdir=$(realpath "${1#*=}"); shift 1;;
+        -p|--path)
+          projectdir=$(realpath "$2"); shift 2;;
+        --gcc=*)
+          gccincludedir=$(realpath "${1#*=}"); shift 1;;
+        --gcc)
+          gccincludedir=$(realpath "$2"); shift 2;;
+        -o=*|--out=*)
+          outvar=${1#*=}; shift 1;;
+        -o|--out)
+          outvar=$2; shift 2;;
+        --gccout=*)
+          gccoutvar=$(realpath "${1#*=}"); shift 1;;
+        --gccout)
+          gccoutvar=$(realpath "$2"); shift 2;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
   done
 
   # print message
-  printInfo "creating QtCreator project files for the LightRing module\n"
+  printInfo "creating QtCreator project files for the LightRing module...\n"
 
   # read project directory if required
   if [ -z "$projectdir" ]; then
@@ -487,10 +516,8 @@ function createLightRingProject {
   fi
 
   # retrieve gcc-arm-none-eabi include dir
-  local gccincludedir=""
-  retrieveGccIncludeDir gccincludedir
   if [ -z "$gccincludedir" ]; then
-    return -1
+    retrieveGccIncludeDir gccincludedir
   fi
 
   # create project files
@@ -515,54 +542,70 @@ function createLightRingProject {
     echo -e "" >> ${projectdir}/LightRing.creator
   fi
 
-  # store the path to the output variable, if required
+  # fill the output variables
   if [ ! -z "$outvar" ]; then
     eval $outvar="$projectdir"
   fi
+  if [ ! -z "$gccoutvar" ]; then
+    eval $gccoutvar="$gccincludedir"
+  fi
 
   return 0
 }
 
-### create PowerManagement project files
-# arguments:
-#  --path, -p <path>  path where to create the project files
-#  --out, -o <var>    variable to store the path to
-# return:
-#  -  0: no error
-#  -  1: warning: function aborted by user
-#  - -1: error: unexpected user input
+### create PowerManagement project files #######################################
+# Create project files for the PowerManagement module.
+#
+# usage:      createPowerManagementProject [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>]
+# arguments:  -p, --path <path>
+#                 Path where to create the project files.
+#             --gcc=<path>
+#                 Path to the GCC include directory.
+#             -o, --out <var>
+#                 Variable to store the path to.
+#             --gccout=<var>
+#                 Variable to store the path to the GCC include directory to.
+# return:     0
+#                 No error or warning occurred.
+#
 function createPowerManagementProject {
-  # parse arguments
-  local arguments=$(getopt -l path:,out: -o p:o: -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
-    return -1
-  fi
-  eval set -- "$arguments"
-
   local projectdir=""
+  local gccincludedir=""
   local outvar=""
+  local gccoutvar=""
 
-  # handle command line arguments
-  while [ true ]; do
-    case $1 in
-      --path|-p)
-        projectdir="$2"; shift 2
-        ;;
-      --out|-o)
-        outvar=$2; shift 2
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (exit with error)
-        printError "unexpected argument: $1\n"; return 1
-        ;;
-    esac
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -p=*|--path=*)
+          projectdir=$(realpath "${1#*=}"); shift 1;;
+        -p|--path)
+          projectdir=$(realpath "$2"); shift 2;;
+        --gcc=*)
+          gccincludedir=$(realpath "${1#*=}"); shift 1;;
+        --gcc)
+          gccincludedir=$(realpath "$2"); shift 2;;
+        -o=*|--out=*)
+          outvar=${1#*=}; shift 1;;
+        -o|--out)
+          outvar=$2; shift 2;;
+        --gccout=*)
+          gccoutvar=$(realpath "${1#*=}"); shift 1;;
+        --gccout)
+          gccoutvar=$(realpath "$2"); shift 2;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
   done
 
   # print message
-  printInfo "creating QtCreator project files for the PowerManagement module\n"
+  printInfo "creating QtCreator project files for the PowerManagement module...\n"
 
   # read project directory if required
   if [ -z "$projectdir" ]; then
@@ -570,16 +613,14 @@ function createPowerManagementProject {
   fi
 
   # retrieve gcc-arm-none-eabi include dir
-  local gccincludedir=""
-  retrieveGccIncludeDir gccincludedir
   if [ -z "$gccincludedir" ]; then
-    return -1
+    retrieveGccIncludeDir gccincludedir
   fi
 
   # create project files
   # generate a file that contains all subdirectories as includes (but ignore hidden and documentation directories)
   find $gccincludedir -type d > ${projectdir}/PowerManagement.includes
-  find $(realpath $(dirname ${BASH_SOURCE[0]})/../../Target/Source/) -type d | grep -v "ARMCM3_STM32" >> ${projectdir}/PowerManagement.includes
+  find $(realpath $(dirname ${BASH_SOURCE[0]})/../../Target/Source/) -type d | grep -v "ARMCM4_STM32" >> ${projectdir}/PowerManagement.includes
   find $(realpath $(dirname ${BASH_SOURCE[0]})/../../Target/Demo/ARMCM4_STM32F405_Power_Management_GCC/Boot/) -type d | grep -v "uip\|fatfs\|ethernetlib\|cmd\|ide" >> ${projectdir}/PowerManagement.includes
   # generate a file that specifies all files
   echo -n "" > ${projectdir}/PowerManagement.files
@@ -598,54 +639,70 @@ function createPowerManagementProject {
     echo -e "" >> ${projectdir}/PowerManagement.creator
   fi
 
-  # store the path to the output variable, if required
+  # fill the output variables
   if [ ! -z "$outvar" ]; then
     eval $outvar="$projectdir"
   fi
+  if [ ! -z "$gccoutvar" ]; then
+    eval $gccoutvar="$gccincludedir"
+  fi
 
   return 0
 }
 
-### create DiWheelDrive project files
-# arguments:
-#  --path, -p <path>  path where to create the project files
-#  --out, -o <var>    variable to store the path to
-# return:
-#  -  0: no error
-#  -  1: warning: function aborted by user
-#  - -1: error: unexpected user input
+### create DiWheelDrive project files ##########################################
+# Create project files for the DiWheelDrive module.
+#
+# usage:      createDiWheelDriveProject [-p|--path=<path>] [--gcc=<path>] [-o|--out=<var>] [--gccout=<var>]
+# arguments:  -p, --path <path>
+#                 Path where to create the project files.
+#             --gcc=<path>
+#                 Path to the GCC include directory.
+#             -o, --out <var>
+#                 Variable to store the path to.
+#             --gccout=<var>
+#                 Variable to store the path to the GCC include directory to.
+# return:     0
+#                 No error or warning occurred.
+#
 function createDiWheelDriveProject {
-  # parse arguments
-  local arguments=$(getopt -l path:,out: -o p:o: -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
-    return -1
-  fi
-  eval set -- "$arguments"
-
   local projectdir=""
+  local gccincludedir=""
   local outvar=""
+  local gccoutvar=""
 
-  # handle command line arguments
-  while [ true ]; do
-    case $1 in
-      --path|-p)
-        projectdir="$2"; shift 2
-        ;;
-      --out|-o)
-        outvar=$2; shift 2
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (exit with error)
-        printError "unexpected argument: $1\n"; return 1
-        ;;
-    esac
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -p=*|--path=*)
+          projectdir=$(realpath "${1#*=}"); shift 1;;
+        -p|--path)
+          projectdir=$(realpath "$2"); shift 2;;
+        --gcc=*)
+          gccincludedir=$(realpath "${1#*=}"); shift 1;;
+        --gcc)
+          gccincludedir=$(realpath "$2"); shift 2;;
+        -o=*|--out=*)
+          outvar=${1#*=}; shift 1;;
+        -o|--out)
+          outvar=$2; shift 2;;
+        --gccout=*)
+          gccoutvar=$(realpath "${1#*=}"); shift 1;;
+        --gccout)
+          gccoutvar=$(realpath "$2"); shift 2;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
   done
 
   # print message
-  printInfo "creating QtCreator project files for the DiWheelDrive module\n"
+  printInfo "creating QtCreator project files for the DiWheelDrive module...\n"
 
   # read project directory if required
   if [ -z "$projectdir" ]; then
@@ -653,10 +710,8 @@ function createDiWheelDriveProject {
   fi
 
   # retrieve gcc-arm-none-eabi include dir
-  local gccincludedir=""
-  retrieveGccIncludeDir gccincludedir
   if [ -z "$gccincludedir" ]; then
-    return -1
+    retrieveGccIncludeDir gccincludedir
   fi
 
   # create project files
@@ -681,93 +736,55 @@ function createDiWheelDriveProject {
     echo -e "" >> ${projectdir}/DiWheelDrive.creator
   fi
 
-  # store the path to the output variable, if required
+  # fill the output variables
   if [ ! -z "$outvar" ]; then
     eval $outvar="$projectdir"
   fi
+  if [ ! -z "$gccoutvar" ]; then
+    eval $gccoutvar="$gccincludedir"
+  fi
 
   return 0
 }
 
-### create project files for al modules
-# arguments:
-#  --path, -p <path>  path where to create the project files
-#  --out, -o <var>    variable to store the path to
-# return:
-#  -  0: no error
-#  -  1: warning: function aborted by user
-#  - -1: error: unexpected user input
+### create project files for al modules ########################################
+# Create project files for all modules.
+#
+# usage:      createAllProjects
+# arguments:  n/a
+# return:     0
+#                 No error or warning occurred.
+#
 function createAllProjects {
-  # parse arguments
-  local arguments=$(getopt -l path:,out: -o p:o: -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
-    return -1
-  fi
-  eval set -- "$arguments"
+  # print message
+  printInfo "creating QtCreator project files for the DiWheelDrive module...\n"
 
+  # read project directory
   local projectdir=""
-  local outvar=""
-
-  # handle command line arguments
-  while [ true ]; do
-    case $1 in
-      --path|-p)
-        projectdir="$2"; shift 2
-        ;;
-      --out|-o)
-        outvar=$2; shift 2
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (exit with error)
-        printError "unexpected argument: $1\n"; return 1
-        ;;
-    esac
-  done
-
-  # print message
-  printInfo "creating QtCreator projects files for all modules\n"
+  getProjectDir projectdir
+  printInfo "files will be created in $projectdir\n"
 
-  # read project directory if required
-  if [ -z "$projectdir" ]; then
-    getProjectDir projectdir
-  fi
+  # retrieve gcc-arm-none-eabi include dir
+  retrieveGccIncludeDir gccincludedir
 
   # create projects
-  createLightRingProject --path="$projectdir"
-  createPowerManagementProject --path="$projectdir"
-  createDiWheelDriveProject --path="$projectdir"
-
-  # store the path to the output variable, if required
-  if [ ! -z "$outvar" ]; then
-    eval $outvar="$projectdir"
-  fi
+  createLightRingProject --path="$projectdir" --gcc="$gccincludedir"
+  createPowerManagementProject --path="$projectdir" --gcc="$gccincludedir"
+  createDiWheelDriveProject --path="$projectdir" --gcc="$gccincludedir"
 
   return 0
 }
 
-################################################################################
-# SCRIPT MAIN FUNCTION                                                         #
-################################################################################
-
-### main function of this script
-# arguments: see help text
-# return: error code
-#   - 0: no error
-#   - 1: error
+### main function of this script ###############################################
+# Creates, deletes and wipes QtCreator project files for the three AMiRo base modules.
+#
+# usage:      see function printHelp
+# arguments:  see function printHelp
+# return:     0
+#                 No error or warning ocurred.
+#
 function main {
-
-  # parse arguments
-  local arguments=$(getopt -l help,clean,wipe,LightRing,PowerManagement,DiWheelDrive,All,quit,log:,LOG:,noinfo -o hcwLPDAq -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
-    exit 1
-  fi
-  eval set -- "$arguments"
-
-  # print welcome/info text if not suppressed
+# print welcome/info text if not suppressed
   if [[ $@ != *"--noinfo"* ]]; then
     printWelcomeText
   else
@@ -776,18 +793,25 @@ function main {
   printf "\n"
 
   # set log file if specified
-  if [[ $@ == *--log* || $@ == *--LOG* ]]; then
+  if [[ $@ == *"--log"* ]] || [[ $@ == *"--LOG"* ]]; then
     # get the parameter (file name)
     local cmdidx=1
-    while [ "${!cmdidx}" != "--log" ] && [ "${!cmdidx}" != "--LOG" ]; do
+    while [[ ! "${!cmdidx}" = "--log"* ]] && [[ ! "${!cmdidx}" = "--LOG"* ]]; do
       cmdidx=$[cmdidx + 1]
     done
-    local filenameidx=$[cmdidx + 1]
+    local cmd="${!cmdidx}"
+    local logfile=""
+    if [[ "$cmd" = "--log="* ]] || [[ "$cmd" = "--LOG="* ]]; then
+      logfile=${cmd#*=}
+    else
+      local filenameidx=$((cmdidx + 1))
+      logfile="${!filenameidx}"
+    fi
     # optionally force silent appending
-    if [ "${!cmdidx}" == "--LOG" ]; then
-      setLogFile --file="${!filenameidx}" --option=A
+    if [[ "$cmd" = "--LOG"* ]]; then
+      setLogFile --option=a --quiet "$logfile" LOG_FILE
     else
-      setLogFile --file="${!filenameidx}"
+      setLogFile "$logfile" LOG_FILE
       printf "\n"
     fi
   fi
@@ -802,87 +826,44 @@ function main {
     quitScript
   fi
 
-  # handle command line arguments
-  local projectfilesdir=""
-  while [ true ]; do
-    case $1 in
-      --help|-h) # already handled; ignore
-        shift 1;
-        ;;
-      --clean|-c)
-        if [ -z "$projectfilesdir" ]; then
-          deleteProjects --out=projectfilesdir
-        else
-          deleteProjects --path="$projectfilesdir"
-        fi
-        printf "\n"
-        shift 1
-        ;;
-      --wipe|-w)
-          if [ -z "$projectfilesdir" ]; then
-          deleteProjects --out=projectfilesdir
-        else
-          deleteProjects --wipe --path="$projectfilesdir"
-        fi
-        printf "\n"
-        shift 1
-        ;;
-      --LightRing|-L)
-        if [ -z "$projectfilesdir" ]; then
-          createLightRingProject --out=projectfilesdir
-        else
-          createLightRingProject --path="$projectfilesdir"
-        fi
-        printf "\n"
-        shift 1
-        ;;
-      --PowerManagement|-P)
-        if [ -z "$projectfilesdir" ]; then
-          createPowerManagementProject --out=projectfilesdir
-        else
-          createPowerManagementProject --path="$projectfilesdir"
-        fi
-        printf "\n"
-        shift 1
-        ;;
-      --DiWheelDrive|-D)
-        if [ -z "$projectfilesdir" ]; then
-          createDiWheelDriveProject --out=projectfilesdir
-        else
-          createDiWheelDriveProject --path="$projectfilesdir"
-        fi
-        printf "\n"
-        shift 1
-        ;;
-      --All|-A)
-        if [ -z "$projectfilesdir" ]; then
-          createAllProjects --out=projectfilesdir
-        else
-          createAllProjects --path="$projectfilesdir"
-        fi
-        printf "\n"
-        shift 1
-        ;;
-      --quit|-q)
-        quitScript
-        ;;
-      --log|--LOG) # already handled; ignore
-        shift 2
-        ;;
-      --noinfo) # already processed; ignore
-        shift 1
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (exit with error)
-        printError "unexpected argument: $1\n"; exit -1
-        ;;
-    esac
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -h|--help) # already handled; ignore
+          shift 1;;
+        -c|--clean)
+          deleteProjects; printf "\n"; shift 1;;
+        -w|--wipe)
+          deleteProjects --wipe; printf "\n"; shift 1;;
+        --LightRing)
+          createLightRingProject; printf "\n"; shift 1;;
+        --PowerManagement)
+          createPowerManagementProject; printf "\n"; shift 1;;
+        --DiWheelDrive)
+          createDiWheelDriveProject; printf "\n"; shift 1;;
+        -a|--all)
+          createAllProjects; printf "\n"; shift 1;;
+        -q|--quit)
+          quitScript; shift 1;;
+        --log=*|--LOG=*) # already handled; ignore
+          shift 1;;
+        --log|--LOG) # already handled; ignore
+          shift 2;;
+        --noinfo) # already handled; ignore
+          shift 1;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
   done
 
-  # interactive menu
-  while [ true ]; do
+# interactive menu
+  while ( true ); do
     # main menu info prompt and selection
     printInfo "QtCreator setup main menu\n"
     printf "Please select one of the following actions:\n"
@@ -893,35 +874,28 @@ function main {
     printf "  [D] - create a project for the DiWheelDrive module\n"
     printf "  [A] - create a project for all modules\n"
     printf "  [Q] - quit this setup\n"
-    readUserInput --num-chars=1 --options="CcWwLlPpDdAaQq" --out=userinput
+    local userinput=""
+    readUserInput "CcWwLlPpDdAaQq" userinput
     printf "\n"
 
     # evaluate user selection
-    case $userinput in
+    case "$userinput" in
       C|c)
-        deleteProjects; printf "\n"
-        ;;
+        deleteProjects; printf "\n";;
       W|w)
-        deleteProjects --wipe; printf "\n"
-        ;;
+        deleteProjects --wipe; printf "\n";;
       L|l)
-        createLightRingProject; printf "\n"
-        ;;
+        createLightRingProject; printf "\n";;
       P|p)
-        createPowerManagementProject; printf "\n"
-        ;;
+        createPowerManagementProject; printf "\n";;
       D|d)
-        createDiWheelDriveProject; printf "\n"
-        ;;
+        createDiWheelDriveProject; printf "\n";;
       A|a)
-        createAllProjects; printf "\n"
-        ;;
+        createAllProjects; printf "\n";;
       Q|q)
-        quitScript
-        ;;
+        quitScript;;
       *) # sanity check (exit with error)
-        printError "unexpected argument: $userinput\n"; exit -1
-        ;;
+        printError "unexpected argument: $userinput\n";;
     esac
   done
 
diff --git a/ide/idesetup.sh b/ide/idesetup.sh
new file mode 100755
index 0000000..6e110a4
--- /dev/null
+++ b/ide/idesetup.sh
@@ -0,0 +1,437 @@
+################################################################################
+# AMiRo-BLT is an bootloader and toolchain designed for the Autonomous Mini    #
+# Robot (AMiRo) platform.                                                      #
+# Copyright (C) 2016..2017  Thomas Schöpping et al.                            #
+#                                                                              #
+# This program is free software: you can redistribute it and/or modify         #
+# it under the terms of the GNU General Public License as published by         #
+# the Free Software Foundation, either version 3 of the License, or            #
+# (at your option) any later version.                                          #
+#                                                                              #
+# This program is distributed in the hope that it will be useful,              #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
+# GNU General Public License for more details.                                 #
+#                                                                              #
+# You should have received a copy of the GNU General Public License            #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
+#                                                                              #
+# This research/work was supported by the Cluster of Excellence Cognitive      #
+# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
+# funded by the German Research Foundation (DFG).                              #
+################################################################################
+
+#!/bin/bash
+
+################################################################################
+# GENERIC FUNCTIONS                                                            #
+################################################################################
+
+### print an error message #####################################################
+# Prints a error <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printError <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
+function printError {
+  local string="ERROR:   $1"
+  # if a log file is specified
+  if [ -n "$LOG_FILE" ]; then
+    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
+  fi
+  printf "$(tput setaf 1)>>> $string$(tput sgr 0)" 1>&2
+}
+
+### print a warning message ####################################################
+# Prints a warning <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printMessage <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
+function printWarning {
+  local string="WARNING: $1"
+  # if a log file is specified
+  if [ -n "$LOG_FILE" ]; then
+    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
+  fi
+  printf "$(tput setaf 3)>>> $string$(tput sgr 0)"
+}
+
+### print an information message ###############################################
+# Prints an information <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printInfo <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
+function printInfo {
+  local string="INFO:    $1"
+  # if a log file is specified
+  if [ -n "$LOG_FILE" ]; then
+    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
+  fi
+  printf "$(tput setaf 2)>>> $string$(tput sgr 0)"
+}
+
+### print a message to file ####################################################
+# Appends a <message> to a log file, specified by the variable 'LOG_FILE'.
+#
+# usage       printLog <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
+function printLog {
+  local string="LOG:     $1"
+  # if a log file is specified
+  if [ -n "$LOG_FILE" ]; then
+    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
+  fi
+}
+
+### exit the script normally ###################################################
+# Prints a delimiter and exits the script normally (returns 0).
+#
+# usage:      quitScript
+# arguments:  n/a
+# return:     0
+#                 No error or warning occurred.
+#
+function quitScript {
+  printLog "exiting $(realpath ${BASH_SOURCE[0]})\n"
+  printf "######################################################################\n"
+  exit 0
+}
+
+### read a user input ##########################################################
+# Reads a single character user input from a set up <options> and stores it in
+# a given <return> variable.
+#
+# usage:      readUserInput <options> <return>
+# arguments:  <options>
+#                 String definiing the set of valid characters.
+#                 If the string is empty, the user can input any character.
+#             <return>
+#                 Variable to store the selected character to.
+# return:     n/a
+#
+function readUserInput {
+  local input=""
+  # read user input
+  while [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); do
+    read -p "your selection: " -n 1 -e input
+    if [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); then
+      printWarning "[$input] is no valid action\n"
+    fi
+  done
+  printLog "[$input] has been selected\n"
+  eval $2="$input"
+}
+
+### check whether argument is an option ########################################
+# Checks a <string> whether it is an option.
+# Options are defined to either start with '--' followed by any string, or
+# to start with a single '-' followed by a single character, or
+# to start with a single '-' followed by a single character, a '=' and any string.
+# Examples: '--option', '--option=arg', '-o', '-o=arg', '--'
+#
+# usage:      parseIsOption <string>
+# arguments:  <string>
+#                 A string to check whether it is an option.
+# return:     0
+#                 <string> is an option.
+#             -1
+#                 <string> is not an option.
+#
+function parseIsOption {
+  if [[ "$1" =~ ^-(.$|.=.*) ]] || [[ "$1" =~ ^--.* ]]; then
+    return 0
+  else
+    return -1
+  fi
+}
+
+### set the log file ###########################################################
+# Sets a specified <infile> as log file and checks whether it already exists.
+# If so, the log may either be appended to the file, its content can be cleared,
+# or no log is generated at all.
+# The resulting path is stored in <outvar>.
+#
+# usage:      setLogFile [--option=<option>] [--quiet] <infile> <outvar>
+# arguments:  --option=<option>
+#                 Select what to do if <file> already exists.
+#                 Possible values are 'a', 'r' and 'n'.
+#                 - a: append
+#                 - r: delete and restart
+#                 - n: no log
+#                 If no option is secified but <file> exists, an interactive selection is provided.
+#             --quiet
+#                 Suppress all messages.
+#             <infile>
+#                 Path of the wanted log file.
+#             <outvar>
+#                 Variable to store the path of the log file to.
+# return:     0
+#                 No error or warning occurred.
+#             -1
+#                 Error: invalid input
+#
+function setLogFile {
+  local filepath=""
+  local option=""
+  local quiet=false
+
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -o=*|--option=*)
+          option=${1#*=}; shift 1;;
+        -o*|--option*)
+          option="$2"; shift 2;;
+        -q|--quiet)
+          quiet=true; shift 1;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
+  done
+  filepath=$(realpath ${otherargs[0]})
+
+  # if file already exists
+  if [ -e $filepath ]; then
+    # if no option was specified, ask what to do
+    if [ -z "$option" ]; then
+      printWarning "log file $filepath already esists\n"
+      local userinput=""
+      printf "Select what to do:\n"
+      printf "  [A] - append log\n"
+      printf "  [R] - restart log (delete existing file)\n"
+      printf "  [N] - no log\n"
+      readUserInput "AaRrNn" userinput
+      option=${userinput,,}
+    fi
+    # evaluate option
+    case "$option" in
+      a)
+        if [ $quiet = false ]; then
+          printInfo "appending log to $filepath\n"
+        fi
+        printf "\n" >> $filepath
+        printf "######################################################################\n" >> $filepath
+        printf "\n" >> $filepath
+        ;;
+      r)
+        echo -n "" > $filepath
+        if [ $quiet = false ]; then
+          printInfo "content of $filepath wiped\n"
+        fi
+        ;;
+      n)
+        if [ $quiet = false ]; then
+          printInfo "no log file will be generated\n"
+        fi
+        filepath=""
+        ;;
+      *) # sanity check (return error)
+        printError "unexpected argument: $option\n"; return -1;;
+    esac
+  else
+    if [ $quiet = false ]; then
+      printInfo "log file set to $filepath\n"
+    fi
+  fi
+
+  eval ${otherargs[1]}="$filepath"
+
+  return 0
+}
+
+################################################################################
+# SPECIFIC FUNCTIONS                                                           #
+################################################################################
+
+### print welcome text #########################################################
+# Prints a welcome message to standard out.
+#
+# usage:      printWelcomeText
+# arguments:  n/a
+# return:     n/a
+#
+function printWelcomeText {
+  printf "######################################################################\n"
+  printf "#                                                                    #\n"
+  printf "#                Welcome to the AMiRo-BLT IDE setup!                 #\n"
+  printf "#                                                                    #\n"
+  printf "######################################################################\n"
+  printf "#                                                                    #\n"
+  printf "# Copyright (c) 2016..2017  Thomas Schöpping                         #\n"
+  printf "#                                                                    #\n"
+  printf "# This is free software; see the source for copying conditions.      #\n"
+  printf "# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR  #\n"
+  printf "# A PARTICULAR PURPOSE. The development of this software was         #\n"
+  printf "# supported by the Excellence Cluster EXC 227 Cognitive Interaction  #\n"
+  printf "# Technology. The Excellence Cluster EXC 227 is a grant of the       #\n"
+  printf "# Deutsche Forschungsgemeinschaft (DFG) in the context of the German #\n"
+  printf "# Excellence Initiative.                                             #\n"
+  printf "#                                                                    #\n"
+  printf "######################################################################\n"
+}
+
+### print help #################################################################
+# Prints a help text to standard out.
+#
+# usage:      printHelp
+# arguments:  n/a
+# return:     n/a
+#
+function printHelp {
+  printInfo "printing help text\n"
+  printf "usage:    $(basename ${BASH_SOURCE[0]}) [-h|--help] [--QtCreator] [-q|--quit] [--log=<file>]\n"
+  printf "\n"
+  printf "options:  -h, --help\n"
+  printf "              Print this help text.\n"
+  printf "          --QtCreator\n"
+  printf "              Enter QtCreator setup.\n"
+  printf "          -q, --quit\n"
+  printf "              Quit the script.\n"
+  printf "          --log=<file>\n"
+  printf "              Specify a log file.\n"
+}
+
+### enter QtCreator setup ######################################################
+# Enter the QtCreator IDE setup.
+#
+# usage:      qtCreatorSetup
+# arguments:  n/a
+# return:     n/a
+function qtCreatorSetup {
+  printInfo "entering QtCreator setup...\n"
+  printf "\n"
+  if [ -z "$LOG_FILE" ]; then
+    $(realpath $(dirname ${BASH_SOURCE[0]}))/QtCreator/QtCreatorSetup.sh --noinfo
+  else
+    $(realpath $(dirname ${BASH_SOURCE[0]}))/QtCreator/QtCreatorSetup.sh --LOG="$LOG_FILE" --noinfo
+  fi
+}
+
+### main function of this script ###############################################
+# The IDE setup lets the user select an IDE of choice.
+# As of now, only QtCreator is supported.
+#
+# usage:      see function printHelp
+# arguments:  see function printHelp
+# return:     0
+#                 No error or warning occurred.
+#
+function main {
+  # print welcome/info text if not suppressed
+  if [[ $@ != *"--noinfo"* ]]; then
+    printWelcomeText
+  else
+    printf "######################################################################\n"
+  fi
+  printf "\n"
+
+  # set log file if specified
+  if [[ $@ == *"--log"* ]] || [[ $@ == *"--LOG"* ]]; then
+    # get the parameter (file name)
+    local cmdidx=1
+    while [[ ! "${!cmdidx}" = "--log"* ]] && [[ ! "${!cmdidx}" = "--LOG"* ]]; do
+      cmdidx=$[cmdidx + 1]
+    done
+    local cmd="${!cmdidx}"
+    local logfile=""
+    if [[ "$cmd" = "--log="* ]] || [[ "$cmd" = "--LOG="* ]]; then
+      logfile=${cmd#*=}
+    else
+      local filenameidx=$((cmdidx + 1))
+      logfile="${!filenameidx}"
+    fi
+    # optionally force silent appending
+    if [[ "$cmd" = "--LOG"* ]]; then
+      setLogFile --option=a --quiet "$logfile" LOG_FILE
+    else
+      setLogFile "$logfile" LOG_FILE
+      printf "\n"
+    fi
+  fi
+
+  # log script name
+  printLog "this is $(realpath ${BASH_SOURCE[0]})\n"
+
+  # if --help or -h was specified, print the help text and exit
+  if [[ $@ == *"--help"* || $@ == *"-h"* ]]; then
+    printHelp
+    printf "\n"
+    quitScript
+  fi
+
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -h|--help) # already handled; ignore
+          shift 1;;
+        --QtCreator)
+          qtCreatorSetup; printf "\n"; shift 1;;
+        -q|--quit)
+          quitScript; printf "\n"; shift 1;;
+        --log=*|--LOG=*) # already handled; ignore
+          shift 1;;
+        --log|--LOG) # already handled; ignore
+          shift 2;;
+        --noinfo) # already handled; ignore
+          shift 1;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
+  done
+
+  # interactive menu
+  while ( true ); do
+    # main menu info prompt and selection
+    printInfo "AMiRo-BLT IDE setup main menu\n"
+    printf "Please select one of the following actions:\n"
+    printf "  [C] - enter QtCreator setup\n"
+    printf "  [Q] - quit this setup\n"
+    local userinput=""
+    readUserInput "CcQq" userinput
+    printf "\n"
+
+    # evaluate user selection
+    case "$userinput" in
+      C|c)
+        qtCreatorSetup; printf "\n";;
+      Q|q)
+        quitScript;;
+      *) # sanity check (exit with error)
+        printError "unexpected argument: $userinput\n";;
+    esac
+  done
+
+  exit 0
+}
+
+################################################################################
+# SCRIPT ENTRY POINT                                                           #
+################################################################################
+
+main "$@"
diff --git a/ide/setup_IDE.sh b/ide/setup_IDE.sh
deleted file mode 100755
index ae061de..0000000
--- a/ide/setup_IDE.sh
+++ /dev/null
@@ -1,443 +0,0 @@
-################################################################################
-# AMiRo-BLT is an bootloader and toolchain designed for the Autonomous Mini    #
-# Robot (AMiRo) platform.                                                      #
-# Copyright (C) 2016..2017  Thomas Schöpping et al.                            #
-#                                                                              #
-# This program is free software: you can redistribute it and/or modify         #
-# it under the terms of the GNU General Public License as published by         #
-# the Free Software Foundation, either version 3 of the License, or            #
-# (at your option) any later version.                                          #
-#                                                                              #
-# This program is distributed in the hope that it will be useful,              #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
-# GNU General Public License for more details.                                 #
-#                                                                              #
-# You should have received a copy of the GNU General Public License            #
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
-#                                                                              #
-# This research/work was supported by the Cluster of Excellence Cognitive      #
-# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
-# funded by the German Research Foundation (DFG).                              #
-################################################################################
-
-#!/bin/bash
-
-################################################################################
-# GENERIC FUNCTIONS                                                            #
-################################################################################
-
-### print an error
-# arguments:
-#   - error string [required]
-# return: n/a
-function printError {
-  local string="ERROR:   $1"
-
-  # if a log file is specified
-  if [ ! -z $LOG_FILE ]; then
-    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
-  fi
-  printf "$(tput setaf 1)>>> $string$(tput sgr 0)" 1>&2
-}
-
-### print a warning
-# arguments:
-#   - warning string [required]
-# return: n/a
-function printWarning {
-  local string="WARNING: $1"
-
-  # if a log file is specified
-  if [ ! -z $LOG_FILE ]; then
-    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
-  fi
-  printf "$(tput setaf 3)>>> $string$(tput sgr 0)" 1>&2
-}
-
-### print an information text
-# arguments:
-#   - information string [required]
-# return: n/a
-function printInfo {
-  local string="INFO:    $1"
-
-  # if a log file is specified
-  if [ ! -z $LOG_FILE ]; then
-    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
-  fi
-  printf "$(tput setaf 2)>>> $string$(tput sgr 0)" 1>&2
-}
-
-### print a message to the log file
-# arguments:
-#   - information string [required]
-# return: n/a
-function printLog {
-  local string="LOG:     $1"
-
-  # if a log file is specified
-  if [ ! -z $LOG_FILE ]; then
-    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
-  fi
-}
-
-### exit the script normally
-# arguments: n/a
-# return: 0 (success)
-function quitScript {
-  printInfo "exiting $(realpath ${BASH_SOURCE[0]})\n"
-  printf "\n"
-  printf "######################################################################\n"
-
-  exit 0
-}
-
-### read a user input
-# arguments:
-#   --numchars, -n  maximum number of characters to read
-#   --options, -o   possible chacters to select (only applies if numchars=1)
-#   --out, -e       output variable to store the user input to
-# return: error code
-#   -  0: no error
-#   - -1: error: invalid arguments
-function readUserInput {
-  # parse arguments
-  local arguments=$(getopt -l num-chars:,options:,out: -o n:o:e: -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
-    return -1
-  fi
-  eval set -- "$arguments"
-
-  # evaluate arguments
-  local numchars=0
-  local options=""
-  local outvar=""
-  while [ true ]; do
-    case "$1" in
-      --num-chars|-n)
-        numchars=$2; shift 2
-        ;;
-      --options|-o)
-        options="$2"; shift 2
-        ;;
-      --out|-e)
-        outvar=$2; shift 2
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (return error)
-        printError "unexpected argument: $1\n"; return -1
-        ;;
-    esac
-  done
-
-  # read user input
-  local _userinput=""
-  while [ -z $_userinput ] || ( [ $numchars == 1 ] && [ ! -z "$options" ] && [[ ! $_userinput =~ ^["$options"]$ ]] ); do
-    if [ $numchars == 0 ]; then
-      read -p "your selection: " -e _userinput
-    else
-      read -p "your selection: " -n $numchars -e _userinput
-    fi
-    if [ -z $_userinput ] || ( [ $numchars == 1 ] && [ ! -z "$options" ] && [[ ! $_userinput =~ ^["$options"]$ ]] ); then
-      printWarning "[$_userinput] is no valid action\n"
-    fi
-  done
-  printLog "[$_userinput] has been selected\n"
-  if [ ! -z "$outvar" ]; then
-    eval $outvar="$_userinput"
-  fi
-
-  return 0
-}
-
-### set the log file
-# arguments:
-#   --file, -f    name of file [required]
-#   --option, -o  option if file already exists [optional]
-#                 a: append
-#                 r: delete and restart
-#                 n: disable log
-#                 A: silent append (no message in the log file)
-# return: error code
-#   -  0: no error
-#   -  1: warning: file already exists
-#   -  2: warning: no file specified
-#   - -1: error: invalid arguments
-function setLogFile {
-  # parse arguments
-  local arguments=$(getopt -l file:,option: -o f:o: -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
-    return -1
-  fi
-  eval set -- "$arguments"
-
-  # evaluate arguments
-  local fname=""
-  local option=""
-  while [ true ]; do
-    case "$1" in
-      --file|f)
-        if [ ! -z $2 ]; then
-          fname="$(dirname $2)/$(basename $2)"
-        else
-          fname=""
-        fi
-        shift 2
-        ;;
-      --option|-o)
-        case $2 in
-          A)
-            option="A"
-            ;;
-          a)
-            option="a"
-            ;;
-          r)
-            option="r"
-            ;;
-          n)
-            option="n"
-            ;;
-          *) # sanity check (return error)
-            printError "unexpected argument: $1\n"; return -1
-            ;;
-        esac
-        shift 2
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (return error)
-        printError "unexpected argument: $1\n"; return -1
-        ;;
-    esac
-  done
-
-  # if no log file was specified
-  if [ -z $fname ]; then
-    printWarning "no log file specified (no log will be genreated)\n"
-    LOG_FILE=""
-    return 2
-  # if file already exists
-  elif [ -f $fname ]; then
-    # if no option was specified, ask what to do
-    if [ -z $option ]; then
-      printWarning "log file ${fname} already esists\n"
-      printf "Options:\n"
-      printf "  [A] - append log\n"
-      printf "  [R] - restart log (delete existing file)\n"
-      printf "  [N] - no log\n"
-      readUserInput --num-chars=1 --options="AaRrNn" --out=userinput
-      option=${userinput,,}
-    fi
-
-    # evaluate option
-    case $option in
-      A)
-        LOG_FILE=$(realpath $fname)
-        ;;
-      a)
-        printInfo "appending log to existing file\n"
-        LOG_FILE=$(realpath $fname)
-        printf "\n" >> $LOG_FILE
-        printf "######################################################################\n" >> $LOG_FILE
-        printf "\n" >> $LOG_FILE
-        ;;
-      r)
-        printInfo "old log file deleted, starting clean\n"
-        LOG_FILE=$(realpath $fname)
-        rm $LOG_FILE
-        ;;
-      n)
-        printInfo "no log file will be generated\n"
-        LOG_FILE=""
-        ;;
-      *) # sanity check (return error)
-        printError "unexpected argument: $1\n"; return -1
-        ;;
-    esac
-
-    return 1
-  else
-    printInfo "log file set to $(realpath $fname)\n"
-    LOG_FILE=$(realpath $fname)
-    return 0
-  fi
-}
-
-################################################################################
-# SPECIFIC FUNCTIONS                                                           #
-################################################################################
-
-### print welcome text
-# arguments: n/a
-# return: n/a
-function printWelcomeText {
-  printf "######################################################################\n"
-  printf "#                                                                    #\n"
-  printf "#                Welcome to the AMiRo-BLT IDE setup!                 #\n"
-  printf "#                                                                    #\n"
-  printf "######################################################################\n"
-  printf "#                                                                    #\n"
-  printf "# Copyright (c) 2016..2017  Thomas Schöpping                         #\n"
-  printf "#                                                                    #\n"
-  printf "# This is free software; see the source for copying conditions.      #\n"
-  printf "# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR  #\n"
-  printf "# A PARTICULAR PURPOSE. The development of this software was         #\n"
-  printf "# supported by the Excellence Cluster EXC 227 Cognitive Interaction  #\n"
-  printf "# Technology. The Excellence Cluster EXC 227 is a grant of the       #\n"
-  printf "# Deutsche Forschungsgemeinschaft (DFG) in the context of the German #\n"
-  printf "# Excellence Initiative.                                             #\n"
-  printf "#                                                                    #\n"
-  printf "######################################################################\n"
-}
-
-### print help text
-# arguments: n/a
-# return: n/a
-function printHelp {
-  printInfo "printing help text\n"
-  printf "usage:  $(basename ${BASH_SOURCE[0]}) [options]\n"
-  printf "options:\n"
-  printf "  --help, -h        Print this help text.\n"
-  printf "  --QtCreator, -c   Generate QtCreator project files.\n"
-  printf "  --quit, -q        Quit the script.\n"
-  printf "  --log=<file>      Specify a log file.\n"
-}
-
-### enter QtCreator setup
-# arguments n/a
-# return:
-#  -  0: no error
-#  -  1: warning: function aborted by user
-#  - -1: error: unexpected user input
-function qtCreatorSetup {
-  printInfo "entering QtCreator setup\n"
-  printf "\n"
-  if [ -z "$LOG_FILE" ]; then
-    $(realpath $(dirname ${BASH_SOURCE}))/QtCreator/QtCreatorSetup.sh --noinfo
-  else
-    $(realpath $(dirname ${BASH_SOURCE}))/QtCreator/QtCreatorSetup.sh --LOG="$LOG_FILE" --noinfo
-  fi
-
-  return 0
-}
-
-################################################################################
-# SCRIPT MAIN FUNCTION                                                         #
-################################################################################
-
-### main function of this script
-# arguments: see help text
-# return: error code
-#   - 0: no error
-#   - 1: error
-function main {
-
-  # parse arguments
-  local arguments=$(getopt -l help,QtCreator,quit,log:,LOG:,noinfo -o hcq -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
-    exit 1
-  fi
-  eval set -- "$arguments"
-
-  # print welcome/info text if not suppressed
-  if [[ $@ != *"--noinfo"* ]]; then
-    printWelcomeText
-  else
-    printf "######################################################################\n"
-  fi
-  printf "\n"
-
-  # set log file if specified
-  if [[ $@ == *--log* || $@ == *--LOG* ]]; then
-    # get the parameter (file name)
-    local cmdidx=1
-    while [ "${!cmdidx}" != "--log" ] && [ "${!cmdidx}" != "--LOG" ]; do
-      cmdidx=$[cmdidx + 1]
-    done
-    local filenameidx=$[cmdidx + 1]
-    # optionally force silent appending
-    if [ "${!cmdidx}" == "--LOG" ]; then
-      setLogFile --file="${!filenameidx}" --option=A
-    else
-      setLogFile --file="${!filenameidx}"
-      printf "\n"
-    fi
-  fi
-
-  # log script name
-  printLog "this is $(realpath ${BASH_SOURCE[0]})\n"
-
-  # if --help or -h was specified, print the help text and exit
-  if [[ $@ == *"--help"* || $@ == *"-h"* ]]; then
-    printHelp
-    printf "\n"
-    quitScript
-  fi
-
-  # handle command line arguments
-  while [ true ]; do
-    case $1 in
-      --help|-h) # already handled; ignore
-        shift 1;
-        ;;
-      --QtCreator)
-        qtCreatorSetup; printf "\n"; shift 1
-        ;;
-      --quit|-q)
-        quitScript
-        ;;
-      --log|--LOG) # already handled; ignore
-        shift 2
-        ;;
-      --noinfo) # already processed; ignore
-        shift 1
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (exit with error)
-        printError "unexpected argument: $1\n"; exit -1
-        ;;
-    esac
-  done
-
-  # interactive menu
-  while [ true ]; do
-    # main menu info prompt and selection
-    printInfo "AMiRo-BLT IDE setup main menu\n"
-    printf "Please select one of the following actions:\n"
-    printf "  [C] - enter QtCreator setup\n"
-    printf "  [Q] - quit this setup\n"
-    readUserInput --num-chars=1 --options="CcQq" --out=userinput
-    printf "\n"
-
-    # evaluate user selection
-    case $userinput in
-      C|c)
-        qtCreatorSetup; printf "\n"
-        ;;
-      Q|q)
-        quitScript
-        ;;
-      *) # sanity check (exit with error)
-        printError "unexpected argument: $userinput\n"; exit -1
-        ;;
-    esac
-  done
-
-  exit 0
-}
-
-################################################################################
-# SCRIPT ENTRY POINT                                                           #
-################################################################################
-
-main "$@"
diff --git a/setup.sh b/setup.sh
index de13c05..fe7211f 100755
--- a/setup.sh
+++ b/setup.sh
@@ -27,256 +27,249 @@
 # GENERIC FUNCTIONS                                                            #
 ################################################################################
 
-### print an error
-# arguments:
-#   - error string [required]
-# return: n/a
+### print an error message #####################################################
+# Prints a error <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printError <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
 function printError {
   local string="ERROR:   $1"
-
   # if a log file is specified
-  if [ ! -z $LOG_FILE ]; then
+  if [ -n "$LOG_FILE" ]; then
     printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
   fi
   printf "$(tput setaf 1)>>> $string$(tput sgr 0)" 1>&2
 }
 
-### print a warning
-# arguments:
-#   - warning string [required]
-# return: n/a
+### print a warning message ####################################################
+# Prints a warning <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printMessage <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
 function printWarning {
   local string="WARNING: $1"
-
   # if a log file is specified
-  if [ ! -z $LOG_FILE ]; then
+  if [ -n "$LOG_FILE" ]; then
     printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
   fi
-  printf "$(tput setaf 3)>>> $string$(tput sgr 0)" 1>&2
+  printf "$(tput setaf 3)>>> $string$(tput sgr 0)"
 }
 
-### print an information text
-# arguments:
-#   - information string [required]
-# return: n/a
+### print an information message ###############################################
+# Prints an information <message> to standard output.
+#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
+#
+# usage:      printInfo <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
 function printInfo {
   local string="INFO:    $1"
-
   # if a log file is specified
-  if [ ! -z $LOG_FILE ]; then
+  if [ -n "$LOG_FILE" ]; then
     printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
   fi
-  printf "$(tput setaf 2)>>> $string$(tput sgr 0)" 1>&2
+  printf "$(tput setaf 2)>>> $string$(tput sgr 0)"
 }
 
-### print a message to the log file
-# arguments:
-#   - information string [required]
-# return: n/a
+### print a message to file ####################################################
+# Appends a <message> to a log file, specified by the variable 'LOG_FILE'.
+#
+# usage       printLog <message>
+# arguments:  <message>
+#                 Message string to print.
+# return:     n/a
+#
 function printLog {
   local string="LOG:     $1"
-
   # if a log file is specified
-  if [ ! -z $LOG_FILE ]; then
+  if [ -n "$LOG_FILE" ]; then
     printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
   fi
 }
 
-### exit the script normally
-# arguments: n/a
-# return: 0 (success)
+### exit the script normally ###################################################
+# Prints a delimiter and exits the script normally (returns 0).
+#
+# usage:      quitScript
+# arguments:  n/a
+# return:     0
+#                 No error or warning occurred.
+#
 function quitScript {
-  printInfo "exiting $(realpath ${BASH_SOURCE[0]})\n"
-  printf "\n"
+  printLog "exiting $(realpath ${BASH_SOURCE[0]})\n"
   printf "######################################################################\n"
-
   exit 0
 }
 
-### read a user input
-# arguments:
-#   --numchars, -n  maximum number of characters to read
-#   --options, -o   possible chacters to select (only applies if numchars=1)
-#   --out, -e       output variable to store the user input to
-# return: error code
-#   -  0: no error
-#   - -1: error: invalid arguments
+### read a user input ##########################################################
+# Reads a single character user input from a set up <options> and stores it in
+# a given <return> variable.
+#
+# usage:      readUserInput <options> <return>
+# arguments:  <options>
+#                 String definiing the set of valid characters.
+#                 If the string is empty, the user can input any character.
+#             <return>
+#                 Variable to store the selected character to.
+# return:     n/a
+#
 function readUserInput {
-  # parse arguments
-  local arguments=$(getopt -l num-chars:,options:,out: -o n:o:e: -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
-    return -1
-  fi
-  eval set -- "$arguments"
-
-  # evaluate arguments
-  local numchars=0
-  local options=""
-  local outvar=""
-  while [ true ]; do
-    case "$1" in
-      --num-chars|-n)
-        numchars=$2; shift 2
-        ;;
-      --options|-o)
-        options="$2"; shift 2
-        ;;
-      --out|-e)
-        outvar=$2; shift 2
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (return error)
-        printError "unexpected argument: $1\n"; return -1
-        ;;
-    esac
-  done
-
+  local input=""
   # read user input
-  local _userinput=""
-  while [ -z $_userinput ] || ( [ $numchars == 1 ] && [ ! -z "$options" ] && [[ ! $_userinput =~ ^["$options"]$ ]] ); do
-    if [ $numchars == 0 ]; then
-      read -p "your selection: " -e _userinput
-    else
-      read -p "your selection: " -n $numchars -e _userinput
-    fi
-    if [ -z $_userinput ] || ( [ $numchars == 1 ] && [ ! -z "$options" ] && [[ ! $_userinput =~ ^["$options"]$ ]] ); then
-      printWarning "[$_userinput] is no valid action\n"
+  while [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); do
+    read -p "your selection: " -n 1 -e input
+    if [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); then
+      printWarning "[$input] is no valid action\n"
     fi
   done
-  printLog "[$_userinput] has been selected\n"
-  if [ ! -z "$outvar" ]; then
-    eval $outvar="$_userinput"
-  fi
-
-  return 0
+  printLog "[$input] has been selected\n"
+  eval $2="$input"
 }
 
-### set the log file
-# arguments:
-#   --file, -f    name of file [required]
-#   --option, -o  option if file already exists [optional]
-#                 a: append
-#                 r: delete and restart
-#                 n: disable log
-#                 A: silent append (no message in the log file)
-# return: error code
-#   -  0: no error
-#   -  1: warning: file already exists
-#   -  2: warning: no file specified
-#   - -1: error: invalid arguments
-function setLogFile {
-  # parse arguments
-  local arguments=$(getopt -l file:,option: -o f:o: -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
+### check whether argument is an option ########################################
+# Checks a <string> whether it is an option.
+# Options are defined to either start with '--' followed by any string, or
+# to start with a single '-' followed by a single character, or
+# to start with a single '-' followed by a single character, a '=' and any string.
+# Examples: '--option', '--option=arg', '-o', '-o=arg', '--'
+#
+# usage:      parseIsOption <string>
+# arguments:  <string>
+#                 A string to check whether it is an option.
+# return:     0
+#                 <string> is an option.
+#             -1
+#                 <string> is not an option.
+#
+function parseIsOption {
+  if [[ "$1" =~ ^-(.$|.=.*) ]] || [[ "$1" =~ ^--.* ]]; then
+    return 0
+  else
     return -1
   fi
-  eval set -- "$arguments"
+}
 
-  # evaluate arguments
-  local fname=""
+### set the log file ###########################################################
+# Sets a specified <infile> as log file and checks whether it already exists.
+# If so, the log may either be appended to the file, its content can be cleared,
+# or no log is generated at all.
+# The resulting path is stored in <outvar>.
+#
+# usage:      setLogFile [--option=<option>] [--quiet] <infile> <outvar>
+# arguments:  --option=<option>
+#                 Select what to do if <file> already exists.
+#                 Possible values are 'a', 'r' and 'n'.
+#                 - a: append
+#                 - r: delete and restart
+#                 - n: no log
+#                 If no option is secified but <file> exists, an interactive selection is provided.
+#             --quiet
+#                 Suppress all messages.
+#             <infile>
+#                 Path of the wanted log file.
+#             <outvar>
+#                 Variable to store the path of the log file to.
+# return:     0
+#                 No error or warning occurred.
+#             -1
+#                 Error: invalid input
+#
+function setLogFile {
+  local filepath=""
   local option=""
-  while [ true ]; do
-    case "$1" in
-      --file|f)
-        if [ ! -z $2 ]; then
-          fname="$(dirname $2)/$(basename $2)"
-        else
-          fname=""
-        fi
-        shift 2
-        ;;
-      --option|-o)
-        case $2 in
-          A)
-            option="A"
-            ;;
-          a)
-            option="a"
-            ;;
-          r)
-            option="r"
-            ;;
-          n)
-            option="n"
-            ;;
-          *) # sanity check (return error)
-            printError "unexpected argument: $1\n"; return -1
-            ;;
-        esac
-        shift 2
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (return error)
-        printError "unexpected argument: $1\n"; return -1
-        ;;
-    esac
+  local quiet=false
+
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -o=*|--option=*)
+          option=${1#*=}; shift 1;;
+        -o*|--option*)
+          option="$2"; shift 2;;
+        -q|--quiet)
+          quiet=true; shift 1;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
   done
+  filepath=$(realpath ${otherargs[0]})
 
-  # if no log file was specified
-  if [ -z $fname ]; then
-    printWarning "no log file specified (no log will be genreated)\n"
-    LOG_FILE=""
-    return 2
   # if file already exists
-  elif [ -f $fname ]; then
+  if [ -e $filepath ]; then
     # if no option was specified, ask what to do
-    if [ -z $option ]; then
-      printWarning "log file ${fname} already esists\n"
-      printf "Options:\n"
+    if [ -z "$option" ]; then
+      printWarning "log file $filepath already esists\n"
+      local userinput=""
+      printf "Select what to do:\n"
       printf "  [A] - append log\n"
       printf "  [R] - restart log (delete existing file)\n"
       printf "  [N] - no log\n"
-      readUserInput --num-chars=1 --options="AaRrNn" --out=userinput
+      readUserInput "AaRrNn" userinput
       option=${userinput,,}
     fi
-
     # evaluate option
-    case $option in
-      A)
-        LOG_FILE=$(realpath $fname)
-        ;;
+    case "$option" in
       a)
-        printInfo "appending log to existing file\n"
-        LOG_FILE=$(realpath $fname)
-        printf "\n" >> $LOG_FILE
-        printf "######################################################################\n" >> $LOG_FILE
-        printf "\n" >> $LOG_FILE
+        if [ $quiet = false ]; then
+          printInfo "appending log to $filepath\n"
+        fi
+        printf "\n" >> $filepath
+        printf "######################################################################\n" >> $filepath
+        printf "\n" >> $filepath
         ;;
       r)
-        printInfo "old log file deleted, starting clean\n"
-        LOG_FILE=$(realpath $fname)
-        rm $LOG_FILE
+        echo -n "" > $filepath
+        if [ $quiet = false ]; then
+          printInfo "content of $filepath wiped\n"
+        fi
         ;;
       n)
-        printInfo "no log file will be generated\n"
-        LOG_FILE=""
+        if [ $quiet = false ]; then
+          printInfo "no log file will be generated\n"
+        fi
+        filepath=""
         ;;
       *) # sanity check (return error)
-        printError "unexpected argument: $1\n"; return -1
-        ;;
+        printError "unexpected argument: $option\n"; return -1;;
     esac
-
-    return 1
   else
-    printInfo "log file set to $(realpath $fname)\n"
-    LOG_FILE=$(realpath $fname)
-    return 0
+    if [ $quiet = false ]; then
+      printInfo "log file set to $filepath\n"
+    fi
   fi
+
+  eval ${otherargs[1]}="$filepath"
+
+  return 0
 }
 
 ################################################################################
 # SPECIFIC FUNCTIONS                                                           #
 ################################################################################
 
-### print welcome text
-# arguments: n/a
-# return: n/a
+### print welcome text #########################################################
+# Prints a welcome message to standard out.
+#
+# usage:      printWelcomeText
+# arguments:  n/a
+# return:     n/a
+#
 function printWelcomeText {
   printf "######################################################################\n"
   printf "#                                                                    #\n"
@@ -297,38 +290,71 @@ function printWelcomeText {
   printf "######################################################################\n"
 }
 
-### print help text
-# arguments: n/a
-# return: n/a
+### print help #################################################################
+# Prints a help text to standard out.
+#
+# usage:      printHelp
+# arguments:  n/a
+# return:     n/a
+#
 function printHelp {
   printInfo "printing help text\n"
-  printf "usage:  $(basename ${BASH_SOURCE[0]}) [options]\n"
-  printf "options:\n"
-  printf "  --help, -h        Print this help text.\n"
-  printf "  --stm32flash, -f  Run stm32flash tool setup.\n"
-  printf "  --SerialBoot, -s  Run SerialBoot tool setup.\n"
-  printf "  --IDE, -e         Enter IDE setup.\n"
-  printf "  --quit, -q        Quit the script.\n"
-  printf "  --log=<file>      Specify a log file.\n"
+  printf "usage:    $(basename ${BASH_SOURCE[0]}) [-h|--help] [-f|--stm32flash] [-s|--SerialBoot] [-e|--IDE] [-c|--compiler] [-q|--quit] [--log=<file>]\n"
+  printf "\n"
+  printf "options:  -h, --help\n"
+  printf "              Print this help text.\n"
+  printf "          -f, --stm32flash\n"
+  printf "              Run st,32flash tool setup.\n"
+  printf "          -s, --SerialBoot\n"
+  printf "              Run SerialBoot tool setup.\n"
+  printf "          -e, --IDE\n"
+  printf "              Enter IDE setup.\n"
+  printf "          -c, --compiler\n"
+  printf "              Enter compiler setup.\n"
+  printf "          -q, --quit\n"
+  printf "              Quit the script.\n"
+  printf "          --log=<file>\n"
+  printf "              Specify a log file.\n"
 }
 
-### enter bootloader setup
-# arguments n/a
-# return:
-#  -  0: no error
-#  -  1: warning: function aborted by user
-#  - -1: error: unexpected user input
+### stm32flash tool setup ######################################################
+# Fetches the source code for the stm32flash tool and builds the binary.
+# If the tool was already initialized, it can be wiped and rebuilt.
+#
+# usage:      stm32flashSetup
+# arguments:  n/a
+# return:     0
+#                 No error or warning occurred.
+#             1
+#                 Warning: Setup aborted by user.
+#             -1
+#                 Error: Unexpected user input.
+#
 function stm32flashSetup {
   local stm32flashdir=$(dirname $(realpath ${BASH_SOURCE[0]}))/Host/Source/stm32flash/
+  local userdir=$(pwd)
 
   # if the stm32flash folder is not empty
   if [ ! -z "$(ls -A $stm32flashdir)" ]; then
-    printWarning "$(realpath $stm32flashdir) is not empty. Delete and reinitialize? [y/n]\n"
-    readUserInput --num-chars=1 --options="YyNn" --out=userinput
-    case $userinput in
+    printWarning "$stm32flashdir is not empty. Delete and reinitialize? [y/n]\n"
+    local userinput=""
+    readUserInput "YyNn" userinput
+    case "$userinput" in
       Y|y)
-        printInfo "wiping $stm32flashdir\n"
+        printInfo "wiping ${stm32flashdir}...\n"
+        # checkout base commit and delete all local branches
+        git submodule update --force --checkout $stm32flashdir | tee -a $LOG_FILE
+        cd $stm32flashdir
+        local git_branches=($(git for-each-ref --format="%(refname)"))
+        for branch in $git_branches ; do
+          if [[ $branch = *"heads/"* ]]; then
+            git branch -D ${branch##*/} | tee -a $LOG_FILE
+          fi
+        done
+        cd $userdir
+        # deinit stm32flash submodule and delete any remaining files
         git submodule deinit -f $stm32flashdir 2>&1 | tee -a $LOG_FILE
+        rm -rf $stm32flashdir/*
         ;;
       N|n)
         printWarning "stm32flash setup aborted by user\n"
@@ -342,7 +368,7 @@ function stm32flashSetup {
   fi
 
   # initialize submodule
-  printInfo "initializing stm32flash submodule\n"
+  printInfo "initializing stm32flash submodule...\n"
   git submodule update --init $stm32flashdir 2>&1 | tee -a $LOG_FILE
 
   # build the stm32flash tool
@@ -355,22 +381,31 @@ function stm32flashSetup {
   return 0
 }
 
-### enter SerialBoot setup
-# arguments n/a
-# return:
-#  -  0: no error
-#  -  1: warning: function aborted by user
-#  - -1: error: unexpected user input
+### SerialBoot tool setup ######################################################
+# Builds the SerialBoot tool.
+# If the tool was built before, it can be deleted and rebuilt.
+#
+# usage:      serialBootSetup
+# arguments:  n/a
+# return:     0
+#                 No errort or warning occurred.
+#             1
+#                 Warning: Setup aborted by user.
+#             -1
+#                 Error: Unexpected user input.
+#
 function serialBootSetup {
   local serialbootdir=$(dirname $(realpath ${BASH_SOURCE[0]}))/Host/Source/SerialBoot/
+  local userdir=$(pwd)
 
   # if a build folder already exists
   if [ -d "${serialbootdir}/build/" ]; then
     printWarning "SerialBoot has been built before. Delete and rebuild? [y/n]\n"
-    readUserInput --num-chars=1 --options="YyNn" --out=userinput
-    case $userinput in
+    local userinput=""
+    readUserInput "YyNn" userinput
+    case "$userinput" in
       Y|y)
-        printInfo "deleting ${serialbootdir}build/\n"
+        printInfo "deleting ${serialbootdir}build/...\n"
         rm -rf "${serialbootdir}build/"
         ;;
       N|n)
@@ -385,49 +420,60 @@ function serialBootSetup {
   fi
 
   # build SerialBoot
-  printInfo "compiling SerialBoot\n"
-  local userdir=${PWD}
-  mkdir "${serialbootdir}build/"
-  cd "${serialbootdir}build/"
+  printInfo "compiling SerialBoot...\n"
+  mkdir ${serialbootdir}build/
+  cd ${serialbootdir}build/
   cmake .. 2>&1 | tee -a $LOG_FILE
   make 2>&1 | tee -a $LOG_FILE
-  cd "$userdir"
+  cd $userdir
 
   return 0
 }
 
-### enter IDE setup
-# arguments n/a
-# return: n/a
+### IDE setup ##################################################################
+# Enter the IDE setup.
+#
+# usage:      ideSetup
+# arguments:  n/a
+# return:     n/a
+#
 function ideSetup {
-  printInfo "entering ideSetup setup\n"
+  printInfo "entering IDE setup\n"
   printf "\n"
-  if [ -z $LOG_FILE ]; then
-    $(dirname $(realpath ${BASH_SOURCE[0]}))/ide/setup_IDE.sh --noinfo
+  if [ -z "$LOG_FILE" ]; then
+    $(dirname $(realpath ${BASH_SOURCE[0]}))/ide/idesetup.sh --noinfo
   else
-    $(dirname $(realpath ${BASH_SOURCE[0]}))/ide/setup_IDE.sh --LOG="$LOG_FILE" --noinfo
+    $(dirname $(realpath ${BASH_SOURCE[0]}))/ide/idesetup.sh --LOG="$LOG_FILE" --noinfo
   fi
 }
 
-################################################################################
-# SCRIPT MAIN FUNCTION                                                         #
-################################################################################
-
-### main function of this script
-# arguments: see help text
-# return: error code
-#   - 0: no error
-#   - 1: error
-function main {
-
-  # parse arguments
-  local arguments=$(getopt -l help,stm32flash,SerialBoot,IDE,quit,log:,LOG:,noinfo -o hfseq -- "$@")
-  if [ $? != 0 ]; then
-    printError "could not interprete arguments."
-    exit 1
+### compiler setup #############################################################
+# Enter the compiler setup.
+#
+# usage:      compilerSetup
+# arguments:  n/a
+# return:     n/a
+#
+function compilerSetup {
+  printInfo "entering IDE setup\n"
+  printf "\n"
+  if [ -z "$LOG_FILE" ]; then
+    $(dirname $(realpath ${BASH_SOURCE[0]}))/compiler/compilersetup.sh --noinfo
+  else
+    $(dirname $(realpath ${BASH_SOURCE[0]}))/compiler/compilersetup.sh --LOG="$LOG_FILE" --noinfo
   fi
-  eval set -- "$arguments"
+}
 
+### main function of this script ###############################################
+# A setup to initialize dependencies, setup IDE projects and configure the
+# compiler setup.
+#
+# usage:      see function printHelp
+# arguments:  see function printHelp
+# return:     0
+#                 No error or warning occurred.
+#
+function main {
   # print welcome/info text if not suppressed
   if [[ $@ != *"--noinfo"* ]]; then
     printWelcomeText
@@ -437,18 +483,25 @@ function main {
   printf "\n"
 
   # set log file if specified
-  if [[ $@ == *--log* || $@ == *--LOG* ]]; then
+  if [[ $@ == *"--log"* ]] || [[ $@ == *"--LOG"* ]]; then
     # get the parameter (file name)
     local cmdidx=1
-    while [ "${!cmdidx}" != "--log" ] && [ "${!cmdidx}" != "--LOG" ]; do
+    while [[ ! "${!cmdidx}" = "--log"* ]] && [[ ! "${!cmdidx}" = "--LOG"* ]]; do
       cmdidx=$[cmdidx + 1]
     done
-    local filenameidx=$[cmdidx + 1]
+    local cmd="${!cmdidx}"
+    local logfile=""
+    if [[ "$cmd" = "--log="* ]] || [[ "$cmd" = "--LOG="* ]]; then
+      logfile=${cmd#*=}
+    else
+      local filenameidx=$((cmdidx + 1))
+      logfile="${!filenameidx}"
+    fi
     # optionally force silent appending
-    if [ "${!cmdidx}" == "--LOG" ]; then
-      setLogFile --file="${!filenameidx}" --option=A
+    if [[ "$cmd" = "--LOG"* ]]; then
+      setLogFile --option=a --quiet "$logfile" LOG_FILE
     else
-      setLogFile --file="${!filenameidx}"
+      setLogFile "$logfile" LOG_FILE
       printf "\n"
     fi
   fi
@@ -463,71 +516,66 @@ function main {
     quitScript
   fi
 
-  # handle command line arguments
-  while [ true ]; do
-    case $1 in
-      --help|-h) # already handled; ignore
-        shift 1;
-        ;;
-      --stm32flash|-f)
-        stm32flashSetup; printf "\n"; shift 1
-        ;;
-      --SerialBoot|-s)
-        serialBootSetup; printf "\n"; shift 1
-        ;;
-      --IDE|-e)
-        IdeSetup; printf "\n"; shift 1;
-        ;;
-      --quit|-q)
-        quitScript
-        ;;
-      --log|--LOG) # already handled; ignore
-        shift 2
-        ;;
-      --noinfo) # already processed; ignore
-        shift 1
-        ;;
-      --) # end of options reached
-        shift; break
-        ;;
-      *) # sanity check (exit with error)
-        printError "unexpected argument: $1\n"; exit -1
-        ;;
-    esac
+  # parse arguments
+  local otherargs=()
+  while [ $# -gt 0 ]; do
+    if ( parseIsOption $1 ); then
+      case "$1" in
+        -h|--help) # already handled; ignore
+          shift 1;;
+        -f|--stm32flash)
+          stm32flashSetup; printf "\n"; shift 1;;
+        -s|--SerialBoot)
+          serialBootSetup; printf "\n"; shift 1;;
+        -e|--IDE)
+          ideSetup; printf "\n"; shift 1;;
+        -c|--compiler)
+          compilerSetup; printf "\n"; shift 1;;
+        -q|--quit)
+          quitScript; shift 1;;
+        --log=*|--LOG=*) # already handled; ignore
+          shift 1;;
+        --log|--LOG) # already handled; ignore
+          shift 2;;
+        --noinfo) # already handled; ignore
+          shift 1;;
+        *)
+          printError "invalid option: $1\n"; shift 1;;
+      esac
+    else
+      otherargs+=("$1")
+      shift 1
+    fi
   done
 
   # interactive menu
-  while [ true ]; do
+  while ( true ); do
     # main menu info prompt and selection
-    printInfo "AMiRo-BLT main menu\n"
+    printInfo "AMiRo-BLT setup main menu\n"
     printf "Please select one of the following actions:\n"
     printf "  [F] - get and build stm32flash tool\n"
     printf "  [S] - build SerialBoot tool\n"
     printf "  [E] - IDE project setup\n"
+    printf "  [C] - enter compiler setup\n"
     printf "  [Q] - quit this setup\n"
-    readUserInput --num-chars=1 --options="FfSsEeQq" --out=userinput
+    local userinput=""
+    readUserInput "FfSsEeCcQq" userinput
     printf "\n"
 
     # evaluate user selection
-    case $userinput in
-      I|i)
-        projectInitialization; printf "\n"
-        ;;
+    case "$userinput" in
       F|f)
-        stm32flashSetup; printf "\n"
-        ;;
+        stm32flashSetup; printf "\n";;
       S|s)
-        serialBootSetup; printf "\n"
-        ;;
+        serialBootSetup; printf "\n";;
       E|e)
-        ideSetup; printf "\n"
-        ;;
+        ideSetup; printf "\n";;
+      C|c)
+        compilerSetup; printf "\n";;
       Q|q)
-        quitScript
-        ;;
+        quitScript;;
       *) # sanity check (exit with error)
-        printError "unexpected argument: $userinput\n"; exit -1
-        ;;
+        printError "unexpected argument: $userinput\n";;
     esac
   done
 
@@ -540,166 +588,3 @@ function main {
 
 main "$@"
 
-
-## initial info text (can be disabled with 'no_info' as last argument)
-#if [[ ! ${!#} = "no_info" ]]; then
-#  printf "######################################################################\n"
-#  printf "#                                                                    #\n"
-#  printf "#                  Welcome to the AMiRo-BLT setup!                   #\n"
-#  printf "#                                                                    #\n"
-#  printf "######################################################################\n"
-#  printf "#                                                                    #\n"
-#  printf "# Copyright (c) 2016..2017  Thomas Schöpping                         #\n"
-#  printf "#                                                                    #\n"
-#  printf "# This is free software; see the source for copying conditions.      #\n"
-#  printf "# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR  #\n"
-#  printf "# A PARTICULAR PURPOSE. The development of this software was         #\n"
-#  printf "# supported by the Excellence Cluster EXC 227 Cognitive Interaction  #\n"
-#  printf "# Technology. The Excellence Cluster EXC 227 is a grant of the       #\n"
-#  printf "# Deutsche Forschungsgemeinschaft (DFG) in the context of the German #\n"
-#  printf "# Excellence Initiative.                                             #\n"
-#  printf "#                                                                    #\n"
-#  printf "######################################################################\n"
-#  printf "\n"
-#fi
-#
-## initialization of variables
-#ARG_IDX=1
-#USER_INPUT=${!ARG_IDX}
-#
-#while [[ ! $USER_INPUT =~ ^[Ee]$ ]]; do
-#
-#  # main menu info prompt and selection
-#  printf "AMiRo-BLT setup\n"
-#  printf "===============\n"
-#  printf "\n"
-#  if [[ -z $USER_INPUT || $USER_INPUT == "no_info" ]]; then
-#    printf "Please select one of the following actions:\n"
-#    printf "    [F] - stm32flash flashing tool setup\n"
-#    printf "    [S] - SerialBoot flashing tool setup\n"
-#    printf "    [Q] - setup QtCreator projects\n"
-#    printf "    [E] - exit this setup\n"
-#
-#    while [[ ! $USER_INPUT =~ ^[FfSsQqEe]$ ]]; do
-#      read -p "your selection: " -n 1 -e USER_INPUT
-#      if [[ ! $USER_INPUT =~ ^[FfSsQqEe]$ ]]; then
-#        printf "[%s] is no valid action. \n" $USER_INPUT
-#      fi
-#    done
-#
-#    printf "\n"
-#    printf "######################################################################\n"
-#    printf "\n"
-#  fi
-#
-#  # action selection
-#  case $USER_INPUT in
-#
-#    # stm32flash setup
-#    F|f)
-#      USER_DIR=${PWD}
-#      cd $(dirname ${BASH_SOURCE[0]})
-#
-#      # initialize submodule
-#      git submodule update --init ./Host/Source/stm32flash/
-#
-#      cd ./Host/Source/stm32flash/
-#      BUILD_STM32FLASH=true
-#
-#      # test for existing bonary
-#      if [ -f stm32flash ]; then
-#        printf "WARNING: stm32flash binary already exists.\n"
-#        read -p "Would you like to delete and rebuild it? [Y|n] " -n 1 -i "Y" -e USER_INPUT
-#        if [[ $USER_INPUT =~ ^[Yy]$ ]]; then
-#          BUILD_STM32FLASH=true
-#          make clean
-#        elif [[ ! $USER_INPUT =~ ^[YyNn]$ ]]; then
-#          BUILD_STM32FLASH=false
-#          printf "'%s' is no valid selection. Aborting setup.\n" $USER_INPUT
-#        else
-#          BUILD_STM32FLASH=false
-#        fi
-#     fi
-#
-#      # build the tool if required
-#      if [ $BUILD_STM32FLASH = true ]; then
-#       make
-#      fi
-#
-#      cd $USER_DIR
-#      ;;
-#
-#    # SerailBoot setup
-#    S|s)
-#      # print setup header
-#      printf "SerialBoot setup\n"
-#      printf "================\n"
-#      printf "\n"
-#
-#      USER_DIR=${PWD}
-#      cd $(dirname ${BASH_SOURCE[0]})/Host/Source/SerialBoot/
-#      BUILD_SERIALBOOT=true
-#
-#      # test for existing binary
-#      if [ -f build/SerialBoot ]; then
-#        printf "WARNING: SerialBoot binary already exists.\n"
-#        read -p "Would you like to delete and rebuild it? [Y|n] " -n 1 -i "Y" -e USER_INPUT
-#        if [[ $USER_INPUT =~ ^[Yy]$ ]]; then
-#          BUILD_SERIALBOOT=true
-#          rm -rf build/
-#        elif [[ ! $USER_INPUT =~ ^[YyNn]$ ]]; then
-#          BUILD_SERIALBOOT=false
-#          printf "'%s' is no valid selection. Aborting setup.\n" $USER_INPUT
-#        else
-#          BUILD_SERIALBOOT=false
-#        fi
-#      fi
-#
-#      # build the tool if requested
-#      if [ $BUILD_SERIALBOOT = true ]; then
-#        mkdir build
-#        cd build
-#        cmake ..
-#        make
-#      fi
-#
-#      cd $USER_DIR
-#      ;;
-#
-#    # QtCreator setup
-#    Q|q)
-#      # calling the script with no arguments prints the help and returns
-#      source $(dirname ${BASH_SOURCE[0]})/ide/QtCreator/QtCreatorSetup.sh no_info
-#      printf "\n"
-#      # set deafult arguments and call the script again
-#      USER_INPUT="clean all"
-#      read -p "select commands: " -i "$USER_INPUT" -e USER_INPUT
-#      printf "\n"
-#      source $(dirname ${BASH_SOURCE[0]})/ide/QtCreator/QtCreatorSetup.sh no_info $USER_INPUT
-#      ;;
-#
-#    # exit
-#    E|e)
-#      break;
-#      ;;
-#
-#    # sanity check
-#    *)
-#      printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
-#      printf "ERROR (${LINENO}): unexpected state; aborting script\n"
-#      printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
-#      printf "\n"
-#      exit
-#      ;;
-#
-#  esac
-#
-#  printf "\n"
-#  printf "######################################################################\n"
-#  printf "\n"
-#
-#  let ARG_IDX++
-#  USER_INPUT=${!ARG_IDX}
-#
-#done
-
