--- configure.orig	Wed Dec  3 14:17:42 2003
+++ configure	Mon Dec 29 01:43:15 2003
@@ -3773,7 +3773,7 @@
 #
 
 # So many systems seem to need this that it is better do it here automatically.
-LIBS="-L/usr/local/lib $LIBS"
+#LIBS="-L/usr/local/lib $LIBS"
 
 # Platform-specific stuff.
 case "$target" in
@@ -9731,6 +9731,9 @@
     no_ranlib=yes
     CFLAGS="$CFLAGS -UM_I86SM"
     ;;
+  *-*-freebsd*)
+    os_freebsd=yes
+    ;;
   *)
     ;;
 esac
@@ -10994,7 +10997,7 @@
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
+#  X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
 else
   echo "$ac_t""no" 1>&6
 fi
@@ -11112,7 +11115,7 @@
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+ac_try="$ac_cpp -I$x_includes conftest.$ac_ext >/dev/null 2>conftest.out"
 { (eval echo configure:11117: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
@@ -13011,6 +13014,9 @@
   fi
 else
   ssh2_ldadd_options="-L. -Llib/sshkeyutil -Llib/sshproto -L../../lib -lssh2 -lsshproto -lsshkeyutil $SCM_LDADD $ssh2_toolkit_ldadd -lssh"
+  if test -n "$os_freebsd"; then
+    ssh2_ldadd_options="$ssh2_ldadd_options -lz"
+  fi
 fi
 
 
