diff --git a/configure b/configure
index 2d9228067f3f184bf4d455da10c327c5f81200fc..323f98eb885c171129d21ad7391e4b603f5d12a2 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 178605 .
+# From configure.ac Revision: 180944 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for asterisk 1.6.
 #
@@ -4113,8 +4113,10 @@ case "${host_os}" in
      ;;
 esac
 
-if test ${localstatedir} = '${prefix}/var'; then
-     localstatedir=/var
+if test ${prefix} = ${ac_default_prefix} || test ${prefix} = 'NONE'; then
+     if test ${localstatedir} = '${prefix}/var'; then
+        localstatedir=/var
+     fi
 fi
 
 BUILD_PLATFORM=${build}
diff --git a/configure.ac b/configure.ac
index 62515088d2327575e91132280be31f1e3048aae0..17cba0205ec593ddacaa9d2831bc30a8c409519e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,8 +57,10 @@ case "${host_os}" in
      ;;
 esac
 
-if test ${localstatedir} = '${prefix}/var'; then
-     localstatedir=/var
+if test ${prefix} = ${ac_default_prefix} || test ${prefix} = 'NONE'; then
+     if test ${localstatedir} = '${prefix}/var'; then
+        localstatedir=/var
+     fi
 fi
 
 BUILD_PLATFORM=${build}