configure doesn't generate proper pthread support

--- motion-4.0.1/configure.ac
+++ ./configure.ac
@@ -188,7 +188,8 @@
  pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
  [PTHREAD_LIB=yes])

-if test x$PTHREAD_LIB != xyes; then
+# this test should fail but it doesn't on alpine
+if test x$PTHREAD_LIB = xyes; then

 	if test "${FreeBSD}" != ""; then
 		TEMP_LIBS="$TEMP_LIBS -pthread"
@@ -213,7 +214,7 @@
     CFLAGS="$TEMP_CFLAGS"
     LIBS="$TEMP_LIBS"
     AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM([[#include <pthread.h>]], [[  pthread_setname_np(pthread_self(), "name")]])],
+    [AC_LANG_PROGRAM([[#include <pthread.h>]], [[  pthread_getname_np(pthread_self(), "name", 0)]])],
     [AC_DEFINE([[HAVE_PTHREAD_SETNAME_NP]], [[1]], [Define if you have pthread_setname_np function.])
      AC_MSG_RESULT([[yes]])],
     [AC_MSG_RESULT([[no]])] )
