@@ -2502,3 +2502,43 @@ AC_DEFUN([PHP_REMOVE_OPTIMIZATION_FLAGS], [
25022502 CFLAGS=$(echo "$CFLAGS" | $SED -e "$sed_script")
25032503 CXXFLAGS=$(echo "$CXXFLAGS" | $SED -e "$sed_script")
25042504] )
2505+
2506+ dnl
2507+ dnl PHP_C_STANDARD_LIBRARY
2508+ dnl
2509+ dnl Determine the C standard library used for the build. The uclibc is checked
2510+ dnl first because it also defines the __GLIBC__ and could otherwise be detected
2511+ dnl as glibc. Musl C library is determined heuristically.
2512+ dnl
2513+ AC_DEFUN ( [ PHP_C_STANDARD_LIBRARY] ,
2514+ [ AC_CACHE_CHECK ( [ C standard library implementation] ,
2515+ [ php_cv_c_standard_library] ,
2516+ [ php_cv_c_standard_library=unknown
2517+ dnl Check if C standard library is uclibc.
2518+ AS_VAR_IF ( [ php_cv_c_standard_library] , [ unknown] ,
2519+ [ AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ #include <features.h>] ,
2520+ [ #ifndef __UCLIBC__
2521+ (void) __UCLIBC__;
2522+ #endif] ) ] ,
2523+ [ php_cv_c_standard_library=uclibc] ,
2524+ [ php_cv_c_standard_library=unknown] ) ] )
2525+ dnl Check if C standard library is GNU C.
2526+ AS_VAR_IF ( [ php_cv_c_standard_library] , [ unknown] ,
2527+ [ AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ #include <features.h>] ,
2528+ [ #ifndef __GLIBC__
2529+ (void) __GLIBC__;
2530+ #endif] ) ] ,
2531+ [ php_cv_c_standard_library=glibc] ,
2532+ [ php_cv_c_standard_library=unknown] ) ] )
2533+ dnl Check if C standard library is musl libc.
2534+ AS_VAR_IF ( [ php_cv_c_standard_library] , [ unknown] ,
2535+ [ AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ #include <stdarg.h>] ,
2536+ [ #ifndef __DEFINED_va_list
2537+ (void) __DEFINED_va_list;
2538+ #endif] ) ] ,
2539+ [ php_cv_c_standard_library=musl] ,
2540+ [ AS_IF ( [ command -v ldd >/dev/null && ldd --version 2>&1 | grep ^musl >/dev/null 2>&1] ,
2541+ [ php_cv_c_standard_library=musl] ,
2542+ [ php_cv_c_standard_library=unknown] ) ] ) ] )
2543+ ] )
2544+ ] )
0 commit comments