diff --git a/BUILD/choose_configure.sh b/BUILD/choose_configure.sh
index 71243ea09b634f49e0c70d04b03a0872543254ff..476b8b51657a2d77d50bb60fc68230fa67a77979 100644
--- a/BUILD/choose_configure.sh
+++ b/BUILD/choose_configure.sh
@@ -7,8 +7,8 @@ cmake -P cmake/check_minimal_version.cmake >/dev/null 2>&1 || HAVE_CMAKE=no
 perl --version >/dev/null 2>&1 || HAVE_CMAKE=no
 if test "$HAVE_CMAKE" = "no"
 then
-  sh ./configure.am $@
+  sh ./configure.am "$@"
 else
-  perl ./cmake/configure.pl $@
+  perl ./cmake/configure.pl "$@"
 fi
 
diff --git a/cmake/configure.pl b/cmake/configure.pl
index 5886a5547892adec7e4eb8b224b9e4b9a5500bfb..50225a0ef5e444c733817cb3aff15a059944d2e3 100644
--- a/cmake/configure.pl
+++ b/cmake/configure.pl
@@ -72,10 +72,21 @@ check_compiler("CXX", "CXXFLAGS");
 
 foreach my $option (@ARGV)
 {
-  if (substr ($option, 0, 2) == "--")
+  if (substr ($option, 0, 2) eq "--")
   {
     $option = substr($option, 2);
   }
+  else
+  {
+    # This must be environment variable
+    my @v  = split('=', $option);
+    my $name = shift(@v);
+    if(@v)
+    {
+      $ENV{$name} = join('=', @v);  
+    }	
+    next;
+  }
   if($option =~ /srcdir/)
   {
     $srcdir = substr($option,7);