X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fgetdomainname.m4;h=542e4cead44e65459883b06e886a37d884c30dcc;hb=395f9e6a19b504609aa8b0bd7f8cc55d4547d8dd;hp=6ce943d4f1b79388c157a2d20ad4ba84a12949f4;hpb=b2e2010c7c902235b5efb5bd3c6529f61b093aa4;p=gnulib.git diff --git a/m4/getdomainname.m4 b/m4/getdomainname.m4 index 6ce943d4f..542e4cead 100644 --- a/m4/getdomainname.m4 +++ b/m4/getdomainname.m4 @@ -1,5 +1,5 @@ -# getdomainname.m4 serial 4 -dnl Copyright (C) 2002-2003, 2008-2010 Free Software Foundation, Inc. +# getdomainname.m4 serial 8 +dnl Copyright (C) 2002-2003, 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. @@ -7,18 +7,98 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_GETDOMAINNAME], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H + AC_REQUIRE([gl_HEADER_NETDB])dnl for HAVE_NETDB_H dnl Persuade glibc to declare getdomainname(). AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - AC_REPLACE_FUNCS([getdomainname]) - if test $ac_cv_func_getdomainname = no; then - HAVE_GETDOMAINNAME=0 - gl_PREREQ_GETDOMAINNAME + dnl Where is getdomainname() defined? + dnl - On Solaris, it is in libnsl. But this function is not declared and + dnl is discouraged, see + dnl . + dnl We need to avoid a collision with this function. + dnl - Otherwise it is in libc. + AC_CHECK_FUNCS([getdomainname], , [ + AC_CACHE_CHECK([for getdomainname in -lnsl], + [gl_cv_func_getdomainname_in_libnsl], + [gl_cv_func_getdomainname_in_libnsl=no + gl_save_LIBS="$LIBS" + LIBS="$LIBS -lnsl" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + extern + #ifdef __cplusplus + "C" + #endif + int getdomainname (char *, size_t); + ]], + [[getdomainname(NULL, 0);]])], + [gl_cv_func_getdomainname_in_libnsl=yes]) + LIBS="$gl_save_LIBS" + ]) + ]) + + dnl What about the declaration? + dnl - It's int getdomainname(char *, size_t) on glibc, NetBSD, OpenBSD. + dnl - It's int getdomainname(char *, int) on MacOS X, FreeBSD, AIX, IRIX, + dnl OSF/1. + AC_CHECK_DECLS([getdomainname], , , + [#include + #ifdef HAVE_SYS_SOCKET_H + #include + #endif + #ifdef HAVE_NETDB_H + #include + #endif + #include + ]) + AC_CACHE_CHECK([for getdomainname's second argument type], + [gl_cv_decl_getdomainname_argtype2], + [if test $ac_cv_have_decl_getdomainname; then + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #ifdef HAVE_SYS_SOCKET_H + #include + #endif + #ifdef HAVE_NETDB_H + #include + #endif + #include + extern + #ifdef __cplusplus + "C" + #endif + int getdomainname (char *, int); + ]], + [[]])], + [gl_cv_decl_getdomainname_argtype2='int'], + [gl_cv_decl_getdomainname_argtype2='size_t']) + else + gl_cv_decl_getdomainname_argtype2='int' + fi + ]) + + if test $ac_cv_have_decl_getdomainname = no; then + HAVE_DECL_GETDOMAINNAME=0 + fi + + if { test $ac_cv_func_getdomainname = yes \ + && test $gl_cv_decl_getdomainname_argtype2 != size_t; \ + } \ + || test "$gl_cv_func_getdomainname_in_libnsl" = yes; then + REPLACE_GETDOMAINNAME=1 fi ]) # Prerequisites of lib/getdomainname.c. AC_DEFUN([gl_PREREQ_GETDOMAINNAME], [ - : + if test $ac_cv_func_getdomainname = yes; then + AC_DEFINE([HAVE_GETDOMAINNAME], [1], + [Define if the getdomainname() function is present and can be used.]) + fi + AC_CHECK_HEADERS([sys/systeminfo.h]) + AC_CHECK_FUNCS([sysinfo]) ])