php-src/ext/posix/config.m4
Peter Kokot f9cfd40fa2
Refactor utsname.domainname struct member Autoconf check (#13336)
* Refactor utsname.domainname struct member Autoconf check

Autoconf's AC_CHECK_MEMBERS macro (available since Autoconf 2.50) can be
used instead of the compile check. This was originally implemented for
IRIX compatibility, when Autoconf 2.13 didn't have the struct members
checking macro yet.

Macro by default here defines the HAVE_STRUCT_UTSNAME_DOMAINNAME symbol.

* Remove also redundant DARWIN symbol check

Checking in the configuration step also correctly detects missing struct
member on Darwin systems (macos...).
2024-02-06 23:21:42 +01:00

46 lines
1.4 KiB
Plaintext

PHP_ARG_ENABLE([posix],
[whether to enable POSIX-like functions],
[AS_HELP_STRING([--disable-posix],
[Disable POSIX-like functions])],
[yes])
if test "$PHP_POSIX" = "yes"; then
AC_DEFINE(HAVE_POSIX, 1, [whether to include POSIX-like functions])
PHP_NEW_EXTENSION(posix, posix.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
AC_CHECK_HEADERS([sys/mkdev.h sys/sysmacros.h])
AC_CHECK_FUNCS(seteuid setegid setsid getsid getpgid ctermid mkfifo mknod setrlimit getrlimit getgroups makedev initgroups getgrgid_r eaccess)
dnl Skip pathconf and fpathconf check on musl libc due to limited implementation
dnl (first argument is not validated and has different error).
AS_IF([command -v ldd >/dev/null && ldd --version 2>&1 | grep -q "^musl"],[],
[AC_CHECK_FUNCS(pathconf fpathconf)])
AC_MSG_CHECKING([for working ttyname_r() implementation])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <unistd.h>
int main(int argc, char *argv[])
{
char buf[64];
return !ttyname_r(0, buf, 64);
}
]])],[
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_TTYNAME_R, 1, [Whether you have a working ttyname_r])
],[
AC_MSG_RESULT([no, posix_ttyname() will be thread-unsafe])
], [
AC_MSG_RESULT([no, cannot detect working ttyname_r() when cross compiling. posix_ttyname() will be thread-unsafe])
])
AC_CHECK_MEMBERS([struct utsname.domainname],,,[
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sys/utsname.h>
])
fi