diff -ru socat-1.6.0.1/Makefile.in socat-1.6.0.1mac/Makefile.in
--- socat-1.6.0.1/Makefile.in	2008-02-09 22:59:11.000000000 +0100
+++ socat-1.6.0.1mac/Makefile.in	2008-02-20 15:04:51.000000000 +0100
@@ -15,6 +15,7 @@
 
 BINDEST = @bindir@
 
+datarootdir = @datarootdir@
 MANDEST = @mandir@
 
 srcdir = @srcdir@
@@ -124,13 +125,13 @@
 strip: progs
 	strip $(PROGS)
 
-install: progs doc/socat.1
+install: progs $(srcdir)/doc/socat.1
 	mkdir -p $(DESTDIR)$(BINDEST)
 	$(INSTALL) -m 755 socat $(DESTDIR)$(BINDEST)
 	$(INSTALL) -m 755 procan $(DESTDIR)$(BINDEST)
 	$(INSTALL) -m 755 filan $(DESTDIR)$(BINDEST)
 	mkdir -p $(DESTDIR)$(MANDEST)/man1
-	$(INSTALL) -m 644 doc/socat.1 $(DESTDIR)$(MANDEST)/man1/
+	$(INSTALL) -m 644 $(srcdir)/doc/socat.1 $(DESTDIR)$(MANDEST)/man1/
 
 uninstall:
 	rm -f $(DESTDIR)$(BINDEST)/socat
diff -ru socat-1.6.0.1/configure.in socat-1.6.0.1mac/configure.in
--- socat-1.6.0.1/configure.in	2008-02-09 22:59:11.000000000 +0100
+++ socat-1.6.0.1mac/configure.in	2008-02-20 21:51:21.000000000 +0100
@@ -55,13 +55,22 @@
 AC_CHECK_HEADERS(pty.h)
 AC_CHECK_HEADERS(netinet/in.h netinet/in_systm.h netinet/ip.h netinet/tcp.h)
 AC_CHECK_HEADERS(netinet6/in6.h)	# found on OpenBSD, used for IPV6_*
-AC_CHECK_HEADERS(arpa/nameser.h resolv.h)
-AC_CHECK_HEADERS(termios.h net/if.h linux/if_tun.h)
+AC_CHECK_HEADERS(net/if.h, [], [], [AC_INCLUDES_DEFAULT
+	#if HAVE_SYS_SOCKET_H
+	#include <sys/socket.h>
+	#endif])	# Mac OS X requires including sys/socket.h
+AC_CHECK_HEADERS(arpa/nameser.h)
+AC_HEADER_RESOLV()
+AC_CHECK_HEADERS(termios.h linux/if_tun.h)
 AC_CHECK_HEADERS(sys/utsname.h sys/select.h sys/file.h)
 AC_CHECK_HEADERS(util.h libutil.h sys/stropts.h regex.h)
 AC_CHECK_HEADERS(linux/fs.h linux/ext2_fs.h)
 
 
+dnl Link libresolv if necessary (for Mac OS X)
+AC_SEARCH_LIBS([res_9_init], [resolv])
+
+
 dnl Check for extra socket library (for Solaris)
 AC_CHECK_FUNC(hstrerror,  , AC_CHECK_LIB(resolv, hstrerror, [LIBS="$LIBS -lresolv"; AC_DEFINE(HAVE_HSTRERROR)]))
 AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent))
@@ -185,7 +194,11 @@
 if test "$WITH_IP6"; then
   AC_CHECK_HEADERS([netinet/ip6.h],
     [AC_DEFINE(HAVE_NETINET_IP6_H) AC_DEFINE(WITH_IP6)],
-    [AC_MSG_WARN([include file netinet/ip6.h not found, disabling IP6])])
+    [AC_MSG_WARN([include file netinet/ip6.h not found, disabling IP6])],
+    [AC_INCLUDES_DEFAULT
+     #ifdef HAVE_NETINET_IN_H
+     # include <netinet/in.h>
+     #endif])
 fi
 
 AC_MSG_CHECKING(whether to include raw IP support)
@@ -284,93 +297,56 @@
 	       esac],
 	       [AC_MSG_RESULT(yes);   WITH_READLINE=1 ])
 
-# check if we find the components of GNU readline
 if test -n "$WITH_READLINE"; then
