diff --git a/configure b/configure
index 7cd59fd581526856a20653b168258b2f075703c0..ac3e00afa2540553b7655d97cef7817d594308d0 100755
--- a/configure
+++ b/configure
@@ -7207,6 +7207,21 @@ then
   prefix=/usr/local
 fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking If prefix is equal to present working directory" >&5
+$as_echo_n "checking If prefix is equal to present working directory... " >&6; }
+
+# ignore cases where the directory does not exist:
+normalized_prefix="`cd "${prefix}" 2>/dev/null && pwd || true`"
+
+if test "`pwd`" = "$normalized_prefix" ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  as_fn_error $? "prefix should not be equal to the present working directory" "$LINENO" 5
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
 test "$program_prefix" != NONE &&
   program_transform_name="s&^&$program_prefix&;$program_transform_name"
 # Use a double $ so make ignores it.
diff --git a/configure.ac b/configure.ac
index 80d1775bd0dbe1ad7fb82fec4fa738fd6f16715a..6abe4cfac115239aeacbe4895400fac5db7ecb56 100644
--- a/configure.ac
+++ b/configure.ac
@@ -833,6 +833,18 @@ then
   prefix=/usr/local
 fi
 
+AC_MSG_CHECKING([If prefix is equal to present working directory])
+
+# ignore cases where the directory does not exist:
+normalized_prefix="`cd "${prefix}" 2>/dev/null && pwd || true`"
+
+if test "`pwd`" = "$normalized_prefix" ; then
+  AC_MSG_RESULT([yes])
+  AC_MSG_ERROR([prefix should not be equal to the present working directory])
+else
+  AC_MSG_RESULT([no])
+fi
+
 AC_ARG_PROGRAM