test-chown.h: correct a cast
[gnulib.git] / m4 / gethostname.m4
index e32f7e5..9bdfb7c 100644 (file)
@@ -1,5 +1,5 @@
-# gethostname.m4 serial 8
-dnl Copyright (C) 2002, 2008, 2009 Free Software Foundation, Inc.
+# gethostname.m4 serial 10
+dnl Copyright (C) 2002, 2008-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -22,12 +22,12 @@ AC_DEFUN([gl_FUNC_GETHOSTNAME],
       [gl_cv_w32_gethostname=no
        gl_save_LIBS="$LIBS"
        LIBS="$LIBS -lws2_32"
-       AC_TRY_LINK([
+       AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #ifdef HAVE_WINSOCK2_H
 #include <winsock2.h>
 #endif
 #include <stddef.h>
-], [gethostname(NULL, 0);], [gl_cv_w32_gethostname=yes])
+]], [[gethostname(NULL, 0);]])], [gl_cv_w32_gethostname=yes])
        LIBS="$gl_save_LIBS"
       ])
     if test "$gl_cv_w32_gethostname" = "yes"; then
@@ -83,7 +83,11 @@ lucky
 #if HAVE_NETDB_H
 # include <netdb.h>
 #endif
-])
+],
+          [dnl The system does not define MAXHOSTNAMELEN in any of the common
+           dnl headers. Use a safe fallback.
+           gl_cv_decl_HOST_NAME_MAX=256
+          ])
       fi
     fi
   ])