diff --git a/configure b/configure
index 291966b5e89e986ffd981ba54f70ff639197a300..03f95abcf6ce79e3a7b46ab3a96b48147161c68e 100755
--- a/configure
+++ b/configure
@@ -5069,6 +5069,8 @@ then
         as_fn_error $? "--enable-win64 and --with-wine64 are mutually exclusive.
 --enable-win64 should be used in the 64-bit build tree, --with-wine64 in the 32-bit Wow64 build tree." "$LINENO" 5
     fi
+    test "$srcdir" != . || as_fn_error $? "--with-wine64 cannot be used when building inside the source tree.
+You should create a separate build directory and run configure from there." "$LINENO" 5
     enable_fonts=${enable_fonts:-no}
     enable_server=${enable_server:-no}
 elif test "x$enable_win64" = "xyes"
diff --git a/configure.ac b/configure.ac
index bd3db262868ace138d1128e8b4beb46b2bdd1d2a..2d2a168787f32fc845e52a3452d4c626d53b8b64 100644
--- a/configure.ac
+++ b/configure.ac
@@ -203,6 +203,8 @@ then
         AC_MSG_ERROR([--enable-win64 and --with-wine64 are mutually exclusive.
 --enable-win64 should be used in the 64-bit build tree, --with-wine64 in the 32-bit Wow64 build tree.])
     fi
+    test "$srcdir" != . || AC_MSG_ERROR([--with-wine64 cannot be used when building inside the source tree.
+You should create a separate build directory and run configure from there.])
     enable_fonts=${enable_fonts:-no}
     enable_server=${enable_server:-no}
 elif test "x$enable_win64" = "xyes"