xref: /PHP-8.2/ext/sockets/config.m4 (revision 07aaa34c)
1PHP_ARG_ENABLE([sockets],
2  [whether to enable sockets support],
3  [AS_HELP_STRING([--enable-sockets],
4    [Enable sockets support])])
5
6if test "$PHP_SOCKETS" != "no"; then
7  AC_CHECK_FUNCS([hstrerror if_nametoindex if_indextoname])
8  AC_CHECK_HEADERS([netinet/tcp.h sys/un.h sys/sockio.h])
9  AC_DEFINE([HAVE_SOCKETS], 1, [ ])
10
11  dnl Check for fied ss_family in sockaddr_storage (missing in AIX until 5.3)
12  AC_CACHE_CHECK([for field ss_family in struct sockaddr_storage], ac_cv_ss_family,
13  [
14    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
15#include <sys/socket.h>
16#include <sys/types.h>
17#include <netdb.h>
18  ]], [[struct sockaddr_storage sa_store; sa_store.ss_family = AF_INET6;]])],
19    [ac_cv_ss_family=yes], [ac_cv_ss_family=no])
20  ])
21
22  if test "$ac_cv_ss_family" = yes; then
23    AC_DEFINE(HAVE_SA_SS_FAMILY,1,[Whether you have sockaddr_storage.ss_family])
24  fi
25
26  dnl Check for AI_V4MAPPED flag
27  AC_CACHE_CHECK([if getaddrinfo supports AI_V4MAPPED],[ac_cv_gai_ai_v4mapped],
28  [
29    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
30#include <netdb.h>
31  ]], [[int flag = AI_V4MAPPED;]])],
32    [ac_cv_gai_ai_v4mapped=yes], [ac_cv_gai_ai_v4mapped=no])
33  ])
34
35  if test "$ac_cv_gai_ai_v4mapped" = yes; then
36    AC_DEFINE(HAVE_AI_V4MAPPED,1,[Whether you have AI_V4MAPPED])
37  fi
38
39  dnl Check for AI_ALL flag
40  AC_CACHE_CHECK([if getaddrinfo supports AI_ALL],[ac_cv_gai_ai_all],
41  [
42    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
43#include <netdb.h>
44  ]], [[int flag = AI_ALL;]])],
45    [ac_cv_gai_ai_all=yes], [ac_cv_gai_ai_all=no])
46  ])
47
48  if test "$ac_cv_gai_ai_all" = yes; then
49    AC_DEFINE(HAVE_AI_ALL,1,[Whether you have AI_ALL])
50  fi
51
52  dnl Check for AI_IDN flag
53  AC_CACHE_CHECK([if getaddrinfo supports AI_IDN],[ac_cv_gai_ai_idn],
54  [
55    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
56#include <netdb.h>
57  ]], [[int flag = AI_IDN;]])],
58      [ac_cv_gai_ai_idn=yes], [ac_cv_gai_ai_idn=no])
59  ])
60
61  if test "$ac_cv_gai_ai_idn" = yes; then
62    AC_DEFINE(HAVE_AI_IDN,1,[Whether you have AI_IDN])
63  fi
64
65  dnl Check for struct ucred
66  dnl checking the header is not enough	(eg DragonFlyBSD)
67  AC_CACHE_CHECK([if ancillary credentials uses ucred],[ac_cv_ucred],
68  [
69    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
70#ifndef _GNU_SOURCE
71#define _GNU_SOURCE
72#endif
73#include <sys/socket.h>
74  ]], [[struct ucred u = {.gid = 0};]])],
75      [ac_cv_ucred=yes], [ac_cv_ucred=no])
76  ])
77
78  if test "$ac_cv_ucred" = yes; then
79    AC_DEFINE(ANC_CREDS_UCRED,1,[Uses ucred struct])
80  fi
81
82  dnl Check for struct cmsgcred
83  AC_CACHE_CHECK([if ancillary credentials uses cmsgcred],[ac_cv_cmsgcred],
84  [
85    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
86#include <sys/socket.h>
87  ]], [[struct cmsgcred c = {0};]])],
88      [ac_cv_cmsgcred=yes], [ac_cv_cmsgcred=no])
89  ])
90
91  if test "$ac_cv_cmsgcred" = yes; then
92    AC_DEFINE(ANC_CREDS_CMSGCRED,1,[Uses cmsgcred struct])
93  fi
94
95
96  PHP_SOCKETS_CFLAGS=-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1
97  case $host_alias in
98  *darwin*) PHP_SOCKETS_CFLAGS="$PHP_SOCKETS_CFLAGS -D__APPLE_USE_RFC_3542"
99  esac
100  PHP_NEW_EXTENSION(
101    [sockets],
102    [sockets.c multicast.c conversions.c sockaddr_conv.c sendrecvmsg.c],
103    [$ext_shared],,
104    $PHP_SOCKETS_CFLAGS)
105  PHP_INSTALL_HEADERS([ext/sockets/], [php_sockets.h])
106fi
107