annotate m4/getdomainname.m4 @ 14434:7624b26aea3d

sys_socket, netdb: Document problem with socklen_t. * doc/posix-headers/sys_socket.texi: Mention lack of socklen_t on some platforms. * doc/posix-headers/netdb.texi: Likewise.
author Bruno Haible <bruno@clisp.org>
date Sat, 19 Mar 2011 13:39:12 +0100
parents 97fc9a21a8fb
children f16721915551
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13911
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
1 # getdomainname.m4 serial 5
14079
97fc9a21a8fb maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents: 13911
diff changeset
2 dnl Copyright (C) 2002-2003, 2008-2011 Free Software Foundation, Inc.
5611
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4730
diff changeset
3 dnl This file is free software; the Free Software Foundation
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4730
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4730
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
4730
64e0a1bfa9bb New module 'getdomainname'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
64e0a1bfa9bb New module 'getdomainname'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_GETDOMAINNAME],
64e0a1bfa9bb New module 'getdomainname'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
10661
65c9436dc0d3 Move the getdomainname() declaration to <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents: 5611
diff changeset
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
13911
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
10 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
11 AC_REQUIRE([gl_HEADER_NETDB])dnl for HAVE_NETDB_H
10661
65c9436dc0d3 Move the getdomainname() declaration to <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents: 5611
diff changeset
12
65c9436dc0d3 Move the getdomainname() declaration to <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents: 5611
diff changeset
13 dnl Persuade glibc <unistd.h> to declare getdomainname().
65c9436dc0d3 Move the getdomainname() declaration to <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents: 5611
diff changeset
14 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
65c9436dc0d3 Move the getdomainname() declaration to <unistd.h>.
Bruno Haible <bruno@clisp.org>
parents: 5611
diff changeset
15
13911
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
16 dnl Where is getdomainname() defined?
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
17 dnl - On Solaris, it is in libnsl. But this function is not declared and
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
18 dnl is discouraged, see
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
19 dnl <http://www.sun.com/software/solaris/programs/abi/appcert_faq.xml#q18>.
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
20 dnl We need to avoid a collision with this function.
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
21 dnl - Otherwise is is in libc.
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
22 AC_CHECK_FUNCS([getdomainname], , [
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
23 AC_CACHE_CHECK([for getdomainname in -lnsl],
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
24 [gl_cv_func_getdomainname_in_libnsl],
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
25 [gl_cv_func_getdomainname_in_libnsl=no
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
26 gl_save_LIBS="$LIBS"
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
27 LIBS="$LIBS -lnsl"
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
28 AC_LINK_IFELSE(
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
29 [AC_LANG_PROGRAM(
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
30 [[#include <stddef.h>
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
31 extern int getdomainname (char *, size_t);
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
32 ]],
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
33 [[getdomainname(NULL, 0);]])],
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
34 [gl_cv_func_getdomainname_in_libnsl=yes])
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
35 LIBS="$gl_save_LIBS"
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
36 ])
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
37 ])
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
38
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
39 dnl What about the declaration?
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
40 dnl - It's int getdomainname(char *, size_t) on glibc, NetBSD, OpenBSD.
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
41 dnl - It's int getdomainname(char *, int) on MacOS X, FreeBSD, AIX, IRIX,
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
42 dnl OSF/1.
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
43 AC_CHECK_DECLS([getdomainname], , ,
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
44 [#include <sys/types.h>
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
45 #ifdef HAVE_SYS_SOCKET_H
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
46 #include <sys/socket.h>
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
47 #endif
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
48 #ifdef HAVE_NETDB_H
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
49 #include <netdb.h>
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
50 #endif
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
51 #include <unistd.h>
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
52 ])
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
53 AC_CACHE_CHECK([for getdomainname's second argument type],
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
54 [gl_cv_decl_getdomainname_argtype2],
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
55 [if test $ac_cv_have_decl_getdomainname; then
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
56 AC_COMPILE_IFELSE(
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
57 [AC_LANG_PROGRAM(
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
58 [[#include <sys/types.h>
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
59 #ifdef HAVE_SYS_SOCKET_H
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
60 #include <sys/socket.h>
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
61 #endif
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
62 #ifdef HAVE_NETDB_H
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
63 #include <netdb.h>
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
64 #endif
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
65 #include <unistd.h>
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
66 extern int getdomainname (char *, int);]],
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
67 [[]])],
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
68 [gl_cv_decl_getdomainname_argtype2='int'],
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
69 [gl_cv_decl_getdomainname_argtype2='size_t'])
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
70 else
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
71 gl_cv_decl_getdomainname_argtype2='int'
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
72 fi
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
73 ])
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
74
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
75 if test $ac_cv_have_decl_getdomainname = no; then
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
76 HAVE_DECL_GETDOMAINNAME=0
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
77 fi
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
78
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
79 if { test $ac_cv_func_getdomainname = yes \
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
80 && test $gl_cv_decl_getdomainname_argtype2 != size_t; \
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
81 } \
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
82 || test "$gl_cv_func_getdomainname_in_libnsl" = yes; then
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
83 REPLACE_GETDOMAINNAME=1
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
84 fi
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
85
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
86 if test $HAVE_DECL_GETDOMAINNAME = 0 || test $REPLACE_GETDOMAINNAME = 1; then
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
87 AC_LIBOBJ([getdomainname])
4730
64e0a1bfa9bb New module 'getdomainname'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 gl_PREREQ_GETDOMAINNAME
64e0a1bfa9bb New module 'getdomainname'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 fi
64e0a1bfa9bb New module 'getdomainname'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 ])
64e0a1bfa9bb New module 'getdomainname'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91
64e0a1bfa9bb New module 'getdomainname'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 # Prerequisites of lib/getdomainname.c.
64e0a1bfa9bb New module 'getdomainname'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 AC_DEFUN([gl_PREREQ_GETDOMAINNAME], [
13911
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
94 if test $ac_cv_func_getdomainname = yes; then
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
95 AC_DEFINE([HAVE_GETDOMAINNAME], [1],
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
96 [Define if the getdomainname() function is present and can be used.])
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
97 fi
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
98 AC_CHECK_HEADERS([sys/systeminfo.h])
e6744cae0421 getdomainname: Use the system function when possible.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
99 AC_CHECK_FUNCS([sysinfo])
4730
64e0a1bfa9bb New module 'getdomainname'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 ])