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