Add Darwin/Mac OS X support to the build system.

diff --git a/configure b/configure
index 1f61966..7c4f9ee 100755
--- a/configure
+++ b/configure
@@ -5878,6 +5878,70 @@
 
 fi
 
+
+echo "$as_me:$LINENO: checking for poll in -lpoll" >&5
+echo $ECHO_N "checking for poll in -lpoll... $ECHO_C" >&6
+if test "${ac_cv_lib_poll_poll+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpoll  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char poll ();
+int
+main ()
+{
+poll ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_poll_poll=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_poll_poll=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_poll_poll" >&5
+echo "${ECHO_T}$ac_cv_lib_poll_poll" >&6
+if test $ac_cv_lib_poll_poll = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBPOLL 1
+_ACEOF
+
+  LIBS="-lpoll $LIBS"
+
+fi
+
 echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5
 echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6
 if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then
@@ -12521,6 +12585,62 @@
         then
           LDSHARED="\$(CC) -Wl,-G \$(SONAME:%=-Wl,-h,%)"
           LDDLL="\$(CC) -Wl,-G,-B,symbolic"
+
+        else
+          echo "$as_me:$LINENO: checking whether we can build a Mach-O (Mac OS X/Darwin) dll" >&5
+echo $ECHO_N "checking whether we can build a Mach-O (Mac OS X/Darwin) dll... $ECHO_C" >&6
+if test "${ac_cv_c_dll_macho+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_wine_try_cflags_saved=$CFLAGS
+CFLAGS="$CFLAGS -bundle"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_dll_macho="yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_dll_macho="no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+CFLAGS=$ac_wine_try_cflags_saved
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_dll_macho" >&5
+echo "${ECHO_T}$ac_cv_c_dll_macho" >&6
+          if test "$ac_cv_c_dll_macho" = "yes"
+          then
+            LIBEXT="dylib"
+            LDDLL="\$(CC) -bundle -flat_namespace -undefined suppress"
+            LDSHARED="\$(CC) -dynamiclib"
+            CFLAGS="$CFLAGS -ffixed-r13 -no-cpp-precomp"
+          fi
         fi
       fi
     fi
@@ -12675,6 +12795,9 @@
   cygwin*|mingw32*)
     LDPATH="PATH=\"\$(TOOLSDIR)/libs/unicode:\$\$PATH\""
  ;;
+  darwin*|macosx*)
+    LDPATH="DYLD_LIBRARY_PATH=\"\$(TOOLSDIR)/libs/unicode:\$\$DYLD_LIBRARY_PATH\""
+ ;;
   *)
     LDPATH="LD_LIBRARY_PATH=\"\$(TOOLSDIR)/libs/unicode:\$\$LD_LIBRARY_PATH\""
  ;;