]> git.saurik.com Git - wxWidgets.git/blob - build/aclocal/ax_func_which_gethostbyname_r.m4
reSWIGged
[wxWidgets.git] / build / aclocal / ax_func_which_gethostbyname_r.m4
1 dnl @synopsis AX_FUNC_WHICH_GETHOSTBYNAME_R
2 dnl
3 dnl Determines which historical variant of the gethostbyname_r() call
4 dnl (taking three, five, or six arguments) is available on the system
5 dnl and defines one of the following macros accordingly:
6 dnl
7 dnl HAVE_FUNC_GETHOSTBYNAME_R_6
8 dnl HAVE_FUNC_GETHOSTBYNAME_R_5
9 dnl HAVE_FUNC_GETHOSTBYNAME_R_3
10 dnl
11 dnl If used in conjunction with gethostname.c, the API demonstrated in
12 dnl test.c can be used regardless of which gethostbyname_r() is
13 dnl available. These example files can be found at
14 dnl http://www.csn.ul.ie/~caolan/publink/gethostbyname_r
15 dnl
16 dnl based on David Arnold's autoconf suggestion in the threads faq
17 dnl
18 dnl Originally named "AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R". Rewritten
19 dnl for Autoconf 2.5x by Daniel Richard G.
20 dnl
21 dnl @category InstalledPackages
22 dnl @author Caolan McNamara <caolan@skynet.ie>
23 dnl @author Daniel Richard G. <skunk@iskunk.org>
24 dnl @version 2005-01-21
25 dnl @license GPLWithACException
26
27 AC_DEFUN([AX_FUNC_WHICH_GETHOSTBYNAME_R], [
28
29 AC_LANG_PUSH(C)
30 AC_MSG_CHECKING([how many arguments gethostbyname_r() takes])
31
32 AC_CACHE_VAL(ac_cv_func_which_gethostbyname_r, [
33
34 ################################################################
35
36 ac_cv_func_which_gethostbyname_r=unknown
37
38 #
39 # ONE ARGUMENT (sanity check)
40 #
41
42 # This should fail, as there is no variant of gethostbyname_r() that takes
43 # a single argument. If it actually compiles, then we can assume that
44 # netdb.h is not declaring the function, and the compiler is thereby
45 # assuming an implicit prototype. In which case, we're out of luck.
46 #
47 AC_COMPILE_IFELSE(
48 AC_LANG_PROGRAM(
49 [[#include <netdb.h>]],
50 [[
51 char *name = "www.gnu.org";
52 (void)gethostbyname_r(name) /* ; */
53 ]]),
54 ac_cv_func_which_gethostbyname_r=no)
55
56 #
57 # SIX ARGUMENTS
58 # (e.g. Linux)
59 #
60
61 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
62
63 AC_COMPILE_IFELSE(
64 AC_LANG_PROGRAM(
65 [[#include <netdb.h>]],
66 [[
67 char *name = "www.gnu.org";
68 struct hostent ret, *retp;
69 char buf@<:@1024@:>@;
70 int buflen = 1024;
71 int my_h_errno;
72 (void)gethostbyname_r(name, &ret, buf, buflen, &retp, &my_h_errno) /* ; */
73 ]]),
74 ac_cv_func_which_gethostbyname_r=six)
75
76 fi
77
78 #
79 # FIVE ARGUMENTS
80 # (e.g. Solaris)
81 #
82
83 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
84
85 AC_COMPILE_IFELSE(
86 AC_LANG_PROGRAM(
87 [[#include <netdb.h>]],
88 [[
89 char *name = "www.gnu.org";
90 struct hostent ret;
91 char buf@<:@1024@:>@;
92 int buflen = 1024;
93 int my_h_errno;
94 (void)gethostbyname_r(name, &ret, buf, buflen, &my_h_errno) /* ; */
95 ]]),
96 ac_cv_func_which_gethostbyname_r=five)
97
98 fi
99
100 #
101 # THREE ARGUMENTS
102 # (e.g. AIX, HP-UX, Tru64)
103 #
104
105 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
106
107 AC_COMPILE_IFELSE(
108 AC_LANG_PROGRAM(
109 [[#include <netdb.h>]],
110 [[
111 char *name = "www.gnu.org";
112 struct hostent ret;
113 struct hostent_data data;
114 (void)gethostbyname_r(name, &ret, &data) /* ; */
115 ]]),
116 ac_cv_func_which_gethostbyname_r=three)
117
118 fi
119
120 ################################################################
121
122 ]) dnl end AC_CACHE_VAL
123
124 case "$ac_cv_func_which_gethostbyname_r" in
125 three)
126 AC_MSG_RESULT([three])
127 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_3)
128 ;;
129
130 five)
131 AC_MSG_RESULT([five])
132 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_5)
133 ;;
134
135 six)
136 AC_MSG_RESULT([six])
137 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_6)
138 ;;
139
140 no)
141 AC_MSG_RESULT([cannot find function declaration in netdb.h])
142 ;;
143
144 unknown)
145 AC_MSG_RESULT([can't tell])
146 ;;
147
148 *)
149 AC_MSG_ERROR([internal error])
150 ;;
151 esac
152
153 AC_LANG_POP(C)
154
155 ]) dnl end AC_DEFUN