/ext/sockets/config.m4

https://github.com/source-comment/php7 · m4 · 95 lines · 72 code · 13 blank · 10 comment · 0 complexity · f4bdfe585b3582b9e7a32c9126a7b78c MD5 · raw file

  1. dnl
  2. dnl $Id$
  3. dnl
  4. PHP_ARG_ENABLE(sockets, whether to enable sockets support,
  5. [ --enable-sockets Enable sockets support])
  6. if test "$PHP_SOCKETS" != "no"; then
  7. dnl Check for struct cmsghdr
  8. AC_CACHE_CHECK([for struct cmsghdr], ac_cv_cmsghdr,
  9. [
  10. AC_TRY_COMPILE([
  11. #include <sys/types.h>
  12. #include <sys/socket.h>], [struct cmsghdr s; s], ac_cv_cmsghdr=yes, ac_cv_cmsghdr=no)
  13. ])
  14. if test "$ac_cv_cmsghdr" = yes; then
  15. AC_DEFINE(HAVE_CMSGHDR,1,[Whether you have struct cmsghdr])
  16. fi
  17. AC_CHECK_FUNCS([hstrerror socketpair if_nametoindex if_indextoname])
  18. AC_CHECK_HEADERS([netdb.h netinet/tcp.h sys/un.h sys/sockio.h errno.h])
  19. AC_TRY_COMPILE([
  20. #include <sys/types.h>
  21. #include <sys/socket.h>
  22. ], [static struct msghdr tp; int n = (int) tp.msg_flags; return n],[],
  23. [AC_DEFINE(MISSING_MSGHDR_MSGFLAGS, 1, [ ])]
  24. )
  25. AC_DEFINE([HAVE_SOCKETS], 1, [ ])
  26. dnl Check for fied ss_family in sockaddr_storage (missing in AIX until 5.3)
  27. AC_CACHE_CHECK([for field ss_family in struct sockaddr_storage], ac_cv_ss_family,
  28. [
  29. AC_TRY_COMPILE([
  30. #include <sys/socket.h>
  31. #include <sys/types.h>
  32. #include <netdb.h>
  33. ], [struct sockaddr_storage sa_store; sa_store.ss_family = AF_INET6;],
  34. ac_cv_ss_family=yes, ac_cv_ss_family=no)
  35. ])
  36. if test "$ac_cv_ss_family" = yes; then
  37. AC_DEFINE(HAVE_SA_SS_FAMILY,1,[Whether you have sockaddr_storage.ss_family])
  38. fi
  39. dnl Check for AI_V4MAPPED flag
  40. AC_CACHE_CHECK([if getaddrinfo supports AI_V4MAPPED],[ac_cv_gai_ai_v4mapped],
  41. [
  42. AC_TRY_COMPILE([
  43. #include <netdb.h>
  44. ], [int flag = AI_V4MAPPED;],
  45. ac_cv_gai_ai_v4mapped=yes, ac_cv_gai_ai_v4mapped=no)
  46. ])
  47. if test "$ac_cv_gai_ai_v4mapped" = yes; then
  48. AC_DEFINE(HAVE_AI_V4MAPPED,1,[Whether you have AI_V4MAPPED])
  49. fi
  50. dnl Check for AI_ALL flag
  51. AC_CACHE_CHECK([if getaddrinfo supports AI_ALL],[ac_cv_gai_ai_all],
  52. [
  53. AC_TRY_COMPILE([
  54. #include <netdb.h>
  55. ], [int flag = AI_ALL;],
  56. ac_cv_gai_ai_all=yes, ac_cv_gai_ai_all=no)
  57. ])
  58. if test "$ac_cv_gai_ai_all" = yes; then
  59. AC_DEFINE(HAVE_AI_ALL,1,[Whether you have AI_ALL])
  60. fi
  61. dnl Check for AI_IDN flag
  62. AC_CACHE_CHECK([if getaddrinfo supports AI_IDN],[ac_cv_gai_ai_idn],
  63. [
  64. AC_TRY_COMPILE([
  65. #include <netdb.h>
  66. ], [int flag = AI_IDN;],
  67. ac_cv_gai_ai_idn=yes, ac_cv_gai_ai_idn=no)
  68. ])
  69. if test "$ac_cv_gai_ai_idn" = yes; then
  70. AC_DEFINE(HAVE_AI_IDN,1,[Whether you have AI_IDN])
  71. fi
  72. PHP_SOCKETS_CFLAGS=-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1
  73. case $host_alias in
  74. *darwin*) PHP_SOCKETS_CFLAGS="$PHP_SOCKETS_CFLAGS -D__APPLE_USE_RFC_3542"
  75. esac
  76. PHP_NEW_EXTENSION(
  77. [sockets],
  78. [sockets.c multicast.c conversions.c sockaddr_conv.c sendrecvmsg.c],
  79. [$ext_shared],,
  80. $PHP_SOCKETS_CFLAGS)
  81. PHP_INSTALL_HEADERS([ext/sockets/], [php_sockets.h])
  82. fi