diff --git a/configure.in b/configure.in
index a160f84a165ca0691b2fb02447974e4568167b0e..3c92d072b8dc70d9a7fda362b8dcdc2c472f12fe 100644
--- a/configure.in
+++ b/configure.in
@@ -383,15 +383,16 @@ AC_MSG_CHECKING("if we should use 'skip-locking' as default for $target_os")
 if expr "$target_os" : "[[Ll]]inux.*" > /dev/null
 then
   MYSQLD_DEFAULT_SWITCHES="--skip-locking"
-  IS_LINUX="true"
-  AC_MSG_RESULT("yes");
+  TARGET_LINUX="true"
+  AC_MSG_RESULT("yes")
+  AC_DEFINE([TARGET_OS_LINUX], [1], [Whether we build for Linux])
 else
   MYSQLD_DEFAULT_SWITCHES=""
-  IS_LINUX="false"
-  AC_MSG_RESULT("no");
+  TARGET_LINUX="false"
+  AC_MSG_RESULT("no")
 fi
 AC_SUBST(MYSQLD_DEFAULT_SWITCHES)
-AC_SUBST(IS_LINUX)
+AC_SUBST(TARGET_LINUX)
 
 dnl Find paths to some shell programs
 AC_PATH_PROG(LN, ln, ln)
@@ -580,7 +581,7 @@ AC_SUBST(NOINST_LDFLAGS)
 # (this is true on the MySQL build machines to avoid NSS problems)
 #
 
-if test "$IS_LINUX" = "true" -a "$static_nss" = ""
+if test "$TARGET_LINUX" = "true" -a "$static_nss" = ""
 then
   tmp=`nm /usr/lib/libc.a  | grep _nss_files_getaliasent_r`
   if test -n "$tmp"
@@ -747,7 +748,7 @@ AC_CHECK_FUNC(sem_init, , AC_CHECK_LIB(posix4, sem_init))
 MYSQL_CHECK_ZLIB_WITH_COMPRESS
 
 # For large pages support
-if test "$IS_LINUX" = "true"
+if test "$TARGET_LINUX" = "true"
 then
   # For SHM_HUGETLB on Linux
   AC_CHECK_DECLS(SHM_HUGETLB, 
@@ -805,7 +806,7 @@ struct request_info *req;
 ])
 AC_SUBST(WRAPLIBS)
 
-if test "$IS_LINUX" = "true"; then
+if test "$TARGET_LINUX" = "true"; then
   AC_MSG_CHECKING([for atomic operations])
 
   atom_ops=
@@ -849,7 +850,7 @@ int main()
     [ USE_PSTACK=no ])
   pstack_libs=
   pstack_dirs=
-  if test "$USE_PSTACK" = yes -a "$IS_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386"
+  if test "$USE_PSTACK" = yes -a "$TARGET_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386"
   then
     have_libiberty= have_libbfd=
     my_save_LIBS="$LIBS"
@@ -1231,61 +1232,93 @@ esac
 # We have to check libc last because else it fails on Solaris 2.6
 
 with_posix_threads="no"
-# Hack for DEC-UNIX (OSF1)
+# Search thread lib on Linux
 if test "$with_named_thread" = "no"
 then
