- (dtucker) [configure.ac defines.h] Only define SHUT_RD (and friends) and O_NONBLOCK
   if they're really needed.  Fixes build errors on HP-UX, old Linuxes and probably
   more.
diff --git a/ChangeLog b/ChangeLog
index 78a23fe..b2c8cda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+20060712
+ - (dtucker) [configure.ac defines.h] Only define SHUT_RD (and friends) and O_NONBLOCK
+   if they're really needed.  Fixes build errors on HP-UX, old Linuxes and probably
+   more.
+
 20060711
  - (dtucker) [configure.ac ssh-keygen.c openbsd-compat/bsd-openpty.c
    openbsd-compat/daemon.c] Add includes needed by open(2).  Conditionally
@@ -4846,4 +4851,4 @@
    - (djm) Trim deprecated options from INSTALL. Mention UsePAM
    - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
 
-$Id: ChangeLog,v 1.4387 2006/07/11 09:01:51 dtucker Exp $
+$Id: ChangeLog,v 1.4388 2006/07/12 04:14:31 dtucker Exp $
diff --git a/configure.ac b/configure.ac
index c6d56bf..19446b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-# $Id: configure.ac,v 1.345 2006/07/11 08:00:06 dtucker Exp $
+# $Id: configure.ac,v 1.346 2006/07/12 04:14:31 dtucker Exp $
 #
 # Copyright (c) 1999-2004 Damien Miller
 #
@@ -15,7 +15,7 @@
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org)
-AC_REVISION($Revision: 1.345 $)
+AC_REVISION($Revision: 1.346 $)
 AC_CONFIG_SRCDIR([ssh.c])
 
 AC_CONFIG_HEADER(config.h)
@@ -1285,6 +1285,19 @@
 
 AC_CHECK_DECLS(h_errno, , ,[#include <netdb.h>])
 
+AC_CHECK_DECLS(SHUT_RD, , ,[#include <sys/socket.h>])
+
+AC_CHECK_DECLS(O_NONBLOCK, , ,
+	[
+#include <sys/types.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+	])
+
 AC_CHECK_FUNCS(setresuid, [
 	dnl Some platorms have setresuid that isn't implemented, test for this
 	AC_MSG_CHECKING(if setresuid seems to work)
diff --git a/defines.h b/defines.h
index f2fdd3c..4dccc91 100644
--- a/defines.h
+++ b/defines.h
@@ -25,12 +25,12 @@
 #ifndef _DEFINES_H
 #define _DEFINES_H
 
-/* $Id: defines.h,v 1.132 2006/05/15 07:17:30 dtucker Exp $ */
+/* $Id: defines.h,v 1.133 2006/07/12 04:14:31 dtucker Exp $ */
 
 
 /* Constants */
 
-#ifndef SHUT_RDWR
+#if defined(HAVE_DECL_SHUT_RD) && HAVE_DECL_SHUT_RD == 0
 enum
 {
   SHUT_RD = 0,		/* No more receptions.  */
@@ -90,8 +90,8 @@
 #endif
 #endif
 
-#ifndef O_NONBLOCK	/* Non Blocking Open */
-# define O_NONBLOCK      00004
+#if defined(HAVE_DECL_O_NONBLOCK) && HAVE_DECL_O_NONBLOCK == 0
+# define O_NONBLOCK      00004	/* Non Blocking Open */
 #endif
 
 #ifndef S_ISDIR