@@ -2488,3 +2488,43 @@ AC_DEFUN([PHP_REMOVE_OPTIMIZATION_FLAGS], [
24882488 CFLAGS=$(echo "$CFLAGS" | $SED -e "$sed_script")
24892489 CXXFLAGS=$(echo "$CXXFLAGS" | $SED -e "$sed_script")
24902490] )
2491+
2492+ dnl
2493+ dnl PHP_C_STANDARD_LIBRARY
2494+ dnl
2495+ dnl Determine the C standard library used for the build. The uclibc is checked
2496+ dnl first because it also defines the __GLIBC__ and could otherwise be detected
2497+ dnl as glibc. Musl C library is determined heuristically.
2498+ dnl
2499+ AC_DEFUN ( [ PHP_C_STANDARD_LIBRARY] ,
2500+ [ AC_CACHE_CHECK ( [ C standard library implementation] ,
2501+ [ php_cv_c_standard_library] ,
2502+ [ php_cv_c_standard_library=unknown
2503+ dnl Check if C standard library is uclibc.
2504+ AS_VAR_IF ( [ php_cv_c_standard_library] , [ unknown] ,
2505+ [ AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ #include <features.h>] ,
2506+ [ #ifndef __UCLIBC__
2507+ (void) __UCLIBC__;
2508+ #endif] ) ] ,
2509+ [ php_cv_c_standard_library=uclibc] ,
2510+ [ php_cv_c_standard_library=unknown] ) ] )
2511+ dnl Check if C standard library is GNU C.
2512+ AS_VAR_IF ( [ php_cv_c_standard_library] , [ unknown] ,
2513+ [ AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ #include <features.h>] ,
2514+ [ #ifndef __GLIBC__
2515+ (void) __GLIBC__;
2516+ #endif] ) ] ,
2517+ [ php_cv_c_standard_library=glibc] ,
2518+ [ php_cv_c_standard_library=unknown] ) ] )
2519+ dnl Check if C standard library is musl libc.
2520+ AS_VAR_IF ( [ php_cv_c_standard_library] , [ unknown] ,
2521+ [ AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ #include <stdarg.h>] ,
2522+ [ #ifndef __DEFINED_va_list
2523+ (void) __DEFINED_va_list;
2524+ #endif] ) ] ,
2525+ [ php_cv_c_standard_library=musl] ,
2526+ [ AS_IF ( [ command -v ldd >/dev/null && ldd --version 2>&1 | grep ^musl >/dev/null 2>&1] ,
2527+ [ php_cv_c_standard_library=musl] ,
2528+ [ php_cv_c_standard_library=unknown] ) ] ) ] )
2529+ ] )
2530+ ] )
0 commit comments