-  # first, we need to find the include file <readline.h>
-  AC_MSG_NOTICE(checking for components of readline)
-  #AC_CHECK_HEADERS(readline/readline.h readline/history.h)
-  AC_CACHE_VAL(sc_cv_have_readline_h,
-    [AC_TRY_COMPILE([#include <stdio.h>	/* FreeBSD needs "FILE *" */
-#include <readline/readline.h>
-#include <readline/history.h>],[;],
-      [sc_cv_have_readline_h=yes; READLINE_ROOT=""; ],
-      [sc_cv_have_readline_h=no
-       for D in "/sw" "/usr/local" "/opt/freeware" "/usr/sfw"; do
-	I="$D/include"
-        i="$I/readline/readline.h"
-	if test -r "$i"; then
-	  #V_INCL="$V_INCL -I$I/"
-	  CPPFLAGS="$CPPFLAGS -I$I"
-	  AC_MSG_NOTICE(found $i)
-	  sc_cv_have_readline_h=yes; READLINE_ROOT="$D"
-	  break;
-	fi
-      done])
-  ])
-  if test "$sc_cv_have_readline_h" = "yes"; then
-    AC_DEFINE(HAVE_READLINE_READLINE_H)
-    AC_DEFINE(HAVE_READLINE_HISTORY_H)
-  fi
-  AC_MSG_NOTICE(checked for readline.h... $sc_cv_have_readline_h)
-fi	# end checking for readline.h
-#
-if test -n "$WITH_READLINE" -a "$sc_cv_have_readline_h" = yes; then
-  # next, we search for the readline library (libreadline.*)
-  AC_MSG_CHECKING(for libreadline)
-  AC_CACHE_VAL(sc_cv_have_libreadline,
-    [ LIBS0="$LIBS"
-      if test -n "$READLINE_ROOT"; then
-	L="$READLINE_ROOT/lib"; LIBS="$LIBS0 -L$L -lreadline"
-      else
-	LIBS="$LIBS0 -lreadline"
-      fi
-      AC_TRY_LINK([#include <stdio.h>	/* FreeBSD needs FILE * */
-#include <readline/readline.h>
-#include <readline/history.h>],
-	[readline(NULL)],
-	[sc_cv_have_libreadline='yes'],
-	[sc_cv_have_libreadline='no'
-	  LIBS1="$LIBS"
-	  LIBS="$LIBS -lcurses"
-	  AC_TRY_LINK([#include <stdio.h>	/* FreeBSD needs FILE * */
-#include <readline/readline.h>
-#include <readline/history.h>],
-            [readline(NULL)],
-            [sc_cv_have_libreadline='yes'],
-            [sc_cv_have_libreadline='no'
-	      LIBS="$LIBS1 -lncurses"		# eg for SuSE52
-	      AC_TRY_LINK([#include <stdio.h>	/* FreeBSD needs FILE * */
-#include <readline/readline.h>
-#include <readline/history.h>],
-                [readline(NULL)],
-                [sc_cv_have_libreadline='yes'],
-                [sc_cv_have_libreadline='no'])
-      ])]
-      )
-      if test "$sc_cv_have_libreadline" != 'yes'; then
-	LIBS="$LIBS0"
-      fi
-    ]
-#! missing libcurses dependency; missing freeware places
-#    # we test if libcurses is available and if it can be used without further libs
-#    AC_CHECK_LIB(ncurses, main, , AC_CHECK_LIB(curses, main))	# some Linux work with this
-#    # we test if readline can be used without further libs
-#    AC_CHECK_LIB(readline, readline)
-#    # we see if using_history() is already in $LIBS; if not, we try it with curses
-#    AC_CHECK_FUNC(using_history, , AC_CHECK_LIB(history, using_history,,, -lcurses))
-#fi
-  )
-  if test "$sc_cv_have_libreadline" = 'yes'; then
-    AC_DEFINE(HAVE_LIBREADLINE)
-  fi
-  AC_MSG_RESULT($sc_cv_have_libreadline)
-fi
-#
-if test -n "$WITH_READLINE"; then
-  if test "$sc_cv_have_readline_h" = "yes" -a "$sc_cv_have_libreadline" = "yes"; then
-    AC_DEFINE(WITH_READLINE)
-  else
-    AC_MSG_WARN([not all components of readline found, disabling it]);
+  CPPFLAGS_ORIG=$CPPFLAGS
+  CFLAGS_ORIG=$CFLAGS
+  LIBS_ORIG=$LIBS
+  sc_usable_readline_found=
+  
+  for D in "" "/usr/local" "/opt/local" "/sw" "/opt/freeware" "/usr/sfw"; do    
+    if test -n "$D" ; then
+      CPPFLAGS="$CPPFLAGS -I$D/include"
+      CFLAGS="$CFLAGS -L$D/lib"
+      DLOC="in location $D"
+    else
+      DLOC="in default location"
+    fi
+    AC_MSG_CHECKING(for usable readline $DLOC)
+    
+    # Some systems require -lcurses, some require -lncurses.
+    # Mac OS X 10.4 (and others) ships with libedit masquerading as readline,
+    # but it doesn't work well with socat. It can be recognized by the absence
+    # of append_history.
+    
+    for L in "" "-lcurses" "-lncurses"; do
+      LIBS="$LIBS_ORIG -lreadline $L"
+      AC_TRY_LINK(
+        [ #include <stdio.h>
+          #include <readline/readline.h>
+          #include <readline/history.h>],
+        [ readline(NULL);
+          append_history(0, NULL); ],
+        [ sc_usable_readline_found=1
+          break ])
+    done
+    
+    if test -n "$sc_usable_readline_found"; then
+      AC_MSG_RESULT(yes)
+      AC_DEFINE(HAVE_READLINE_READLINE_H,1)
+      AC_DEFINE(HAVE_READLINE_HISTORY_H,1)
+      AC_DEFINE(HAVE_LIBREADLINE,1)
+      AC_DEFINE(WITH_READLINE,1)
+      break
+    else
+      AC_MSG_RESULT(no)
+      CPPFLAGS=$CPPFLAGS_ORIG
+      CFLAGS=$CFLAGS_ORIG
+      LIBS=$LIBS_ORIG
+    fi
+  done
+  
+  if test -z "$sc_usable_readline_found"; then
+    AC_MSG_WARN([no suitable version of readline found; perhaps you need to install a newer version])
   fi
 fi
 
diff -ru socat-1.6.0.1/test.sh socat-1.6.0.1mac/test.sh
--- socat-1.6.0.1/test.sh	2008-02-09 22:59:11.000000000 +0100
+++ socat-1.6.0.1mac/test.sh	2008-02-20 22:19:20.000000000 +0100
@@ -83,6 +83,7 @@
 OpenBSD)IFCONFIG=/sbin/ifconfig ;;
 OSF1)  IFCONFIG=/sbin/ifconfig ;;
 SunOS) IFCONFIG=/sbin/ifconfig ;;
+Darwin)IFCONFIG=/sbin/ifconfig ;;
 #*)     IFCONFIG=/sbin/ifconfig ;;
 esac
 
@@ -140,7 +141,7 @@
 PRINTF="printf"
 
 case "$TERM" in
-vt100|vt320|linux|xterm|cons25|dtterm|aixterm|sun-color)
+vt100|vt320|linux|xterm|cons25|dtterm|aixterm|sun-color|xterm-color)
 	# there are different behaviours of printf (and echo)
 	# on some systems, echo behaves different than printf...
 	if [ $($PRINTF "\0101") = "A" ]; then
