From 0752e545e46bd2d05301ff23405770823f9bade4 Mon Sep 17 00:00:00 2001
From: Giovanni Mascellani <gmascellani@codeweavers.com>
Date: Tue, 9 Jan 2024 10:31:37 +0100
Subject: [PATCH] configure: Detect pthread support using -pthread instead of
 -lpthread.

The latter links the pthread library, but doesn't set the preprocessor
state that some toolchains require. The former is the supported way
to use pthread.

This allows vkd3d to be compiled with the Android NDK.
---
 m4/check-pthread.m4 | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/m4/check-pthread.m4 b/m4/check-pthread.m4
index 5fa82ecb8b..706829d985 100644
--- a/m4/check-pthread.m4
+++ b/m4/check-pthread.m4
@@ -15,7 +15,15 @@ AS_IF([test "x$vkd3d_pthread_found" = "xno"], [PTHREAD_LIBS=""])
 LIBS="$vkd3d_libs_saved"])
 
 AS_IF([test "x$vkd3d_pthread_found" != "xyes"],
-AC_CHECK_LIB([pthread], [pthread_create],
-             [PTHREAD_LIBS="-lpthread"],
-             [AC_MSG_ERROR([libpthread not found.])]))
+[vkd3d_libs_saved="$LIBS"
+PTHREAD_LIBS="-pthread"
+LIBS="$LIBS $PTHREAD_LIBS"
+
+AC_MSG_CHECKING([checking for pthread_create in $PTHREAD_LIBS])
+AC_TRY_LINK_FUNC([pthread_create], [vkd3d_pthread_found=yes])
+AC_MSG_RESULT([$vkd3d_pthread_found])
+
+AS_IF([test "x$vkd3d_pthread_found" = "xno"], [PTHREAD_LIBS=""])
+
+LIBS="$vkd3d_libs_saved"])
 ])
-- 
GitLab