diff --git a/configure.in b/configure.in
index 69dcc5f924809aac66203859dba99577a519e131..f9f8298220518fdc3d6a6d4f9a55660801fc27db 100644
--- a/configure.in
+++ b/configure.in
@@ -82,14 +82,21 @@ if test "$VERBOSEMAKE" = yes ; then
   AC_MSG_RESULT(Make will be verbose.)
 fi
 
-##########################################
-# Check for invalid command-line options #
-##########################################
+##############################################################
+# Check for invalid command-line options and build directory #
+##############################################################
 case $prefix in
   *\ * ) AC_MSG_ERROR(spaces not allowed in --prefix argument "$prefix");;
   * ) ;;
 esac
 
+case $(pwd) in
+  *\ * ) AC_MSG_ERROR(spaces not allowed in build directory "$(pwd)");;
+  *\'* ) AC_MSG_ERROR(single quotes not allowed in build directory "$(pwd)");;
+  *\"* ) AC_MSG_ERROR(double quotes not allowed in build directory "$(pwd)");;
+  * ) ;;
+esac
+
 #############################
 # Check for Ocaml compilers #
 #############################