php-src/ext/posix/config.m4
Peter Kokot ff2b50889c
Refactor checks for fpathconf and pathconf
These two might not be available everywhere so we check them in
config.m4 when doing the configure step. Check is skipped for musl libc
due to limited implementation.

Constants that are defined into main/php_config.h:
HAVE_FPATHCONF
HAVE_PATHCONF

Implemented via GH-10238
Related to GH-10350
Fixes GH-12725
2023-11-20 13:39:21 +00:00

54 lines
1.8 KiB
Text

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_CACHE_CHECK([for utsname.domainname], ac_cv_have_utsname_domainname, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#define _GNU_SOURCE
#include <sys/utsname.h>
]],[[
return sizeof(((struct utsname *)0)->domainname);
]])],[
ac_cv_have_utsname_domainname=yes
],[
ac_cv_have_utsname_domainname=no
])
])
if test "$ac_cv_have_utsname_domainname" = yes; then
AC_DEFINE(HAVE_UTSNAME_DOMAINNAME, 1, [Whether struct utsname has domainname])
fi
fi