tCheck for select() function. - vaccinewars - be a doctor and try to vaccinate … | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit b36bd78ee5b0889699c42507f141c44542c453c0 | |
parent ad47d9c630d8d3b0261beb097a282c97aaa4ca16 | |
Author: Ben Webb <[email protected]> | |
Date: Sun, 29 Mar 2015 00:02:23 -0700 | |
Check for select() function. | |
Diffstat: | |
M CMakeLists.txt | 16 +++++++++++++++- | |
M config-cmake.h.in | 6 +++--- | |
M src/curses_client/curses_client.c | 2 +- | |
M src/util.c | 2 +- | |
4 files changed, 20 insertions(+), 6 deletions(-) | |
--- | |
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
t@@ -4,6 +4,7 @@ project(dopewars) | |
set(VERSION "SVN") | |
include(CheckIncludeFiles) | |
+include(CheckFunctionExists) | |
include(GNUInstallDirs) | |
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |
t@@ -22,12 +23,25 @@ check_include_files(sys/time.h HAVE_SYS_TIME_H) | |
check_include_files(unistd.h HAVE_UNISTD_H) | |
check_include_files(stdlib.h HAVE_STDLIB_H) | |
+# Check for socket and select even if networking gets manually | |
+# disabled below, since select is used if available for | |
+# millisecond sleeping | |
+check_function_exists(socket HAVE_SOCKET) | |
+check_function_exists(gethostbyname HAVE_GETHOSTBYNAME) | |
+check_function_exists(select HAVE_SELECT) | |
+if (${HAVE_SOCKET} AND ${HAVE_GETHOSTBYNAME} AND ${HAVE_SELECT}) | |
+ set(HAVE_NETWORK ON) | |
+else() | |
+ set(HAVE_NETWORK OFF) | |
+endif() | |
+ | |
# Process client options | |
option(GUI_CLIENT "include graphical client (GTK+/Win32)" ON) | |
option(CURSES_CLIENT "include curses client" ON) | |
option(GUI_SERVER "use a simple GTK+/Win32 GUI for the server" "probe") | |
option(NETWORKING | |
- "should dopewars use TCP/IP networking to connect to servers?" ON) | |
+ "should dopewars use TCP/IP networking to connect to servers?" | |
+ ${HAVE_NETWORK}) | |
option(WITH_ESD "support ESD sound output" ON) | |
option(WITH_SDL "support SDL sound output" ON) | |
diff --git a/config-cmake.h.in b/config-cmake.h.in | |
t@@ -52,7 +52,7 @@ | |
#undef HAVE_FORK | |
/* Define to 1 if you have the `gethostbyname' function. */ | |
-#undef HAVE_GETHOSTBYNAME | |
+#cmakedefine HAVE_GETHOSTBYNAME | |
/* Define to 1 if you have the `getopt' function. */ | |
#undef HAVE_GETOPT | |
t@@ -85,10 +85,10 @@ | |
#undef HAVE_SDL_MIXER | |
/* Define to 1 if you have the `select' function. */ | |
-#undef HAVE_SELECT | |
+#cmakedefine HAVE_SELECT | |
/* Define to 1 if you have the `socket' function. */ | |
-#undef HAVE_SOCKET | |
+#cmakedefine HAVE_SOCKET | |
/* Do we have the socklen_t data type? */ | |
#undef HAVE_SOCKLEN_T | |
diff --git a/src/curses_client/curses_client.c b/src/curses_client/curses_clien… | |
t@@ -2502,7 +2502,7 @@ static void Curses_DoGame(Player *Play) | |
} | |
} | |
if (FD_ISSET(0, &readfs)) { | |
-#elif HAVE_SELECT | |
+#elif defined(HAVE_SELECT) | |
FD_ZERO(&readfs); | |
FD_SET(0, &readfs); | |
MaxSock = 1; | |
diff --git a/src/util.c b/src/util.c | |
t@@ -231,7 +231,7 @@ void ReleaseLock(FILE * fp) | |
*/ | |
void MicroSleep(int microsec) | |
{ | |
-#if HAVE_SELECT || CYGWIN | |
+#if defined(HAVE_SELECT) || CYGWIN | |
struct timeval tv; | |
tv.tv_sec = 0; |