diff --git a/configure.ac b/configure.ac index fef05085..2faa2427 100644 --- a/configure.ac +++ b/configure.ac @@ -63,15 +63,14 @@ else revctrl= fi AC_SUBST(revctrl,$revctrl) +# Not a program, but need to check this early +MY_WINDOWS_API + ### Checks for libraries ACX_PTHREAD +LIBS="$LIBS_SOCKETS $LIBS" LIB_SOCKET_NSL -# TODO merge this into LIB_SOCKET_NSL? -case "$host_os" in -*mingw32) - LIBS="-lws2_32 $LIBS" ;; -esac # TODO turn this into a macro? save_LIBS=$LIBS @@ -123,10 +122,9 @@ if test -z "$with_pthread" || test "$with_pthread" = no; then if test "$ac_cv_func_makecontext" = yes; then empthread=LWP fi - case "$host_os" in - *mingw32) - empthread=Windows ;; - esac + if test $Windows_API = yes; then + empthread=Windows + fi fi if test -z "$empthread"; then AC_MSG_ERROR([No usable thread package found]) diff --git a/m4/my_windows_api.m4 b/m4/my_windows_api.m4 new file mode 100644 index 00000000..3404cdb0 --- /dev/null +++ b/m4/my_windows_api.m4 @@ -0,0 +1,18 @@ +AC_DEFUN([MY_WINDOWS_API], +[ + AC_MSG_CHECKING([whether compiling for Windows API]) + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[#ifdef _WIN32 +#Here's a nickel, kid +#endif]])], + [Windows_API=no], + [Windows_API=yes]) + AC_MSG_RESULT([$Windows_API]) + if test $Windows_API = yes; then + AC_DEFINE([WINDOWS], 1, [Define if compiling for Windows API]) + LIBS_SOCKETS="-lws2_32" + else + LIBS_SOCKETS= + fi + AC_SUBST([LIBS_SOCKETS]) +]) diff --git a/src/client/configure.ac b/src/client/configure.ac index 2dc6a677..7a74286a 100644 --- a/src/client/configure.ac +++ b/src/client/configure.ac @@ -47,36 +47,24 @@ AC_CONFIG_HEADERS([config.h]) AC_PROG_CC AC_PROG_INSTALL +# Not a program, but need to check this early +MY_WINDOWS_API + ### Checks for libraries. -AC_SEARCH_LIBS([setupterm], [termlib termcap curses ncurses]) +LIBS="$LIBS_SOCKETS $LIBS" LIB_SOCKET_NSL -# TODO merge this into LIB_SOCKET_NSL? -if test "$ac_cv_search_gethostbyname" = no; then - dnl Can't search ws2_32 for gethostbyname using AC_SEARCH_LIBS, because - dnl it requires #include to work. - AC_MSG_CHECKING([for gethostbyname in -lws2_32]) - save_LIBS=$LIBS - LIBS="-lws2_32 $LIBS" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], - [[gethostbyname ("");]])], - [ws2_res=yes], [LIBS=save_LIBS ws2_res=no]) - AC_MSG_RESULT([$ws2_res]) -fi +AC_SEARCH_LIBS([setupterm], [termlib termcap curses ncurses]) + ### Checks for header files. ### Checks for typedefs, structures, and compiler characteristics. -AC_MSG_CHECKING([for Windows]) -AC_COMPILE_IFELSE( - [AC_LANG_SOURCE([[#ifdef _WIN32 -#Here's a nickel, kid -#endif]])], - [Windows_res=no], - [Windows_res=yes CFLAGS="$CFLAGS -mthreads"]) -AC_MSG_RESULT([$Windows_res]) +if test "$Windows_API" = yes; then + CFLAGS="$CFLAGS -mthreads" +fi ### Checks for library functions.