$NetBSD$

--- configure.in.orig	2002-09-02 21:12:52.000000000 +0000
+++ configure.in
@@ -43,6 +43,36 @@ AM_PATH_GLIB(1.2.2,,AC_MSG_ERROR([*** GL
 AM_PATH_GTK(1.2.2,,AC_MSG_ERROR([*** Gtk+ >= 1.2.2 not found. You either don't have Gtk+ at all or your Gtk+ is too old. Latest Gtk+ can be found from Gtk+ homepages (http://www.gtk.org/)]), gthread)
 
 
+PTHREAD_LIBS=error
+AC_MSG_CHECKING(for old style FreeBSD -pthread flag)
+AC_EGREP_CPP(yes,
+[#if (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version <= 500001) || defined(__OpenBSD__)
+	yes
+	#endif
+	], AC_MSG_RESULT(yes)
+	CFLAGS="$CFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
+	AC_MSG_RESULT(no))
+if test "x$PTHREAD_LIBS" = xerror; then
+	AC_CHECK_LIB(pthread, pthread_attr_init,
+		PTHREAD_LIBS="-lpthread")
+fi
+if test "x$PTHREAD_LIBS" = xerror; then
+	AC_CHECK_LIB(pthreads, pthread_attr_init,
+		PTHREAD_LIBS="-lpthreads")
+fi
+if test "x$PTHREAD_LIBS" = xerror; then
+	AC_CHECK_LIB(c_r, pthread_attr_init,
+		PTHREAD_LIBS="-lc_r")
+fi
+if test "x$PTHREAD_LIBS" = xerror; then
+	AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
+fi
+if test "x$PTHREAD_LIBS" = xerror; then
+	AC_MSG_ERROR(*** Unable to locate working posix thread library ***)
+fi
+AC_SUBST(PTHREAD_LIBS)
+
+
 dnl ***
 dnl *** Song position patch check
 dnl ***