@@ -1594,6 +1595,7 @@
     OpenBSD)l=$($IFCONFIG -a |fgrep 'inet 127.0.0.1 ');;
     OSF1)  l=$($IFCONFIG -a |grep ' inet ') ;;
     SunOS) l=$($IFCONFIG -a |grep 'inet ') ;;
+    Darwin)l=$($IFCONFIG lo0 |fgrep 'inet 127.0.0.1 ') ;;
 #    *)     l=$($IFCONFIG -a |grep ' ::1[^:0-9A-Fa-f]') ;;
     esac
     [ -z "$l" ] && return 1    
@@ -1619,12 +1621,13 @@
     NetBSD)l=$(/sbin/ifconfig -a |grep 'inet6 ::1 ');;
     OSF1)  l=$(/sbin/ifconfig -a |grep ' inet6 ') ;;
     SunOS) l=$(/sbin/ifconfig -a |grep 'inet6 ') ;;
+    Darwin)l=$(/sbin/ifconfig lo0 |grep 'inet6 ::1 ') ;;
     *)     l=$(/sbin/ifconfig -a |grep ' ::1[^:0-9A-Fa-f]') ;;
     esac
     [ -z "$l" ] && return 1    
     # existence of interface might not suffice, check for routeability:
     case "$UNAME" in
-    Darwin) ping -c 1 ::1; l="$?" ;;
+    Darwin) ping6 -c 1 ::1; l="$?" ;;
     Linux)  ping6 -c 1 ::1; l="$?" ;;
     *) if [ -n "$l" ]; then l=0; else l=1; fi ;;
     esac
