From bc023abbbbd2b136da9ff65efbbb726daa9fc907 Mon Sep 17 00:00:00 2001 From: Michael Wetherell Date: Wed, 9 Aug 2006 11:18:24 +0000 Subject: [PATCH] Detect and use sys/select.h required by POSIX for select git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40530 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- configure | 164 ++++++++++++++++++++++++++++++++++++++++-- configure.in | 5 ++ setup.h.in | 3 + setup.h_vms | 3 + src/gtk/app.cpp | 3 + src/gtk1/app.cpp | 3 + src/motif/evtloop.cpp | 4 ++ src/unix/gsocket.cpp | 4 ++ src/unix/joystick.cpp | 4 ++ src/unix/utilsunx.cpp | 4 ++ src/x11/evtloop.cpp | 4 ++ 11 files changed, 195 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 4d30f6bf97..f0932740d1 100755 --- a/configure +++ b/configure @@ -17346,6 +17346,158 @@ case "${host}" in ;; esac +if test "$USE_UNIX" = 1 ; then + +for ac_header in sys/select.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (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); }; } && + { ac_try='test -s conftest.$ac_objext' + { (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_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ----------------------------------------- ## +## Report this to wx-dev@lists.wxwidgets.org ## +## ----------------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +fi + echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 @@ -28530,7 +28682,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -28557,7 +28709,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do - if test -r "$ac_dir/X11/Xlib.h"; then + if test -r "$ac_dir/X11/Intrinsic.h"; then ac_x_includes=$ac_dir break fi @@ -28571,18 +28723,18 @@ if test "$ac_x_libraries" = no; then # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS - LIBS="-lX11 $LIBS" + LIBS="-lXt $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include int main () { -XrmInitialize () +XtMalloc (0) ; return 0; } @@ -28620,7 +28772,7 @@ for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` do # Don't even attempt the hair of trying to link an X program! for ac_extension in a so sl; do - if test -r $ac_dir/libX11.$ac_extension; then + if test -r $ac_dir/libXt.$ac_extension; then ac_x_libraries=$ac_dir break 2 fi diff --git a/configure.in b/configure.in index 5039a1867e..4368d689c6 100644 --- a/configure.in +++ b/configure.in @@ -1801,6 +1801,11 @@ case "${host}" in ;; esac +dnl POSIX needs this for select(), but old systems don't have it +if test "$USE_UNIX" = 1 ; then + AC_CHECK_HEADERS([sys/select.h]) +fi + dnl --------------------------------------------------------------------------- dnl Checks for compiler characteristics dnl --------------------------------------------------------------------------- diff --git a/setup.h.in b/setup.h.in index 306348bfd3..b4d0aadddd 100644 --- a/setup.h.in +++ b/setup.h.in @@ -1081,6 +1081,9 @@ /* Define if you have Pango xft support */ #undef HAVE_PANGO_XFT +/* Define if you have the header file. */ +#undef HAVE_SYS_SELECT_H + /* ------------------------------------------------------------------------- Win32 adjustments section ------------------------------------------------------------------------- */ diff --git a/setup.h_vms b/setup.h_vms index 1545d17432..382eebec3f 100644 --- a/setup.h_vms +++ b/setup.h_vms @@ -1155,6 +1155,9 @@ typedef pid_t GPid; /* Define if you have Pango xft support */ #undef HAVE_PANGO_XFT +/* Define if you have the header file. */ +#undef HAVE_SYS_SELECT_H + /* --------------------------------------------------------------------- Win32 adjustments section --------------------------------------------------------------------- diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index c9f6bbc827..52d8556a65 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -70,6 +70,9 @@ #include #include #include + #ifdef HAVE_SYS_SELECT_H + #include + #endif #endif // HAVE_POLL/!HAVE_POLL #include "wx/unix/private.h" diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 65f7a46441..24d091a897 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -74,6 +74,9 @@ #include #include #include + #ifdef HAVE_SYS_SELECT_H + #include + #endif #endif // HAVE_POLL/!HAVE_POLL #include "wx/unix/private.h" diff --git a/src/motif/evtloop.cpp b/src/motif/evtloop.cpp index 4271f4577c..03049f43da 100644 --- a/src/motif/evtloop.cpp +++ b/src/motif/evtloop.cpp @@ -45,6 +45,10 @@ #include "wx/unix/private.h" #include "wx/motif/private.h" +#ifdef HAVE_SYS_SELECT_H +# include +#endif + static bool CheckForKeyUp(XEvent* event); static bool CheckForKeyDown(XEvent* event); static bool CheckForAccelerator(XEvent* event); diff --git a/src/unix/gsocket.cpp b/src/unix/gsocket.cpp index 0b255fb182..bf29390d94 100644 --- a/src/unix/gsocket.cpp +++ b/src/unix/gsocket.cpp @@ -39,6 +39,10 @@ #include #include +#ifdef HAVE_SYS_SELECT_H +# include +#endif + #ifdef __VMS__ #include struct sockaddr_un diff --git a/src/unix/joystick.cpp b/src/unix/joystick.cpp index 49a4cad688..64afa78cb9 100644 --- a/src/unix/joystick.cpp +++ b/src/unix/joystick.cpp @@ -29,6 +29,10 @@ #include #include +#ifdef HAVE_SYS_SELECT_H +# include +#endif + #include "wx/unix/private.h" enum { diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index 29c1320025..41f5184b3a 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -39,6 +39,10 @@ #include +#ifdef HAVE_SYS_SELECT_H +# include +#endif + #define HAS_PIPE_INPUT_STREAM (wxUSE_STREAMS && wxUSE_FILE) #if HAS_PIPE_INPUT_STREAM diff --git a/src/x11/evtloop.cpp b/src/x11/evtloop.cpp index fa380fcc0d..0295cd1559 100644 --- a/src/x11/evtloop.cpp +++ b/src/x11/evtloop.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef HAVE_SYS_SELECT_H +# include +#endif + #if wxUSE_SOCKETS // ---------------------------------------------------------------------------- // wxSocketTable -- 2.45.2