-  # Look for LinuxThreads.
-  AC_MSG_CHECKING("LinuxThreads")
-    res=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l`
-    if test "$res" -gt 0
+    AC_MSG_CHECKING("Linux threads")
+    if test "$TARGET_LINUX" = "true"
     then
-      AC_MSG_RESULT("Found")
-      AC_DEFINE([HAVE_LINUXTHREADS], [1],
-                [Whether we are using Xavier Leroy's LinuxThreads])
-      # Linux 2.0 sanity check
-      AC_TRY_COMPILE([#include <sched.h>], [int a = sched_get_priority_min(1);], ,
-      AC_MSG_ERROR([Syntax error in sched.h. Change _P to __P in the /usr/include/sched.h file. See the Installation chapter in the Reference Manual]))
-      # RedHat 5.0 does not work with dynamic linking of this. -static also
-      # gives a speed increase in linux so it does not hurt on other systems.
-      with_named_thread="-lpthread"
-    else
-      AC_MSG_RESULT("Not found")
-      # If this is a linux machine we should barf
-      if test "$IS_LINUX" = "true"
-      then
-	AC_MSG_ERROR([This is a linux system and Linuxthreads was not
-found. On linux Linuxthreads should be used.  Please install Linuxthreads
-(or a new glibc) and try again.  See the Installation chapter in the
-Reference Manual for more information.])
-      else
-	AC_MSG_CHECKING("DEC threads")
-        if test -f /usr/shlib/libpthread.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a
-	then
-	  with_named_thread="-lpthread -lmach -lexc"
-	  CFLAGS="$CFLAGS -D_REENTRANT"
-	  CXXFLAGS="$CXXFLAGS -D_REENTRANT"
-	  AC_DEFINE(HAVE_DEC_THREADS, [1],
-                    [Whether we are using DEC threads])
-	  AC_MSG_RESULT("yes")
-	else
-	  AC_MSG_RESULT("no")
-	  AC_MSG_CHECKING("DEC 3.2 threads")
-          if test -f /usr/shlib/libpthreads.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a
-	  then
-	    with_named_thread="-lpthreads -lmach -lc_r"
-	    AC_DEFINE(HAVE_DEC_THREADS, [1])
-            AC_DEFINE([HAVE_DEC_3_2_THREADS], [1],
-                      [Whether we are using OSF1 DEC threads on 3.2])
-            with_osf32_threads="yes"
-            MYSQLD_DEFAULT_SWITCHES="--skip-thread-priority"
-	    AC_MSG_RESULT("yes")
-	  else
-	    AC_MSG_RESULT("no")
+        AC_MSG_RESULT("starting")
+        # use getconf to check glibc contents
+        AC_MSG_CHECKING("getconf GNU_LIBPTHREAD_VERSION")
+        case `getconf GNU_LIBPTHREAD_VERSION | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` in
+        NPTL* )
+                AC_MSG_RESULT("NPTL")
+                AC_DEFINE([HAVE_NPTL], [1], [NPTL threads implementation])
+                with_named_thread="-lpthread"
+                ;;
+        LINUXTHREADS* )
+                AC_MSG_RESULT("Linuxthreads")
+                AC_DEFINE([HAVE_LINUXTHREADS], [1], 
+                      [Whether we are using Xavier Leroy's LinuxThreads])
+                with_named_thread="-lpthread"
+                ;;
+        * )
+                AC_MSG_RESULT("unknown")
+                ;;
+        esac
+        if test "$with_named_thread" = "no"
+        then
+          # old method, check headers
+          # Look for LinuxThreads.
+          AC_MSG_CHECKING("LinuxThreads in header file comment")
+          res=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l`
+          if test "$res" -gt 0
+          then
+            AC_MSG_RESULT("Found")
+            AC_DEFINE([HAVE_LINUXTHREADS], [1],
+                  [Whether we are using Xavier Leroy's LinuxThreads])
+            # Linux 2.0 sanity check
+            AC_TRY_COMPILE([#include <sched.h>], [int a = sched_get_priority_min(1);], ,
+                  AC_MSG_ERROR([Syntax error in sched.h. Change _P to __P in the /usr/include/sched.h file. See the Installation chapter in the Reference Manual]))
+            # RedHat 5.0 does not work with dynamic linking of this. -static also
+            # gives a speed increase in linux so it does not hurt on other systems.
+            with_named_thread="-lpthread"
+          else
+            AC_MSG_RESULT("Not found")
+            # If this is a linux machine we should barf
+            AC_MSG_ERROR([This is a Linux system without a working getconf, 
+and Linuxthreads was not found. Please install it (or a new glibc) and try again.  
+See the Installation chapter in the Reference Manual for more information.])
           fi
-	fi
-     fi
-   fi
-fi
+        else
+            AC_MSG_RESULT("no need to check headers")
+        fi
+        
+        AC_MSG_CHECKING("for pthread_create in -lpthread");
+        ac_save_LIBS="$LIBS"
+        LIBS="$LIBS -lpthread"
+        AC_TRY_LINK( [#include <pthread.h>],
+              [ (void) pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0); ],
+              AC_MSG_RESULT("yes"),
+              [ AC_MSG_RESULT("no")
+                AC_MSG_ERROR([
+This is a Linux system claiming to support threads, either Linuxthreads or NPTL, but linking a test program failed.  
+Please install one of these (or a new glibc) and try again.  
+See the Installation chapter in the Reference Manual for more information.]) ]
+              )
+        LIBS="$ac_save_LIBS"
+    else
+        AC_MSG_RESULT("no")
+    fi  # "$TARGET_LINUX" 
+fi  # "$with_named_thread" = "no" -a "$with_mit_threads" = "no"
+
+
+# Hack for DEC-UNIX (OSF1 -> Tru64)
+if test "$with_named_thread" = "no" -a "$with_mit_threads" = "no"
+then
+    AC_MSG_CHECKING("DEC threads post OSF/1 3.2")
+    if test -f /usr/shlib/libpthread.so -a -f /usr/lib/libmach.a -a -f /usr/ccs/lib/cmplrs/cc/libexc.a
+    then
+      with_named_thread="-lpthread -lmach -lexc"
+      CFLAGS="$CFLAGS -D_REENTRANT"
+      CXXFLAGS="$CXXFLAGS -D_REENTRANT"
+      AC_DEFINE(HAVE_DEC_THREADS, [1], [Whether we are using DEC threads])
+      AC_MSG_RESULT("yes")
+    else
+      AC_MSG_RESULT("no")
+    fi  # DEC threads
+fi  # "$with_named_thread" = "no" -a "$with_mit_threads" = "no"
 
 
 dnl This is needed because -lsocket has to come after the thread
@@ -1696,7 +1729,7 @@ fi
 AC_SUBST(COMPILATION_COMMENT)
 
 AC_MSG_CHECKING("need of special linking flags")
-if test "$IS_LINUX" = "true" -a "$ac_cv_prog_gcc" = "yes" -a "$all_is_static" != "yes"
+if test "$TARGET_LINUX" = "true" -a "$ac_cv_prog_gcc" = "yes" -a "$all_is_static" != "yes"
 then
   LDFLAGS="$LDFLAGS -rdynamic"
   AC_MSG_RESULT("-rdynamic")
@@ -1914,7 +1947,7 @@ CFLAGS="$ORG_CFLAGS"
 # Sanity check: We chould not have any fseeko symbol unless
 # large_file_support=yes
 AC_CHECK_FUNC(fseeko,
-[if test "$large_file_support" = no -a "$IS_LINUX" = "true";
+[if test "$large_file_support" = no -a "$TARGET_LINUX" = "true";
 then
   AC_MSG_ERROR("Found fseeko symbol but large_file_support is not enabled!");
 fi]
diff --git a/include/my_global.h b/include/my_global.h
index 7ec0437786447645d3ffbd80c3838cbf3622bada..6cd1277d35899d9f31d3f1d44368e67f72779ae8 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -97,7 +97,7 @@
 
 
 /* Fix problem with S_ISLNK() on Linux */
-#if defined(HAVE_LINUXTHREADS)
+#if defined(TARGET_OS_LINUX)
 #undef  _GNU_SOURCE
 #define _GNU_SOURCE 1
 #endif
@@ -246,13 +246,13 @@ C_MODE_START int __cxa_pure_virtual() {\
 #endif
 
 /* In Linux-alpha we have atomic.h if we are using gcc */
-#if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__alpha__) && (__GNUC__ > 2 || ( __GNUC__ == 2 &&  __GNUC_MINOR__ >= 95)) && !defined(HAVE_ATOMIC_ADD)
+#if defined(TARGET_OS_LINUX) && defined(__GNUC__) && defined(__alpha__) && (__GNUC__ > 2 || ( __GNUC__ == 2 &&  __GNUC_MINOR__ >= 95)) && !defined(HAVE_ATOMIC_ADD)
 #define HAVE_ATOMIC_ADD
 #define HAVE_ATOMIC_SUB
 #endif
 
 /* In Linux-ia64 including atomic.h will give us an error */
-#if (defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && (defined(__ia64__)||defined(__powerpc64__))) || !defined(THREAD)
+#if (defined(TARGET_OS_LINUX) && defined(__GNUC__) && (defined(__ia64__)||defined(__powerpc64__))) || !defined(THREAD)
 #undef HAVE_ATOMIC_ADD
 #undef HAVE_ATOMIC_SUB
 #endif
@@ -799,7 +799,7 @@ typedef unsigned long	uint32; /* Short for unsigned integer >= 32 bits */
 #error "Neither int or long is of 4 bytes width"
 #endif
 
-#if !defined(HAVE_ULONG) && !defined(HAVE_LINUXTHREADS) && !defined(__USE_MISC)
+#if !defined(HAVE_ULONG) && !defined(TARGET_OS_LINUX) && !defined(__USE_MISC)
 typedef unsigned long	ulong;		  /* Short for unsigned long */
 #endif
 #ifndef longlong_defined
diff --git a/myisam/Makefile.am b/myisam/Makefile.am
index e77e46cb7a315b19fc26b09d5a52cd1d7634fe1c..c61647b25f7b501513747cf3fc9cadb084cfdbfb 100644
--- a/myisam/Makefile.am
+++ b/myisam/Makefile.am
@@ -88,7 +88,7 @@ SUFFIXES = .sh
 	  -e 's!@''FIND_PROC''@!@FIND_PROC@!' \
 	  -e 's!@''MYSQLD_DEFAULT_SWITCHES''@!@MYSQLD_DEFAULT_SWITCHES@!' \
 	  -e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \
-	  -e 's!@''IS_LINUX''@!@IS_LINUX@!' \
+	  -e 's!@''TARGET_LINUX''@!@TARGET_LINUX@!' \
 	  -e "s!@""CONF_COMMAND""@!@CONF_COMMAND@!" \
 	  -e 's!@''MYSQLD_USER''@!@MYSQLD_USER@!' \
 	  -e 's!@''sysconfdir''@!@sysconfdir@!' \
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index bbcfaa8bba69ef76877ae8a093266cf8ed6ce8fb..2facb4e18cf8d703a068d53eacc6653a5b76409a 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -17,7 +17,7 @@
 /* This makes a wrapper for mutex handling to make it easier to debug mutex */
 
 #include <my_global.h>
-#if defined(HAVE_LINUXTHREADS) && !defined (__USE_UNIX98)
+#if defined(TARGET_OS_LINUX) && !defined (__USE_UNIX98)
 #define __USE_UNIX98			/* To get rw locks under Linux */
 #endif
 #if defined(THREAD) && defined(SAFE_MUTEX)
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 82a4fc2ca92cfe8cbc5946bdfc26e9c8da79c3b2..b2fef9acadf53bd17557fbb5a0b903de9e2cf976 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -135,7 +135,7 @@ SUFFIXES = .sh
 	  -e 's!@''MYSQLD_DEFAULT_SWITCHES''@!@MYSQLD_DEFAULT_SWITCHES@!' \
 	  -e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \
 	  -e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \
-	  -e 's!@''IS_LINUX''@!@IS_LINUX@!' \
+	  -e 's!@''TARGET_LINUX''@!@TARGET_LINUX@!' \
 	  -e "s!@""CONF_COMMAND""@!@CONF_COMMAND@!" \
 	  -e 's!@''MYSQLD_USER''@!@MYSQLD_USER@!' \
 	  -e 's!@''STATIC_NSS_FLAGS''@!@STATIC_NSS_FLAGS@!' \
diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh
index 10983d2850fb3abc1aa40d4a04b7daa82f6c0ac5..9ec573737bd46c0d3060a24e61b981769c632586 100644
--- a/scripts/mysqld_safe.sh
+++ b/scripts/mysqld_safe.sh
@@ -368,7 +368,7 @@ do
     break
   fi
 
-  if @IS_LINUX@ && test $KILL_MYSQLD -eq 1
+  if @TARGET_LINUX@ && test $KILL_MYSQLD -eq 1
   then
     # Test if one process was hanging.
     # This is only a fix for Linux (running as base 3 mysqld processes)
diff --git a/sql/stacktrace.c b/sql/stacktrace.c
index 322d647e74178dfe29e3288a7c28f08b8992a538..838f547dc029f11ef82bc0f067d41058fde61ba4 100644
--- a/sql/stacktrace.c
+++ b/sql/stacktrace.c
@@ -43,7 +43,7 @@ void safe_print_str(const char* name, const char* val, int max_len)
   fputc('\n', stderr);
 }
 
-#ifdef HAVE_LINUXTHREADS
+#ifdef TARGET_OS_LINUX
 #define SIGRETURN_FRAME_COUNT  2
 
 #if defined(__alpha__) && defined(__GNUC__)
@@ -201,7 +201,7 @@ end:
 stack trace is much more helpful in diagnosing the problem, so please do \n\
 resolve it\n");
 }
-#endif /* HAVE_LINUXTHREADS */
+#endif /* TARGET_OS_LINUX */
 #endif /* HAVE_STACKTRACE */
 
 /* Produce a core for the thread */
diff --git a/sql/stacktrace.h b/sql/stacktrace.h
index 980e1ea07eb156f5cd9fde0d92a2da98b900002a..d5d1e05ef0edb3db45e9fa1876ef6983c79046de 100644
--- a/sql/stacktrace.h
+++ b/sql/stacktrace.h
@@ -18,7 +18,7 @@
 extern "C" {
 #endif
 
-#ifdef HAVE_LINUXTHREADS
+#ifdef TARGET_OS_LINUX
 #if defined(HAVE_STACKTRACE) || (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__)))
 #undef HAVE_STACKTRACE
 #define HAVE_STACKTRACE
@@ -30,7 +30,7 @@ extern char* heap_start;
 void print_stacktrace(gptr stack_bottom, ulong thread_stack);
 void safe_print_str(const char* name, const char* val, int max_len);
 #endif /* (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) */
-#endif /* HAVE_LINUXTHREADS */
+#endif /* TARGET_OS_LINUX */
 
 /* Define empty prototypes for functions that are not implemented */
 #ifndef HAVE_STACKTRACE
diff --git a/support-files/Makefile.am b/support-files/Makefile.am
index 0a6077f0efc9afa124bfdb4d594ba3f0a8da4b7c..5f5a10fc1fc68c6b00d1dc59d99f2c905e4234e6 100644
--- a/support-files/Makefile.am
+++ b/support-files/Makefile.am
@@ -90,7 +90,7 @@ SUFFIXES = .sh
 	  -e 's!@''FIND_PROC''@!@FIND_PROC@!' \
 	  -e 's!@''MYSQLD_DEFAULT_SWITCHES''@!@MYSQLD_DEFAULT_SWITCHES@!' \
 	  -e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \
-	  -e 's!@''IS_LINUX''@!@IS_LINUX@!' \
+	  -e 's!@''TARGET_LINUX''@!@TARGET_LINUX@!' \
 	  -e "s!@""CONF_COMMAND""@!@CONF_COMMAND@!" \
 	  -e 's!@''MYSQLD_USER''@!@MYSQLD_USER@!' \
 	  -e 's!@''sysconfdir''@!@sysconfdir@!' \
diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c
index 1ae8f908dc2033207c77bceff197d9302804f99d..4a5c08be50a19e376a17a2ec664024d052750e84 100644
--- a/tools/mysqlmanager.c
+++ b/tools/mysqlmanager.c
@@ -101,7 +101,7 @@ static CHARSET_INFO *cs= &my_charset_latin1;
   set by the user
 */
 
-#if defined(__i386__) && defined(HAVE_LINUXTHREADS)
+#if defined(__i386__) && defined(TARGET_OS_LINUX)
 #define DO_STACKTRACE 1
 #endif