acinclude.m4 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. dnl @synopsis ACX_WHICH_GETHOSTBYNAME_R
  2. dnl
  3. dnl Provides a test to determine the correct way to call gethostbyname_r
  4. dnl
  5. dnl defines HAVE_GETHOSTBYNAME_R to the number of arguments required
  6. dnl
  7. dnl e.g. 6 arguments (linux)
  8. dnl e.g. 5 arguments (solaris)
  9. dnl e.g. 3 arguments (osf/1)
  10. dnl
  11. dnl @version $Id$
  12. dnl @author Brian Stafford <brian@stafford.uklinux.net>
  13. dnl
  14. dnl based on version by Caolan McNamara <caolan@skynet.ie>
  15. dnl based on David Arnold's autoconf suggestion in the threads faq
  16. dnl
  17. AC_DEFUN(ACX_WHICH_GETHOSTBYNAME_R,
  18. [AC_CACHE_CHECK(number of arguments to gethostbyname_r,
  19. acx_which_gethostbyname_r, [
  20. AC_TRY_COMPILE([
  21. # include <netdb.h>
  22. ], [
  23. char *name;
  24. struct hostent *he;
  25. struct hostent_data data;
  26. (void) gethostbyname_r(name, he, &data);
  27. ],acx_which_gethostbyname_r=3,
  28. [
  29. dnl acx_which_gethostbyname_r=0
  30. AC_TRY_COMPILE([
  31. # include <netdb.h>
  32. ], [
  33. char *name;
  34. struct hostent *he, *res;
  35. char *buffer = NULL;
  36. int buflen = 2048;
  37. int h_errnop;
  38. (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
  39. ],acx_which_gethostbyname_r=6,
  40. [
  41. dnl acx_which_gethostbyname_r=0
  42. AC_TRY_COMPILE([
  43. # include <netdb.h>
  44. ], [
  45. char *name;
  46. struct hostent *he;
  47. char *buffer = NULL;
  48. int buflen = 2048;
  49. int h_errnop;
  50. (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
  51. ],acx_which_gethostbyname_r=5,acx_which_gethostbyname_r=0)
  52. ]
  53. )
  54. ]
  55. )
  56. ])
  57. if test $acx_which_gethostbyname_r -gt 0 ; then
  58. AC_DEFINE_UNQUOTED([HAVE_GETHOSTBYNAME_R], $acx_which_gethostbyname_r,
  59. [Number of parameters to gethostbyname_r or 0 if not available])
  60. fi
  61. ])
  62. dnl @synopsis ACX_HELP_STRING(OPTION,DESCRIPTION)
  63. AC_DEFUN([ACX_HELP_STRING],
  64. [ $1 builtin([substr],[ ],len($1))[$2]])
  65. dnl @synopsis ACX_FEATURE(ENABLE_OR_WITH,NAME[,VALUE])
  66. AC_DEFUN([ACX_FEATURE],
  67. [echo "builtin([substr],[ ],len(--$1-$2))--$1-$2: ifelse($3,,[$]translit($1-$2,-,_),$3)"])