diff --git a/src/aclocal.m4 b/src/aclocal.m4
index a0a8c6652f6416e9925dbb6fd5499420c72f7f89..041ccb368f2f622f8234e0c368253d8fad886e6a 100644
--- a/src/aclocal.m4
+++ b/src/aclocal.m4
@@ -1922,3 +1922,33 @@ AC_DEFUN(PIKE_PKG_CONFIG,
     fi
   ])
 ])
+
+define([PIKE_PARSE_SITE_PREFIXES], [
+p_site_prefixes_to_add=""
+p_site_prefixes_to_remove=""
+for p_option in $ac_configure_args ; do
+  p_option=`eval echo $p_option`
+  case $p_option in
+    --with-site-prefixes*)
+      p_useropt=`expr "x$p_option" : 'x--with-site-prefixes=\(.*\)'`
+      if test "x$p_useropt" != 'x'  ; then
+        p_site_prefixes_to_add="${p_site_prefixes_to_add}:${p_useropt}"
+      fi
+    ;;
+
+    --with-exclude-site-prefixes*)
+      p_useropt=`expr "x$p_option" : 'x--with-exclude-site-prefixes=\(.*\)'`
+      if test "x$p_useropt" != 'x' ; then
+        p_site_prefixes_to_remove="${p_site_prefixes_to_remove}:${p_useropt}"
+      fi
+    ;;
+  esac
+done
+
+m4_divert_once([HELP_WITH], [[
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)]])
+m4_divert_once([HELP_WITH], AS_HELP_STRING([--with-site-prefixes=path], [:-separated list of prefixes to search for include, lib and bin dirs.]))
+m4_divert_once([HELP_WITH], AS_HELP_STRING([--with-exclude-site-prefixes=path], [:-separated list of prefixes to exclude for include, lib and bin dirs.]))
+])
diff --git a/src/configure.in b/src/configure.in
index f661caa9015352d2e3668d9fe6f6387419b6b98b..ef35a0878a135b34f260afbccf543524dda99663 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -1,4 +1,7 @@
 AC_INIT(interpret.c)
+
+PIKE_PARSE_SITE_PREFIXES
+
 AC_CONFIG_HEADER(machine.h)
 
 rm -f config.warnings 2>/dev/null
@@ -1281,10 +1284,6 @@ AC_ARG_WITH(crt, MY_DESCR([--with-crt=dynamic|static],
 AC_ARG_WITH(debug-crt, MY_DESCR([--with-debug-crt],
 				[compile and link with debug CRT in Visual Studio]),
 	    [], [with_debug_crt=no])
-
-AC_ARG_WITH(site-prefixes,
-	    MY_DESCR([--with-site-prefixes],
-		     [:-separated list of prefixes to search for include, lib and bin dirs.]))
 AC_ARG_WITH(include-path,
 	    MY_DESCR([--with-include-path],
 		     [a list of paths to search for include files.]))
@@ -2565,10 +2564,9 @@ fi
 
 primary_path=""
 fallback_path=""
-
 if test $ldflags_is_set = yes -a $cppflags_is_set = yes ; then :; else
   for dd in \
-    `echo "${with_site_prefixes}"|sed -e 's/:/ /g'` \
+    `echo "${p_site_prefixes_to_add}"|sed -e 's/:/ /g'` \
     `echo $exec_prefix | sed "s@^NONE@$prefix@g" | sed "s@^NONE@$with_root$ac_default_prefix@g"` \
     $with_root/usr \
     $with_root/usr/local $with_root/sw/local $with_root/sw \
@@ -2580,6 +2578,18 @@ if test $ldflags_is_set = yes -a $cppflags_is_set = yes ; then :; else
     $with_root/usr/sfw $with_root/opt/sfw $with_root/opt/csw \
     $with_root/usr/ccs
   do
+    O_IFS=${IFS}
+    IFS=":"
+    sp_exclude="no"
+    for spx in ${p_site_prefixes_to_remove} ; do
+      if test "x$with_root$spx" = "x$dd" ; then
+        sp_exclude="yes"
+      fi
+    done 
+       
+    IFS="$O_IFS"
+       
+    if test "$sp_exclude" = "yes" ; then continue; fi
     if test "$dd" = "/"; then continue; fi
     #if test "$dd" = "/usr"; then continue; fi
     AC_MSG_CHECKING($dd)