]> git.saurik.com Git - wxWidgets.git/blob - build/aclocal/ax_func_which_gethostbyname_r.m4
correct base for carbon is 10.6 max
[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 )],
55 ac_cv_func_which_gethostbyname_r=no
56 )
57
58 #
59 # SIX ARGUMENTS
60 # (e.g. Linux)
61 #
62
63 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
64
65 AC_COMPILE_IFELSE(
66 [AC_LANG_PROGRAM(
67 [[#include <netdb.h>]],
68 [[
69 char *name = "www.gnu.org";
70 struct hostent ret, *retp;
71 char buf@<:@1024@:>@;
72 int buflen = 1024;
73 int my_h_errno;
74 (void)gethostbyname_r(name, &ret, buf, buflen, &retp, &my_h_errno) /* ; */
75 ]]
76 )],
77 ac_cv_func_which_gethostbyname_r=six
78 )
79
80 fi
81
82 #
83 # FIVE ARGUMENTS
84 # (e.g. Solaris)
85 #
86
87 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
88
89 AC_COMPILE_IFELSE(
90 [AC_LANG_PROGRAM(
91 [[#include <netdb.h>]],
92 [[
93 char *name = "www.gnu.org";
94 struct hostent ret;
95 char buf@<:@1024@:>@;
96 int buflen = 1024;
97 int my_h_errno;
98 (void)gethostbyname_r(name, &ret, buf, buflen, &my_h_errno) /* ; */
99 ]]
100 )],
101 ac_cv_func_which_gethostbyname_r=five
102 )
103
104 fi
105
106 #
107 # THREE ARGUMENTS
108 # (e.g. AIX, HP-UX, Tru64)
109 #
110
111 if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
112
113 AC_COMPILE_IFELSE(
114 [AC_LANG_PROGRAM(
115 [[#include <netdb.h>]],
116 [[
117 char *name = "www.gnu.org";
118 struct hostent ret;
119 struct hostent_data data;
120 (void)gethostbyname_r(name, &ret, &data) /* ; */
121 ]]
122 )],
123 ac_cv_func_which_gethostbyname_r=three
124 )
125
126 fi
127
128 ################################################################
129
130 ]) dnl end AC_CACHE_VAL
131
132 case "$ac_cv_func_which_gethostbyname_r" in
133 three)
134 AC_MSG_RESULT([three])
135 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_3)
136 ;;
137
138 five)
139 AC_MSG_RESULT([five])
140 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_5)
141 ;;
142
143 six)
144 AC_MSG_RESULT([six])
145 AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_6)
146 ;;
147
148 no)
149 AC_MSG_RESULT([cannot find function declaration in netdb.h])
150 ;;
151
152 unknown)
153 AC_MSG_RESULT([can't tell])
154 ;;
155
156 *)
157 AC_MSG_ERROR([internal error])
158 ;;
159 esac
160
161 AC_LANG_POP(C)
162
163 ]) dnl end AC_DEFUN