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