diff --git a/configure b/configure
index b09e9d0436..032266f3c2 100755
--- a/configure
+++ b/configure
@@ -4752,11 +4752,15 @@ fi
 exesuf() {
     case $1 in
         mingw32*|mingw64*|msys*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
+        *)
+            case $2 in
+                msvc) echo .exe ;;
+            esac ;;
     esac
 }
 
-EXESUF=$(exesuf $target_os)
-HOSTEXESUF=$(exesuf $host_os)
+EXESUF=$(exesuf $target_os $toolchain)
+HOSTEXESUF=$(exesuf $host_os $toolchain)
 
 # set temporary file name
 : ${TMPDIR:=$TEMPDIR}
