xref: /PHP-8.3/ext/posix/config.m4 (revision ff2b5088)
1PHP_ARG_ENABLE([posix],
2  [whether to enable POSIX-like functions],
3  [AS_HELP_STRING([--disable-posix],
4    [Disable POSIX-like functions])],
5  [yes])
6
7if test "$PHP_POSIX" = "yes"; then
8  AC_DEFINE(HAVE_POSIX, 1, [whether to include POSIX-like functions])
9  PHP_NEW_EXTENSION(posix, posix.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
10
11  AC_CHECK_HEADERS([sys/mkdev.h sys/sysmacros.h])
12
13  AC_CHECK_FUNCS(seteuid setegid setsid getsid getpgid ctermid mkfifo mknod setrlimit getrlimit getgroups makedev initgroups getgrgid_r eaccess)
14
15dnl Skip pathconf and fpathconf check on musl libc due to limited implementation
16dnl (first argument is not validated and has different error).
17  AS_IF([command -v ldd >/dev/null && ldd --version 2>&1 | grep -q "^musl"],[],
18    [AC_CHECK_FUNCS(pathconf fpathconf)])
19
20  AC_MSG_CHECKING([for working ttyname_r() implementation])
21  AC_RUN_IFELSE([AC_LANG_SOURCE([[
22#include <unistd.h>
23
24int main(int argc, char *argv[])
25{
26	char buf[64];
27
28	return !ttyname_r(0, buf, 64);
29}
30  ]])],[
31    AC_MSG_RESULT([yes])
32    AC_DEFINE(HAVE_TTYNAME_R, 1, [Whether you have a working ttyname_r])
33  ],[
34    AC_MSG_RESULT([no, posix_ttyname() will be thread-unsafe])
35  ], [
36    AC_MSG_RESULT([no, cannot detect working ttyname_r() when cross compiling. posix_ttyname() will be thread-unsafe])
37  ])
38
39  AC_CACHE_CHECK([for utsname.domainname], ac_cv_have_utsname_domainname, [
40    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
41      #define _GNU_SOURCE
42      #include <sys/utsname.h>
43    ]],[[
44      return sizeof(((struct utsname *)0)->domainname);
45    ]])],[
46      ac_cv_have_utsname_domainname=yes
47    ],[
48      ac_cv_have_utsname_domainname=no
49    ])
50  ])
51  if test "$ac_cv_have_utsname_domainname" = yes; then
52    AC_DEFINE(HAVE_UTSNAME_DOMAINNAME, 1, [Whether struct utsname has domainname])
53  fi
54fi
55