--- xc/config/cf/FreeBSD.cf.orig	2003-01-15 11:52:12.000000000 +0900
+++ xc/config/cf/FreeBSD.cf	2007-09-09 22:04:24.000000000 +0900
@@ -162,11 +162,11 @@
  *    ld: warning: libXThrStub.so.6, needed by libX11.so, not found
  */
 #if BuildThreadStubLibrary && (!defined(UseInstalledX11) || !UseInstalledX11)
-# define CcCmd			$(CLIENTENVSETUP) cc
-# define CplusplusCmd		$(CLIENTENVSETUP) c++
+# define CcCmd			$(CLIENTENVSETUP) %%CC%%
+# define CplusplusCmd		$(CLIENTENVSETUP) %%CXX%%
 #else
-# define CcCmd			cc
-# define CplusplusCmd		c++
+# define CcCmd			%%CC%%
+# define CplusplusCmd		%%CXX%%
 #endif
 
 #define CppCmd			/usr/bin/cpp
@@ -223,7 +223,9 @@
  */
 #ifndef BuildXF86DRI
 #if OSMajorVersion >= 5 || (OSMajorVersion == 4 && OSMinorVersion >= 1)
+#ifndef x86_64Architecture
 #define BuildXF86DRI		YES
+#endif
 #endif
 #endif
 
@@ -231,7 +233,7 @@
  * 4.1/i386 and 5.0/i386 have the AGP driver.
  */
 #ifndef HasAgpGart
-#if defined(i386Architecture) && \
+#if (defined(i386Architecture) || defined(x86_64Architecture)) && \
 	(OSMajorVersion >= 5 || (OSMajorVersion == 4 && OSMinorVersion >= 1))
 #define HasAgpGart		YES
 #endif
@@ -241,7 +241,7 @@
  * SSE and 3DNow will be autodetected, so binutils is the only 
  * requirement for enabling this.  By 4.2 they were all supported.
  */
-#if defined(i386Architecture) && \
+#if (defined(i386Architecture) || defined(x86_64Architecture)) && \
 	(OSMajorVersion >= 5 || (OSMajorVersion == 4 && OSMinorVersion >= 2))
 # define HasX86Support          YES
 # define HasMMXSupport		YES
@@ -455,6 +455,10 @@
 #ifdef i386Architecture
 #define ServerExtraDefines GccGasOption XFree86ServerDefines
 #endif
+#if defined(x86_64Architecture) || defined(ia64Architecture)
+# define ServerOSDefines         XFree86ServerOSDefines -DDDXTIME
+# define ServerExtraDefines      GccGasOption XFree86ServerDefines -D_XSERVER64
+#endif /* x86_64Architecture */
 #ifdef AlphaArchitecture
 #define ServerExtraDefines GccGasOption XFree86ServerDefines -D_XSERVER64
 #endif
@@ -492,7 +496,7 @@
 #ifdef i386Architecture
 # define OptimizedCDebugFlags DefaultGcc2i386Opt
 #else
-# define OptimizedCDebugFlags -O
+# define OptimizedCDebugFlags %%CFLAGS%% 
 #endif
 
 #ifndef PreIncDir