flash: openocd: make 'make flash' target work without Zephyr SDK

At present 'make flash' target for boards that support flashing with
OpenOCD works only with Zephyr SDK. This patch enables flashing
without Zephyr SDK as long as openocd itself is installed.

Change-Id: I4594d795225e54b7638839d590e4c0620f9ca88c
Jira: ZEP-1893
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
diff --git a/scripts/support/openocd.sh b/scripts/support/openocd.sh
index 87534d8..6d8dd55 100755
--- a/scripts/support/openocd.sh
+++ b/scripts/support/openocd.sh
@@ -3,7 +3,8 @@
 # This script is loosly based on a script with same purpose provided
 # by RIOT-OS (https://github.com/RIOT-OS/RIOT)
 
-OPENOCD_CMD="${OPENOCD:-openocd} -s ${OPENOCD_DEFAULT_PATH}"
+OPENOCD=${OPENOCD:-openocd}
+OPENOCD_CMD="${OPENOCD}${OPENOCD_DEFAULT_PATH:+ -s $OPENOCD_DEFAULT_PATH}"
 OPENOCD_CONFIG=${ZEPHYR_BASE}/boards/${ARCH}/${BOARD_NAME}/support/openocd.cfg
 BIN_NAME=${O}/${KERNEL_BIN_NAME}
 ELF_NAME=${O}/${KERNEL_ELF_NAME}
@@ -13,7 +14,7 @@
         echo "Error: Unable to locate OpenOCD configuration file: ${OPENOCD_CONFIG}"
         exit 1
     fi
-    if [ ! -f "${OPENOCD}" ]; then
+    if ! which ${OPENOCD} >/dev/null 2>&1; then
         echo "Error: Unable to locate OpenOCD executable: ${OPENOCD}"
         exit 1
     fi