4
0

acinclude.m4 2.3 KB

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