diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog
index 278cde24645dda3c104b22868bd24f8cde27e387..1edd6682ae08f8e8a87206167b9b13040c248d33 100644
--- a/libobjc/ChangeLog
+++ b/libobjc/ChangeLog
@@ -1,3 +1,15 @@
+2005-02-28  Andrew Pinski <pinskia@physics.uc.edu>
+
+	PR libobjc/20252
+	* Makefile.in (GTHREAD_FLAGS): Remove.
+	(ALL_CFLAGS): Remove usage of GTHREAD_FLAGS.
+	* thr-objc.c: Include config.h.
+	* configure.ac: Instead of looking at GCC's makefile, figure out if
+	GTHREAD_FLAGS should be defined by looking at the `thread model'
+	of the current gcc.
+	* configure: Regenerate.
+	* config.h.in: Regenerate.
+
 2005-02-28  Paolo Bonzini  <bonzini@gnu.org>
 
 	PR bootstrap/17383
diff --git a/libobjc/Makefile.in b/libobjc/Makefile.in
index 23af1001867fa2ae4e3cb8e97e9a571c7059a976..3c091830ae41305779b0d85c1abda66eefaffd69 100644
--- a/libobjc/Makefile.in
+++ b/libobjc/Makefile.in
@@ -72,9 +72,8 @@ RANLIB = @RANLIB@
 CC = @CC@
 CFLAGS = @CFLAGS@
 WARN_CFLAGS = -W -Wall -Wwrite-strings -Wstrict-prototypes
-GTHREAD_FLAGS=@GTHREAD_FLAGS@
 ALL_CFLAGS = -I. -I$(srcdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(WARN_CFLAGS) \
-	$(GTHREAD_FLAGS) -DIN_GCC -DIN_TARGET_LIBS -fno-strict-aliasing
+	-DIN_GCC -DIN_TARGET_LIBS -fno-strict-aliasing
 
 # Libtool
 # The following strings describe the version of the obj-C library 
diff --git a/libobjc/config.h.in b/libobjc/config.h.in
index 700e0458450dad59b0387186104e37138d726134..51811a576b74b695e7e61e8d415e5807d66c7a6b 100644
--- a/libobjc/config.h.in
+++ b/libobjc/config.h.in
@@ -1,5 +1,8 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* Define if the compiler has a thread header that is non single. */
+#undef HAVE_GTHR_DEFAULT
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
diff --git a/libobjc/configure b/libobjc/configure
index 71bd0a76397a483b3e0a23ceb5a71151d3c690d1..893645a7c68575f0dd0599496371c9959d826615 100755
--- a/libobjc/configure
+++ b/libobjc/configure
@@ -309,7 +309,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os build_subdir host_subdir target_subdir VERSION OBJC_BOEHM_GC toplevel_srcdir host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical glibcpp_srcdir gcc_version_trigger gcc_version_full gcc_version toolexecdir toolexeclibdir includedirname libext CC ac_ct_CC EXEEXT OBJEXT CFLAGS AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LN_S STRIP ac_ct_STRIP LIBTOOL SET_MAKE CPP CPPFLAGS EGREP GTHREAD_FLAGS LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os build_subdir host_subdir target_subdir VERSION OBJC_BOEHM_GC toplevel_srcdir host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical glibcpp_srcdir gcc_version_trigger gcc_version_full gcc_version toolexecdir toolexeclibdir includedirname libext CC ac_ct_CC EXEEXT OBJEXT CFLAGS AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LN_S STRIP ac_ct_STRIP LIBTOOL SET_MAKE CPP CPPFLAGS EGREP LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -5111,26 +5111,19 @@ done
 # Miscellanea
 # -----------
 
-# Determine CFLAGS for gthread.
-echo "$as_me:$LINENO: checking for gthread cflags" >&5
-echo $ECHO_N "checking for gthread cflags... $ECHO_C" >&6
-if test "${objc_cv_gthread_flags+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  # we know we are compiled as a target library, so the toplevel build directory
-# is ../..
-if test -f ../../$host_subdir/gcc/Makefile
-then
-  objc_cv_gthread_flags=`grep \^GTHREAD_FLAGS ../../$host_subdir/gcc/Makefile | awk -F= '{ print $2 }'`
-else
-  { { echo "$as_me:$LINENO: error: not found" >&5
-echo "$as_me: error: not found" >&2;}
-   { (exit 1); exit 1; }; }
-fi
+echo "$as_me:$LINENO: checking for thread model used by GCC" >&5
+echo $ECHO_N "checking for thread model used by GCC... $ECHO_C" >&6
+target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
+echo "$as_me:$LINENO: result: $target_thread_file" >&5
+echo "${ECHO_T}$target_thread_file" >&6
+
+if test $target_thread_file != single; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_GTHR_DEFAULT 1
+_ACEOF
+
 fi
-echo "$as_me:$LINENO: result: $objc_cv_gthread_flags" >&5
-echo "${ECHO_T}$objc_cv_gthread_flags" >&6
-GTHREAD_FLAGS=$objc_cv_gthread_flags
 
 
 echo "$as_me:$LINENO: checking for exception model to use" >&5
@@ -5147,7 +5140,7 @@ if test "${enable_sjlj_exceptions+set}" = set; then
   :
 else
   cat > conftest.$ac_ext << EOF
-#line 5150 "configure"
+#line 5143 "configure"
 @interface Frob
 @end
 @implementation Frob
@@ -5903,7 +5896,6 @@ s,@SET_MAKE@,$SET_MAKE,;t t
 s,@CPP@,$CPP,;t t
 s,@CPPFLAGS@,$CPPFLAGS,;t t
 s,@EGREP@,$EGREP,;t t
-s,@GTHREAD_FLAGS@,$GTHREAD_FLAGS,;t t
 s,@LIBOBJS@,$LIBOBJS,;t t
 s,@LTLIBOBJS@,$LTLIBOBJS,;t t
 CEOF
diff --git a/libobjc/configure.ac b/libobjc/configure.ac
index 5e56fb7b47217340be0e6e2ce71366ee59aa0ca7..8c554b50563fbffecf4d47f7a3ca6f9e46890086 100644
--- a/libobjc/configure.ac
+++ b/libobjc/configure.ac
@@ -218,18 +218,15 @@ AC_CHECK_HEADERS(sched.h)
 # Miscellanea
 # -----------
 
-# Determine CFLAGS for gthread.
-AC_CACHE_CHECK([for gthread cflags],objc_cv_gthread_flags,
-[# we know we are compiled as a target library, so the toplevel build directory
-# is ../..
-if test -f ../../$host_subdir/gcc/Makefile
-then
-  objc_cv_gthread_flags=`grep \^GTHREAD_FLAGS ../../$host_subdir/gcc/Makefile | awk -F= '{ print $2 }'`
-else
-  AC_MSG_ERROR([not found])
-fi])
-GTHREAD_FLAGS=$objc_cv_gthread_flags
-AC_SUBST(GTHREAD_FLAGS)
+AC_MSG_CHECKING([for thread model used by GCC])
+target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
+AC_MSG_RESULT([$target_thread_file]) 
+
+if test $target_thread_file != single; then
+  AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
+        [Define if the compiler has a thread header that is non single.])
+fi 
+
 
 AC_MSG_CHECKING([for exception model to use])
 AC_LANG_PUSH(C)
diff --git a/libobjc/thr-objc.c b/libobjc/thr-objc.c
index 5afef683a24bdbd4b442ed00902f1731f6215feb..d954f937154619e2483bcab91c2fa167ebc29d94 100644
--- a/libobjc/thr-objc.c
+++ b/libobjc/thr-objc.c
@@ -24,6 +24,7 @@ Boston, MA 02111-1307, USA.  */
    covered by the GNU General Public License.  */
 
 #define _LIBOBJC
+#include "config.h"
 #include "tconfig.h"
 #include "coretypes.h"
 #include "tm.h"