Skip to content

Commit cfec809

Browse files
committed
update musl libc test to fix "cross" compilation on glibc system
1 parent 73b1ebf commit cfec809

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

configure.ac

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,21 @@ esac
236236

237237
dnl Detect musl libc
238238
AC_MSG_CHECKING([whether we are using musl libc])
239-
if command -v ldd >/dev/null && ldd --version 2>&1 | grep ^musl >/dev/null 2>&1
240-
then
241-
AC_MSG_RESULT([yes])
242-
AC_DEFINE([__MUSL__], [1], [Define to 1 when using musl libc.])
243-
else
244-
AC_MSG_RESULT([no])
245-
fi
239+
AC_COMPILE_IFELSE(
240+
[AC_LANG_SOURCE([[
241+
#ifndef _GNU_SOURCE
242+
#define _GNU_SOURCE
243+
#endif
244+
#include <features.h>
245+
#ifdef __USE_GNU
246+
#error Not using musl
247+
#endif
248+
int main() { return 0; }
249+
]])],
250+
[AC_MSG_RESULT([yes])
251+
AC_DEFINE([__MUSL__], [1], [Define to 1 when using musl libc.])],
252+
[AC_MSG_RESULT([no])]
253+
)
246254

247255
dnl Add _GNU_SOURCE compile definition because the php_config.h with definitions
248256
dnl by AC_USE_SYSTEM_EXTENSIONS might be included after the system headers which

0 commit comments

Comments
 (0)