diff --git a/configure.in b/configure.in
index 343b52c624790ad9859b316ac95ba3805ea35706..cce438fe076e67044a163451b3f9d87629e430e4 100644
--- a/configure.in
+++ b/configure.in
@@ -290,6 +290,12 @@ AM_CONDITIONAL(BITQ, test $build_bitq = yes)
 AC_LANG_C
 AC_PROG_CC
 AC_PROG_RANLIB
+AC_PATH_PROG(TCLSH, tclsh)
+
+# quit if we have no tclsh
+if test "x${TCLSH}" = "x"; then
+	AC_MSG_ERROR([no working tclsh found])
+fi
 
 AC_SUBST(WITH_FTD2XX, $with_ftd2xx)
 
diff --git a/src/Makefile.am b/src/Makefile.am
index fae00866a2ae0debf94f384cffb7998a47370893..20b6425149739084083c3fea2ec000bc1f817461 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,7 +6,6 @@ else
 MAINFILE = main.c jim.c
 endif
 
-
 openocd_SOURCES = $(MAINFILE) openocd.c startup.c
 
 # set the include path found by configure
@@ -99,4 +98,7 @@ nobase_dist_pkglib_DATA = \
 
 # Convert .tcl to .c file
 startup.c: $(top_srcdir)/src/startup.tcl Makefile  $(top_srcdir)/src/file2c.tcl
-	tclsh $(top_srcdir)/src/file2c.tcl $(top_srcdir)/src/startup.tcl startup.c
\ No newline at end of file
+	${TCLSH} $(top_srcdir)/src/file2c.tcl $(top_srcdir)/src/startup.tcl startup.c
+
+# add startup.c to make clean list
+CLEANFILES = startup.c