--- a/config/boost_base.m4
+++ b/config/boost_base.m4
@@ -14,6 +14,21 @@
         fi
     ],
     [want_boost="yes"])
+
+
+AC_ARG_WITH([boost-libdir],
+        AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
+        [Force given directory for boost libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
+        [
+        if test -d $withval
+        then
+                ac_boost_lib_path="$withval"
+        else
+                AC_MSG_ERROR(--wit-boost-lib expected directory name)
+        fi
+        ],
+        [ac_boost_lib_path=""]
+)
 
 if test "x$want_boost" = "xyes"; then
         boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
@@ -44,6 +59,12 @@
                 done
         fi
 
+        dnl overwrite ld flags if we have required special directory with 
+        dnl --with-boost-lib parameter
+        if test "$ac_boost_lib_path" != ""; then
+                BOOST_LDFLAGS="-L$ac_boost_lib_path"
+        fi
+
         CPPFLAGS_SAVED="$CPPFLAGS"
         CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
         export CPPFLAGS
@@ -70,13 +91,11 @@
         AC_LANG_POP([C++])
 
 
-
         dnl if we found no boost with system layout we search for boost libraries
         dnl built and installed without the --layout=system option or for a staged(not installed) version
         if test "x$succeeded" != "xyes"; then
                 _version=0
                 if test "$ac_boost_path" != ""; then
-                        BOOST_LDFLAGS="-L$ac_boost_path/lib"
                         if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
                                 for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
                                         _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
@@ -104,7 +123,10 @@
 
                         VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
                         BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
-                        BOOST_LDFLAGS="-L$best_path/lib"
+                        if test "$ac_boost_lib_path" = ""
+                        then
+                                BOOST_LDFLAGS="-L$best_path/lib"
+                        fi
 
                         if test "x$BOOST_ROOT" != "x"; then
                                 if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
@@ -112,7 +134,7 @@
                                         stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
                                         stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
                                         V_CHECK=`expr $stage_version_shorten \>\= $_version`
-                                        if test "$V_CHECK" = "1" ; then
+                                        if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
                                                 AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
                                                 BOOST_CPPFLAGS="-I$BOOST_ROOT"
                                                 BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"