Index: tcl/build.sh
==================================================================
--- tcl/build.sh
+++ tcl/build.sh
@@ -61,10 +61,21 @@
 		if [ -f "${patchscript}" ]; then
 			echo "Running patch script: ${patchscript}"
 			. "${patchscript}"
 		fi
 	done
+
+	# Patch Win32 builds to always provide DllMain if we are building KitDLL
+	if [ "${KITTARGET}" = "kitdll" ]; then
+		## DllMain is needed when building KitDLL
+		for filetopatch in win/tclWin32Dll.c win/tclWinInit.c; do
+			echo "Undefining STATIC_BUILD in \"${filetopatch}\""
+
+			sed 's@STATIC_BUILD@NEVER_STATIC_BUILD@g' "${filetopatch}" > "${filetopatch}.new" && cat "${filetopatch}.new" > "${filetopatch}"
+			rm -f "${filetopatch}.new"
+		done
+	fi
 
 	for dir in unix win macosx __fail__; do
 		if [ "${dir}" = "__fail__" ]; then
 			# If we haven't figured out how to build it, reject.