--- config/cf/FreeBSD.cf.orig	Fri Nov  1 14:06:38 2002
+++ config/cf/FreeBSD.cf	Fri Nov  1 14:15:57 2002
@@ -43,11 +43,15 @@
 #define GccUsesGas		YES
 #define UseGas			YES
 #define GnuCpp			YES
+#define HasPoll			YES
 #define HasNdbm			YES
 #define HasPutenv		YES
 #define HasSnprintf		YES
 #define HasBSD44Sockets 	YES
 #define HasDlopen		YES
+#if ((OSRelVersion >= 410002) && OSRelVersion < 500000) || (OSRelVersion >= 500012)
+#define HasSetProcTitle		YES
+#endif
 #ifndef HasLibCrypt
 # define HasLibCrypt		YES
 #endif
@@ -74,18 +78,14 @@
  * Multi-thread safe libs 
  */	
 /* 2.2.7 and later has libc_r (POSIX threads) */
-#if OSMajorVersion == 2 && OSMinorVersion == 2 && OSTeenyVersion >= 7 || \
-    OSMajorVersion >= 3
+#if (OSMajorVersion == 2 && OSMinorVersion == 2 && OSTeenyVersion >= 7) || \
+    (OSMajorVersion >= 3) && !defined(Sparc64Architecture)
 # ifndef HasLibPthread
 #  define HasLibPthread		NO
 # endif
 # define HasPosixThreads	YES
 # define ThreadedX		YES
 /*
- * math.h uses _REENTRANT and stdio.h uses _THREAD_SAFE, so define both.
- */
-# define SystemMTDefines	-D_REENTRANT -D_THREAD_SAFE
-/*
  * FreeBSD has tread-safe api but no getpwnam_r yet.
  */
 # define HasThreadSafeAPI	YES
@@ -93,10 +93,19 @@
 # if HasLibPthread
 #  define ThreadsLibraries	-lpthread
 # else
-#  define BuildThreadStubLibrary  YES 
-#  define NeedUIThrStubs          YES 
-#  define ThreadsCompileFlags	-pthread
-#  define ThreadsLibraries 	-pthread
+#  if OSRelVersion >= 500043
+#   define BuildThreadStubLibrary  NO
+#   define NeedUIThrStubs          NO
+#  else
+#   define BuildThreadStubLibrary  YES
+#   define NeedUIThrStubs          YES
+#  endif
+#  define SystemMTDefines	-D_REENTRANT -D_THREAD_SAFE
+#  if (OSRelVersion >= 500016)
+#   define ThreadsLibraries	-lc_r
+#  else
+#   define ThreadsLibraries	-pthread
+#  endif
 #  define SharedX11Reqs		$(LDPRELIB) $(XTHRSTUBLIB)
 #  define SharedXtReqs		$(LDPRELIB) $(XLIBONLY) $(SMLIB) $(ICELIB) $(XTHRSTUBLIB)
 # endif
@@ -149,11 +158,11 @@
  *    ld: warning: libXThrStub.so.6, needed by libX11.so, not found
  */
 #if BuildThreadStubLibrary && !UseInstalled
-# define CcCmd			$(CLIENTENVSETUP) cc
-# define CplusplusCmd		$(CLIENTENVSETUP) c++
+# define CcCmd			$(CLIENTENVSETUP) FreeBSDCC
+# define CplusplusCmd		$(CLIENTENVSETUP) FreeBSDCXX
 #else
-# define CcCmd			cc
-# define CplusplusCmd		c++
+# define CcCmd			FreeBSDCC
+# define CplusplusCmd		FreeBSDCXX
 #endif
 
 #define CppCmd			/usr/bin/cpp
@@ -224,6 +233,20 @@
 #endif
 #endif
 
+/* Katmai (SSE) and 3DNow will be autodetected, so binutils is the only 
+ * requirement for enabling this.  By 4.2 they were all supported.
+ */
+#ifdef i386Architecture &&  \
+	(OSMajorVersion >= 5) || (OSMajorVersion == 4 && OSMinorVersion >= 2))
+# define HasMMXSupport		YES
+# define Has3DNowSupport	YES
+# define HasKatmaiSupport	YES
+#else
+# define HasMMXSupport		NO
+# define Has3DNowSupport	NO
+# define HasKatmaiSupport	NO
+#endif
+
 /* 
  * This doesn't work the way it does on every other system. On FreeBSD it's
  * only a "hint, not a demand", whatever that means. Note that this is not 
@@ -428,6 +451,9 @@
 #ifdef AlphaArchitecture
 #define ServerExtraDefines GccGasOption XFree86ServerDefines -D_XSERVER64
 #endif
+#ifdef Sparc64Architecture
+#define ServerExtraDefines GccGasOption XFree86ServerDefines -D_XSERVER64
+#endif
 
 #define StandardDefines	-DCSRG_BASED
 
@@ -449,18 +475,8 @@
 #define XawI18nDefines		-DUSE_XWCHAR_STRING -DUSE_XMBTOWC
 #endif
 
-/* The GCC strength-reduce bug is fixed for FreeBSD 2.1.5 and later */
-#ifndef DefaultGcc2i386Opt
-#if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion > 1) || (OSMajorVersion == 2 && OSMinorVersion == 1 && OSTeenyVersion >= 5)
-#define DefaultGcc2i386Opt -O2
-#endif
-#endif
-
-#ifdef i386Architecture
-# define OptimizedCDebugFlags DefaultGcc2i386Opt
-#else
-# define OptimizedCDebugFlags -O
-#endif
+#define DefaultGcc2i386Opt
+#define OptimizedCDebugFlags FreeBSDCFLAGS
 
 #ifndef PreIncDir
 # define PreIncDir	/usr/include
@@ -513,6 +529,10 @@
  
 #ifndef PamLibraries
 #define PamLibraries		-lpam DlLibrary
+#endif
+
+#ifndef SharedLibXdmGreet
+# define SharedLibXdmGreet		NO
 #endif
 
 /*
