$NetBSD: patch-ac,v 1.7 2009/02/21 16:44:29 wiz Exp $

_POSIX_THREAD_SAFE_FUNCTIONS is not used on NetBSD.  Instead,
let's use _REENTRANT.

--- configure.orig	2009-02-17 15:10:53.000000000 +0000
+++ configure
@@ -932,6 +932,8 @@ XKB_FALSE
 XKBPROTO_CFLAGS
 XKBPROTO_LIBS
 XKBPROTO_REQUIRES
+CROSS_COMPILING_TRUE
+CROSS_COMPILING_FALSE
 LINT
 LINT_FLAGS
 LINT_TRUE
@@ -23828,43 +23830,38 @@ _ACEOF
 	;;
 esac
 
-{ echo "$as_me:$LINENO: checking for pthread_self in -lc" >&5
-echo $ECHO_N "checking for pthread_self in -lc... $ECHO_C" >&6; }
-if test "${ac_cv_lib_c_pthread_self+set}" = set; then
+{ echo "$as_me:$LINENO: checking whether pthread_self is declared" >&5
+echo $ECHO_N "checking whether pthread_self is declared... $ECHO_C" >&6; }
+if test "${ac_cv_have_decl_pthread_self+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lc  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
+#include <pthread.h>
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char pthread_self ();
 int
 main ()
 {
-return pthread_self ();
+#ifndef pthread_self
+  (void) pthread_self;
+#endif
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -23873,28 +23870,35 @@ eval "echo \"\$as_me:$LINENO: $ac_try_ec
   (exit $ac_status); } && {
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_c_pthread_self=yes
+       } && test -s conftest.$ac_objext; then
+  ac_cv_have_decl_pthread_self=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_lib_c_pthread_self=no
+	ac_cv_have_decl_pthread_self=no
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_c_pthread_self" >&5
-echo "${ECHO_T}$ac_cv_lib_c_pthread_self" >&6; }
-if test $ac_cv_lib_c_pthread_self = yes; then
-  thrstubs="no"
+{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_pthread_self" >&5
+echo "${ECHO_T}$ac_cv_have_decl_pthread_self" >&6; }
+if test $ac_cv_have_decl_pthread_self = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_PTHREAD_SELF 1
+_ACEOF
+
+thrstubs="no"
 else
-  thrstubs="yes"
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_PTHREAD_SELF 0
+_ACEOF
+
+thrstubs="yes"
 fi
 
+
  if test x$thrstubs = xyes; then
   THRSTUBS_TRUE=
   THRSTUBS_FALSE='#'
@@ -23909,8 +23913,8 @@ if test x$xthreads = xyes ; then
     linux*|openbsd*|gnu*|k*bsd*-gnu)
         XTHREADLIB=-lpthread ;;
     netbsd*)
-	XTHREAD_CFLAGS="-D_POSIX_THREAD_SAFE_FUNCTIONS"
-	XTHREADLIB="-lpthread" ;;
+	XTHREAD_CFLAGS="-D_REENTRANT"
+	XTHREADLIB="-pthread" ;;
     freebsd*)
         XTHREAD_CFLAGS="-D_THREAD_SAFE"
         XTHREADLIB="-pthread" ;;
@@ -24441,6 +24445,15 @@ else
 fi
 
 
+ if  test $cross_compiling = yes ; then
+  CROSS_COMPILING_TRUE=
+  CROSS_COMPILING_FALSE='#'
+else
+  CROSS_COMPILING_TRUE='#'
+  CROSS_COMPILING_FALSE=
+fi
+
+
 
 
 for ac_header in stdlib.h unistd.h
@@ -25582,6 +25595,13 @@ echo "$as_me: error: conditional \"XKB\"
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${CROSS_COMPILING_TRUE}" && test -z "${CROSS_COMPILING_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"CROSS_COMPILING\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"CROSS_COMPILING\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 if test -z "${LINT_TRUE}" && test -z "${LINT_FALSE}"; then
   { { echo "$as_me:$LINENO: error: conditional \"LINT\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -26412,6 +26432,8 @@ XKB_FALSE!$XKB_FALSE$ac_delim
 XKBPROTO_CFLAGS!$XKBPROTO_CFLAGS$ac_delim
 XKBPROTO_LIBS!$XKBPROTO_LIBS$ac_delim
 XKBPROTO_REQUIRES!$XKBPROTO_REQUIRES$ac_delim
+CROSS_COMPILING_TRUE!$CROSS_COMPILING_TRUE$ac_delim
+CROSS_COMPILING_FALSE!$CROSS_COMPILING_FALSE$ac_delim
 LINT!$LINT$ac_delim
 LINT_FLAGS!$LINT_FLAGS$ac_delim
 LINT_TRUE!$LINT_TRUE$ac_delim
@@ -26438,7 +26460,7 @@ LIBOBJS!$LIBOBJS$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 90; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 92; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
