1
dnl $Id: ac_caolan_func_which_gethostbyname_r.m4,v 1.3 2006/03/29 16:24:36 freddy77 Exp $
3
# @synopsis AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R
5
# Provides a test to determine the correct
6
# way to call gethostbyname_r
8
# defines HAVE_FUNC_GETHOSTBYNAME_R_6 if it needs 6 arguments (e.g linux)
9
# defines HAVE_FUNC_GETHOSTBYNAME_R_5 if it needs 5 arguments (e.g. solaris)
10
# defines HAVE_FUNC_GETHOSTBYNAME_R_3 if it needs 3 arguments (e.g. osf/1)
12
# if used in conjunction in gethostname.c the api demonstrated
13
# in test.c can be used regardless of which gethostbyname_r
14
# exists. These example files found at
15
# http://www.csn.ul.ie/~caolan/publink/gethostbyname_r
17
# @author Caolan McNamara <caolan@skynet.ie>
18
# updated with AC_LINK_IFELSE March 2006 <jklowden@schemamania.org>.
19
# Could probably be replaced with better version:
20
# http://autoconf-archive.cryp.to/ax_func_which_gethostbyname_r.html
22
# based on David Arnold's autoconf suggestion in the threads faq
24
AC_DEFUN([AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R],
25
[ac_save_CFLAGS=$CFLAGS
26
CFLAGS="$CFLAGS $NETWORK_LIBS"
27
AC_CACHE_CHECK(for which type of gethostbyname_r, ac_cv_func_which_gethostname_r, [
28
AC_LINK_IFELSE([AC_LANG_PROGRAM([
34
struct hostent_data data;
35
(void) gethostbyname_r(name, he, &data);
37
])],ac_cv_func_which_gethostname_r=three,
39
dnl ac_cv_func_which_gethostname_r=no
40
AC_LINK_IFELSE([AC_LANG_PROGRAM([
44
struct hostent *he, *res;
48
(void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
49
]])],ac_cv_func_which_gethostname_r=six,
52
dnl ac_cv_func_which_gethostname_r=no
53
AC_LINK_IFELSE([AC_LANG_PROGRAM([
61
(void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
62
]])],ac_cv_func_which_gethostname_r=five,ac_cv_func_which_gethostname_r=no)
70
if test $ac_cv_func_which_gethostname_r = six; then
71
AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_6, 1, [Define to 1 if your system provides the 6-parameter version of gethostbyname_r().])
72
elif test $ac_cv_func_which_gethostname_r = five; then
73
AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_5, 1, [Define to 1 if your system provides the 5-parameter version of gethostbyname_r().])
74
elif test $ac_cv_func_which_gethostname_r = three; then
75
AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_3, 1, [Define to 1 if your system provides the 3-parameter version of gethostbyname_r().])
78
CFLAGS=$ac_save_CFLAGS