This patch contains a number of 4.8.0 build fixes for FreeBSD 7.0 and
MacOSX 10.5


Index: xc/config/cf/FreeBSD.cf
diff -u xc/config/cf/FreeBSD.cf:3.161 xc/config/cf/FreeBSD.cf:3.162
--- xc/config/cf/FreeBSD.cf:3.161	Wed Jan  3 19:33:41 2007
+++ xc/config/cf/FreeBSD.cf	Fri Dec 26 20:06:45 2008
@@ -1,7 +1,7 @@
-XCOMM platform:  $XFree86: xc/config/cf/FreeBSD.cf,v 3.161 2007/01/04 03:33:41 tsi Exp $
+XCOMM platform:  $XFree86: xc/config/cf/FreeBSD.cf,v 3.162 2008/12/27 04:06:45 dawes Exp $
 
 /*
- * Copyright (c) 1994-2005 by The XFree86 Project, Inc.
+ * Copyright (c) 1994-2008 by The XFree86 Project, Inc.
  * All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining
@@ -145,11 +145,19 @@
 /*
  * Multi-thread safe libs 
  */	
-/* 2.2.7 and later has libc_r (POSIX threads) */
+/*
+ * 2.2.7 and later has libc_r (POSIX threads)
+ * 7.0 no longer has libc_r, and it was deprecated prior to that.  Use
+ * libthr or libpthread instead.  We'll use libpthread.
+ */
 #if OSMajorVersion == 2 && OSMinorVersion == 2 && OSTeenyVersion >= 7 || \
     OSMajorVersion >= 3
 # ifndef HasLibPthread
-#  define HasLibPthread		NO
+#  if OSMajorVersion >= 7
+#   define HasLibPthread	YES
+#  else
+#   define HasLibPthread	NO
+#  endif
 # endif
 # define HasPosixThreads	YES
 # define ThreadedX		YES
@@ -161,6 +169,7 @@
 # define MTSafeAPIDefines	-DXUSE_MTSAFE_API -DXNO_MTSAFE_PWDAPI
 # if HasLibPthread
 #  define ThreadsLibraries	-lpthread
+#  define NeedThreadStubLibrary  YES
 # else
 #  define NeedThreadStubLibrary  YES
 #  if OSRelVersion >= 500043
Index: xc/config/cf/X11.tmpl
diff -u xc/config/cf/X11.tmpl:1.300 xc/config/cf/X11.tmpl:1.302
--- xc/config/cf/X11.tmpl:1.300	Sat Dec  6 09:00:39 2008
+++ xc/config/cf/X11.tmpl	Sun Feb  1 14:02:55 2009
@@ -1,6 +1,6 @@
 XCOMM ----------------------------------------------------------------------
 XCOMM X Window System Build Parameters and Rules
-XCOMM $XFree86: xc/config/cf/X11.tmpl,v 1.300 2008/12/06 17:00:39 tsi Exp $
+XCOMM $XFree86: xc/config/cf/X11.tmpl,v 1.302 2009/02/01 22:02:55 tsi Exp $
 /*
  * Copyright (c) 1994-2005 by The XFree86 Project, Inc.
  * All rights reserved.
@@ -128,6 +128,18 @@
 # endif
 #endif
 
+#ifndef StaticUtils
+#define StaticUtils	NO
+#endif
+#if StaticUtils
+#undef BuildLibraries
+#undef ForceNormalLib
+#undef BuildClients
+#define BuildLibraries		YES
+#define ForceNormalLib		YES
+#define BuildClients		YES
+#endif
+
 #ifndef HasXServer
 #define HasXServer		YES
 #endif
@@ -1937,7 +1949,6 @@
      INSTAPPFLAGS = $(INSTDATFLAGS)	/* XXX - this should go away - XXX */
 
 #if UseInstalledX11
-              RGB = $(BINDIR)/rgb
             FONTC = $(BINDIR)/bdftopcf
       MKFONTSCALE = $(BINDIR)/mkfontscale
         MKFONTDIR = $(BINDIR)/mkfontdir
@@ -1947,7 +1958,6 @@
      UCSMAPPREFIX = $(FONTDIR)/util/map-
        XCURSORGEN = $(BINDIR)/xcursorgen
 #else
-              RGB = $(CLIENTENVSETUP) $(XBUILDBINDIR)/rgb
 # if !CrossCompiling
             FONTC = $(CLIENTENVSETUP) $(PRELOADFONTSETUP) $(XBUILDBINDIR)/bdftopcf
       MKFONTSCALE = $(CLIENTENVSETUP) $(PRELOADFREETYPESETUP) $(XBUILDBINDIR)/mkfontscale
Index: xc/config/cf/darwin.cf
diff -u xc/config/cf/darwin.cf:1.59 xc/config/cf/darwin.cf:1.61
--- xc/config/cf/darwin.cf:1.59	Tue May 22 13:50:12 2007
+++ xc/config/cf/darwin.cf	Sun Feb  1 14:02:55 2009
@@ -1,4 +1,4 @@
-XCOMM platform:  $XFree86: xc/config/cf/darwin.cf,v 1.59 2007/05/22 20:50:12 tsi Exp $
+XCOMM platform:  $XFree86: xc/config/cf/darwin.cf,v 1.61 2009/02/01 22:02:55 tsi Exp $
 
 /* Darwin / Mac OS X configuration by John Carmack <johnc@idsoftware.com> */
 
@@ -152,6 +152,8 @@
 /* we don't need -lm */
 #define MathLibrary             /**/
 
+#define LdPostLib		/**/
+
 #define TermcapLibrary          -lcurses
 #define SetTtyGroup             YES             /* for xterm */
 
@@ -313,7 +315,15 @@
 /* no XFree86-VidMode extension */
 #define BuildXF86VidModeExt     NO
 
+/* No longer works after "security" update 2007-004 */
+#if OSMajorVersion < 9
 #define BuildLibPathVar         DYLD_LIBRARY_PATH
+#else
+#undef  DontUseLibPathVar
+#define DontUseLibPathVar	YES
+#undef  StaticUtils
+#define StaticUtils		YES
+#endif
 
 #ifndef DefaultUserPath
 #define DefaultUserPath         /bin:/sbin:/usr/bin:/usr/sbin:$(BINDIR)
@@ -396,4 +406,3 @@
 
 /* include all the XFree86 rules */
 #include <xfree86.cf>
-
Index: xc/config/cf/darwinLib.tmpl
diff -u xc/config/cf/darwinLib.tmpl:1.21 xc/config/cf/darwinLib.tmpl:1.22
--- xc/config/cf/darwinLib.tmpl:1.21	Fri Feb  4 18:01:39 2005
+++ xc/config/cf/darwinLib.tmpl	Sun Feb  1 12:37:05 2009
@@ -1,12 +1,27 @@
-XCOMM $XFree86: xc/config/cf/darwinLib.tmpl,v 1.21 2005/02/05 02:01:39 dawes Exp $
+XCOMM $XFree86: xc/config/cf/darwinLib.tmpl,v 1.22 2009/02/01 20:37:05 tsi Exp $
 /*
  * Darwin/Mac OS X shared library template
  */
 
+#if defined(DarwinArchitecture) && BuildAppleDRI
+/* Next two must be absolute paths, no symlinks allowed in any component */
+NATIVE_GL = /System/Library/Frameworks/OpenGL.framework
+NATIVE_GLLIB = $(NATIVE_GL)/Versions/A/Libraries/libGL.dylib
+#if OSMajorVersion > 8		/* 9.what? */
+NATIVE_GLDEP = -dylib_file $(NATIVE_GLLIB):$(NATIVE_GLLIB)
+#endif
+#endif
+
+#ifndef FixupGLXLibReferences
+#define FixupGLXLibReferences()						@@\
+GLXLIB = LoaderLibPrefix -lGL $(NATIVE_GLDEP)
+#endif
+
 #ifndef FixupLibReferences
 #define FixupLibReferences()						@@\
 XMULIBONLY = -lXmu							@@\
-XMULIB = $(XMULIBONLY) $(XTOOLLIB) $(XLIB)
+XMULIB = $(XMULIBONLY) $(XTOOLLIB) $(XLIB)				@@\
+FixupGLXLibReferences()
 #endif
 
 #ifndef XawClientLibs
@@ -17,15 +32,15 @@
 #if !defined(SharedX11Reqs)
 #define SharedX11Reqs
 #endif
-#define SharedXlibi18nReqs $(LDPRELIB) $(XLIBONLY)
+#define SharedXlibi18nReqs  $(LDPRELIB) $(XLIBONLY)
 
 #define SharedXfontReqs     $(LDPRELIB) $(FONTSTUBLIB) GzipLibrary $(FREETYPE2LIB) -flat_namespace
 
 #define SharedAppleWMReqs   $(LDPRELIB) $(XLIB)
 #define SharedFontencReqs   $(LDPRELIB) GzipLibrary
 #define SharedGLReqs        $(LDPRELIB) $(XLIB)
-#define SharedGLUReqs       $(LDPRELIB) $(XLIB) $(GLXLIB)
-#define SharedOSMesaReqs    $(LDPRELIB) $(XLIB) $(GLXLIB)
+#define SharedGLUReqs       $(LDPRELIB) $(GLXLIB) $(XLIB)
+#define SharedOSMesaReqs    $(LDPRELIB) $(GLXLIB) $(XLIB)
 #define SharedSMReqs        $(LDPRELIB) $(ICELIB)
 #define SharedXawReqs       $(LDPRELIB) $(XMULIB) $(XTOOLLIB) $(XPMLIB) $(XLIB)
 #define SharedXaw6Reqs      $(LDPRELIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
Index: xc/config/imake/imake.c
diff -u xc/config/imake/imake.c:3.71 xc/config/imake/imake.c:3.72
--- xc/config/imake/imake.c:3.71	Mon Jun 26 17:52:48 2006
+++ xc/config/imake/imake.c	Wed Dec 24 21:46:46 2008
@@ -1156,11 +1156,15 @@
   } else
       strcpy (cmd, "objformat");
 
-  if (osrel >= 300004 &&
-      (objprog = popen(cmd, "r")) != NULL &&
-      fgets(buf, sizeof(buf), objprog) != NULL &&
-      strncmp(buf, "elf", 3) == 0)
+  if (osrel >= 500000) {
     iself = 1;
+  } else {
+    if (osrel >= 300004 &&
+        (objprog = popen(cmd, "r")) != NULL &&
+        fgets(buf, sizeof(buf), objprog) != NULL &&
+        strncmp(buf, "elf", 3) == 0)
+      iself = 1;
+  }
   if (objprog)
     pclose(objprog);
 
@@ -1927,7 +1931,7 @@
 		initialized = TRUE;
 	    fprintf (tmpfd, "# Makefile generated by imake - do not edit!\n");
 	    fprintf (tmpfd, "# %s\n",
-		"$XFree86: xc/config/imake/imake.c,v 3.71 2006/06/27 00:52:48 dawes Exp $");
+		"$XFree86: xc/config/imake/imake.c,v 3.72 2008/12/25 05:46:46 dawes Exp $");
 	}
 
 	for (p1 = pline; p1 < end; p1++) {
Index: xc/lib/GL/GL/Imakefile
diff -u xc/lib/GL/GL/Imakefile:1.32 xc/lib/GL/GL/Imakefile:1.33
--- xc/lib/GL/GL/Imakefile:1.32	Sat Sep 15 17:14:40 2007
+++ xc/lib/GL/GL/Imakefile	Sun Feb  1 12:37:06 2009
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/GL/Imakefile,v 1.32 2007/09/16 00:14:40 tsi Exp $
+XCOMM $XFree86: xc/lib/GL/GL/Imakefile,v 1.33 2009/02/01 20:37:06 tsi Exp $
 /*
  * Copyright (c) 1994-2004 by The XFree86 Project, Inc.
  * All rights reserved.
@@ -249,10 +249,9 @@
     DRIDOBJS = $(APPLEOBJS:%.o=$(GLXLIBSRC)/apple/debugger/%.o)
     DRIPOBJS = $(APPLEOBJS:%.o=$(GLXLIBSRC)/apple/profiled/%.o)
 
-NATIVE_GL = /System/Library/Frameworks/OpenGL.framework
+/* NATIVE_GLLIB is set in darwinLib.tmpl */
 
-OTHERREQUIREDLIBS = \
-	XpluginLibrary $(NATIVE_GL)/Libraries/libGL.dylib -sub_library libGL \
+OTHERREQUIREDLIBS = XpluginLibrary $(NATIVE_GLLIB) -sub_library libGL \
 	-framework ApplicationServices -framework CoreFoundation \
 	-framework OpenGL
 #endif
Index: xc/lib/GL/apple/dri_driver.c
diff -u xc/lib/GL/apple/dri_driver.c:1.6 xc/lib/GL/apple/dri_driver.c:1.7
--- xc/lib/GL/apple/dri_driver.c:1.6	Mon Apr  2 17:21:06 2007
+++ xc/lib/GL/apple/dri_driver.c	Sun Feb  1 12:23:30 2009
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/apple/dri_driver.c,v 1.6 2007/04/03 00:21:06 tsi Exp $ */
+/* $XFree86: xc/lib/GL/apple/dri_driver.c,v 1.7 2009/02/01 20:23:30 tsi Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -738,7 +738,7 @@
     int i;
     CGLPixelFormatAttribute attr[64]; // currently uses max of 30
     CGLPixelFormatObj result;
-    long n_formats;
+    GLint n_formats;
 
     i = 0;
 
Index: xc/lib/font/fontfile/decompress.c
diff -u xc/lib/font/fontfile/decompress.c:1.9 xc/lib/font/fontfile/decompress.c:1.10
--- xc/lib/font/fontfile/decompress.c:1.9	Sat Apr  8 11:30:24 2006
+++ xc/lib/font/fontfile/decompress.c	Sun Feb  1 12:23:31 2009
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/font/fontfile/decompress.c,v 1.9 2006/04/08 18:30:24 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/decompress.c,v 1.10 2009/02/01 20:23:31 tsi Exp $ */
 
 /*-
  * Copyright (c) 2005
@@ -77,7 +77,7 @@
 
 #include "fontmisc.h"
 #include <bufio.h>
-#ifdef __UNIXOS2__
+#if defined(__UNIXOS2__) || defined(__DARWIN__)
 #include <sys/types.h>
 #endif
 
Index: xc/lib/xtrans/Xtranssock.c
diff -u xc/lib/xtrans/Xtranssock.c:3.74 xc/lib/xtrans/Xtranssock.c:3.75
--- xc/lib/xtrans/Xtranssock.c:3.74	Mon Apr  2 17:21:06 2007
+++ xc/lib/xtrans/Xtranssock.c	Sun Feb  1 12:23:31 2009
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/xtrans/Xtranssock.c,v 3.75 2009/02/01 20:23:31 tsi Exp $ */
 /*
 
 Copyright 1993, 1994, 1998  The Open Group
@@ -26,7 +27,6 @@
 from the copyright holders.
 
 */
-/* $XFree86: xc/lib/xtrans/Xtranssock.c,v 3.74 2007/04/03 00:21:06 tsi Exp $ */
 
 /* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
  *
@@ -86,7 +86,7 @@
 #endif 
 
 #ifndef NO_TCP_H
-#if defined(__osf__) || defined(linux)
+#if defined(__osf__) || defined(linux) || defined(__DARWIN__)
 #include <sys/param.h>
 #endif /* osf */
 #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) 
Index: xc/programs/Xserver/Imakefile
diff -u xc/programs/Xserver/Imakefile:3.332 xc/programs/Xserver/Imakefile:3.333
--- xc/programs/Xserver/Imakefile:3.332	Mon Dec 31 17:41:59 2007
+++ xc/programs/Xserver/Imakefile	Sun Feb  1 12:37:06 2009
@@ -1,7 +1,7 @@
 /*
  * Server Master Makefile
  */
-XCOMM $XFree86: xc/programs/Xserver/Imakefile,v 3.332 2008/01/01 01:41:59 tsi Exp $
+XCOMM $XFree86: xc/programs/Xserver/Imakefile,v 3.333 2009/02/01 20:37:06 tsi Exp $
 
 /*
  * Copyright (c) 1994-2007 by The XFree86 Project, Inc.
@@ -1569,7 +1569,7 @@
 	$(MV) $(DESTDIR)$(BINDIR)/XDarwinApp \
 		$(DESTDIR)$(XDARWINAPPDIR)/MacOS/XDarwin
 	-(cd $(DESTDIR)$(BINDIR); $(RM) XDarwinQuartz; \
-		$(LN) $(DESTDIR)$(XDARWINAPPDIR)/MacOS/XDarwin XDarwinQuartz)
+		$(LN) $(XDARWINAPPDIR)/MacOS/XDarwin XDarwinQuartz)
 
 /*
  * Display mode bundles for Quartz
@@ -1584,7 +1584,7 @@
 	$(XPRDIRS), \
 	$(QUARTZDIR)/xpr/xprScreen.o, \
 	$(XPRLIBS), \
-	-framework ApplicationServices $(XPLUGINLIB))
+	$(XPLUGINLIB) -framework ApplicationServices)
 #endif
 
             CRDIRS = $(QUARTZDIR)/cr $(ROOTLESSDIR) $(ROOTLESSDIR)/safeAlpha
@@ -1619,7 +1619,7 @@
 	GL, \
 	GL/glx/glxext.o, \
 	GL/glx/libglx.a GL/apple/libAGLcore.a, \
-	-framework AGL -framework OpenGL)
+	-framework AGL -framework OpenGL $(NATIVE_GLDEP))
 
 #if BuildAppleDRI
 BundleProgramTarget(glxCGL, \
@@ -1627,7 +1627,7 @@
 	GL, \
 	GL/glx/glxext.o, \
 	GL/glx/libglx.a GL/apple/libCGLcore.a, \
-	-framework OpenGL $(XPLUGINLIB))
+	$(XPLUGINLIB) -framework OpenGL $(NATIVE_GLDEP))
 #endif
 
 BundleProgramTarget(glxMesa, \
Index: xc/programs/Xserver/GL/apple/indirect.c
diff -u xc/programs/Xserver/GL/apple/indirect.c:1.5 xc/programs/Xserver/GL/apple/indirect.c:1.6
--- xc/programs/Xserver/GL/apple/indirect.c:1.5	Sun Nov  4 11:57:14 2007
+++ xc/programs/Xserver/GL/apple/indirect.c	Sun Feb  1 12:23:31 2009
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/GL/apple/indirect.c,v 1.5 2007/11/04 19:57:14 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/GL/apple/indirect.c,v 1.6 2009/02/01 20:23:31 tsi Exp $ */
 /*
  * GLX implementation that uses Apple's OpenGL.framework
  * (Indirect rendering path)
@@ -453,7 +453,7 @@
     int i;
     CGLPixelFormatAttribute attr[64]; // currently uses max of 30
     CGLPixelFormatObj result;
-    long n_formats;
+    GLint n_formats;
     CGLError gl_err;
     
     GLAQUA_DEBUG_MSG("makeFormat\n");
Index: xc/programs/Xserver/hw/xfree86/CHANGELOG
diff -u xc/programs/Xserver/hw/xfree86/CHANGELOG:3.3988 xc/programs/Xserver/hw/xfree86/CHANGELOG:3.3992
--- xc/programs/Xserver/hw/xfree86/CHANGELOG:3.3988	Sun Dec 14 09:32:59 2008
+++ xc/programs/Xserver/hw/xfree86/CHANGELOG	Sun Feb  1 12:55:57 2009
@@ -1,3 +1,33 @@
+XFree86 4.8.99.1 (?? February 2009)
+   7. Deal with a build issue introduced by "security" update 2007-004 to
+      MacOSX.  This update, present in MacOSX 10.5, by default disables the use
+      of the DYLD_LIBRARY_PATH environment variable that supplemented the
+      run-time library search path.  To overcome this, change the build to link
+      bdftopcf, fc-cache, mkfontdir, mkfontscale, xcursorgen and xkbcomp
+      utilities against static versions of the libraries generated by the
+      build.  Although this is currently only done for Darwin 9 and later, this
+      is written in such a way that this can be done on any other platform
+      should the need arise  (Marc La France).
+   6. Fix links against libGL that arises on MacOSX Jaguar due to its confusion
+      over whether to use the build-generated library or a system-provided one
+      (Marc La France).
+   5. Various header-related build fixes for MacOSX 10.5 (Jaguar).  It is at
+      time unknown whether or not these negatively impact the build on older
+      versions of Darwin  (Marc La France).
+   4. Enable HasLibPthread for FreeBSD 7 and later because libc_r is no
+      longer present, and was deprecated since some earlier release (6.x?)
+      (David Dawes).
+   3. Disable optimisation when building the scanpci/pcidata modules which
+      contain a large amount of statically initialised data.  Optimisation
+      is disabled because it provokes an internal compiler error on FreeBSD
+      7.0 (David Dawes).
+   2. Update Xinstall.sh version for 4.8.0, and recognise some newer platforms
+      and their bindists (David Dawes).
+   1. Elf has been the only supported format on FreeBSD for a long time.
+      The objformat utility has been deprecated for a long time, and was
+      finally removed in FreeBSD 7.  Don't call it from imake for FreeBSD
+      5.x and later (David Dawes).
+
 XFree86 4.8.0 (15 December 2008)
   70. 4.8.0 release.
 
@@ -237,7 +267,7 @@
       libraries.  What remains are run-time only dependencies in the 2D glide
       driver (Glide2) and the tdfx DRI driver (Glide3)  (Marc La France).
 
-XFree86 4.7.99.1 (9 August 2007)
+XFree86 4.7.99.1 (9 September 2007)
 
 XFree86 4.7.0 (12 August 2007)
  167. 4.7.0 release.
@@ -20831,4 +20861,4 @@
 XFree86 3.0 (26 April 1994)
 
 
-$XFree86: xc/programs/Xserver/hw/xfree86/CHANGELOG,v 3.3988 2008/12/14 17:32:59 tsi Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/CHANGELOG,v 3.3992 2009/02/01 20:55:57 tsi Exp $
Index: xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh
diff -u xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh:1.97 xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh:1.98
--- xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh:1.97	Sun Aug 12 17:57:48 2007
+++ xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh	Fri Dec 26 19:56:01 2008
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# $XFree86: xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh,v 1.97 2007/08/13 00:57:48 dawes Exp $
+# $XFree86: xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh,v 1.98 2008/12/27 03:56:01 dawes Exp $
 #
 # Copyright © 2000 by Precision Insight, Inc.
 # Copyright © 2000, 2001 by VA Linux Systems, Inc.
@@ -31,7 +31,7 @@
 #
 
 #
-# Copyright © 1996-2007 by The XFree86 Project, Inc.
+# Copyright © 1996-2008 by The XFree86 Project, Inc.
 # All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining
@@ -78,7 +78,7 @@
 #
 
 #
-# This script should be used to install XFree86 4.7.0
+# This script should be used to install XFree86 4.8.0
 #
 # Parts of this script are based on the old preinst.sh and postinst.sh
 # scripts.
@@ -118,7 +118,7 @@
 	PATCHLEVEL=0
 	FULLVERSION=$VERSION
 else
-	FULLPREFIX=4.7
+	FULLPREFIX=4.8
 	PATCHLEVEL=0
 	VERSION=$FULLPREFIX.$PATCHLEVEL
 	FULLVERSION=$FULLPREFIX.0
@@ -709,6 +709,12 @@
 			5.*)
 				DistName="FreeBSD-5.x"
 				;;
+			6.*)
+				DistName="FreeBSD-6.x"
+				;;
+			7.*)
+				DistName="FreeBSD-7.x"
+				;;
 			*)
 				Message="FreeBSD/i386 binaries are not available for this version"
 				;;
@@ -856,6 +862,9 @@
 			3.*)
 				DistName="NetBSD-3.0"
 				;;
+			4.*)
+				DistName="NetBSD-4.x"
+				;;
 			*)
 				Message="No NetBSD/i386 binaries available for this version"
 				;;
@@ -876,8 +885,11 @@
 			3.*)	# Check this
 				DistName="OpenBSD-3.4"
 				;;
+			4.*)
+				DistName="OpenBSD-4.x"
+				;;
 			*)
-				Message="No OpenBSD/i386 binaries available for this version.   Try OpenBSD-3.4."
+				Message="No OpenBSD/i386 binaries available for this version.   Try OpenBSD-3.4 or OpenBSD-4.x"
 				;;
 			esac
 			;;
Index: xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist
diff -u xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist:1.9 xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist:1.10
--- xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist:1.9	Wed Dec 10 08:32:03 2008
+++ xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist	Tue Dec 23 12:07:25 2008
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $XFree86: xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist,v 1.9 2008/12/10 16:32:03 tsi Exp $
+# $XFree86: xc/programs/Xserver/hw/xfree86/etc/bindist/build-bindist,v 1.10 2008/12/23 20:07:25 dawes Exp $
 #
 
 Usage()
@@ -46,15 +46,23 @@
 FROMDIR=$1
 TODIR=$2
 
-if [ "`echo $FROMDIR | cut -b 1`" != "/" ]; then
+case "$FROMDIR" in
+/*)
+  ;;
+*)
   echo $FROMDIR is not an absolute path
   exit 2
-fi
+  ;;
+esac
 
-if [ "`echo $TODIR | cut -b 1`" != "/" ]; then
+case "$TODIR" in
+/*)
+  ;;
+*)
   echo $TODIR is not an absolute path
   exit 2
-fi
+  ;;
+esac
 
 if [ ! -d $FROMDIR ]; then
   echo No such dir $FROMDIR
Index: xc/programs/Xserver/hw/xfree86/scanpci/Imakefile
diff -u xc/programs/Xserver/hw/xfree86/scanpci/Imakefile:1.12 xc/programs/Xserver/hw/xfree86/scanpci/Imakefile:1.13
--- xc/programs/Xserver/hw/xfree86/scanpci/Imakefile:1.12	Fri Oct 14 08:17:09 2005
+++ xc/programs/Xserver/hw/xfree86/scanpci/Imakefile	Fri Dec 26 20:04:31 2008
@@ -1,5 +1,5 @@
 
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/scanpci/Imakefile,v 1.12 2005/10/14 15:17:09 tsi Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/scanpci/Imakefile,v 1.13 2008/12/27 04:04:31 dawes Exp $
 
 #if DoLoadableServer
 #define IHaveSubdirs
@@ -47,7 +47,9 @@
 
 LinkFile(xf86PciData.c,xf86ScanPci.c)
 
-SpecialCObjectRule(xf86PciData,NullParameter,-DPCIDATA)
+/* Some compilers have problems optimising these files with large data. */
+SpecialCObjectRule(xf86ScanPci,NullParameter,-O0)
+SpecialCObjectRule(xf86PciData,NullParameter,-O0 -DPCIDATA)
 
 #if DoLoadableServer
 MakeSubdirs($(SUBDIRS))
Index: xc/programs/Xserver/hw/xfree86/scanpci/module/Imakefile
diff -u xc/programs/Xserver/hw/xfree86/scanpci/module/Imakefile:1.5 xc/programs/Xserver/hw/xfree86/scanpci/module/Imakefile:1.6
--- xc/programs/Xserver/hw/xfree86/scanpci/module/Imakefile:1.5	Fri Oct 14 08:17:09 2005
+++ xc/programs/Xserver/hw/xfree86/scanpci/module/Imakefile	Fri Dec 26 20:04:31 2008
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/scanpci/module/Imakefile,v 1.5 2005/10/14 15:17:09 tsi Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/scanpci/module/Imakefile,v 1.6 2008/12/27 04:04:31 dawes Exp $
 /*
  * Copyright (c) 1994-2004 by The XFree86 Project, Inc.
  * All rights reserved.
@@ -63,7 +63,9 @@
 
 ModuleObjectRule()
 
-SpecialCObjectRule(xf86PciData,NullParameter,-DPCIDATA)
+/* Some compilers have problems optimising these files with large data. */
+SpecialCObjectRule(xf86ScanPci,NullParameter,-O0)
+SpecialCObjectRule(xf86PciData,NullParameter,-O0 -DPCIDATA)
 
 LibraryModuleTarget(scanpci,xf86ScanPci.o,.)
 
Index: xc/programs/bdftopcf/Imakefile
diff -u xc/programs/bdftopcf/Imakefile:3.11 xc/programs/bdftopcf/Imakefile:3.12
--- xc/programs/bdftopcf/Imakefile:3.11	Fri Oct 14 08:17:30 2005
+++ xc/programs/bdftopcf/Imakefile	Sun Feb  1 12:55:58 2009
@@ -1,8 +1,15 @@
-XCOMM $XFree86: xc/programs/bdftopcf/Imakefile,v 3.11 2005/10/14 15:17:30 tsi Exp $
+XCOMM $XFree86: xc/programs/bdftopcf/Imakefile,v 3.12 2009/02/01 20:55:58 tsi Exp $
 
 #if GzipFontCompression
+#if StaticUtils && BuildZlib
+ZLIB = $(BUILDLIBDIR)/LibraryTargetName(z)
+#else
 ZLIB = GzipLibrary
 #endif
+#endif
+#if StaticUtils
+FONTLIB = $(BUILDLIBDIR)/LibraryTargetName(Xfont)
+#endif
 LOCAL_LIBRARIES = $(FONTLIB)
 SYS_LIBRARIES = $(ZLIB) MathLibrary
 DEPLIBS = $(DEPFONTLIB)
Index: xc/programs/fc-cache/Imakefile
diff -u xc/programs/fc-cache/Imakefile:1.2 xc/programs/fc-cache/Imakefile:1.3
--- xc/programs/fc-cache/Imakefile:1.2	Fri Mar 17 17:34:23 2006
+++ xc/programs/fc-cache/Imakefile	Sun Feb  1 12:55:58 2009
@@ -1,14 +1,30 @@
-XCOMM $XFree86: xc/programs/fc-cache/Imakefile,v 1.2 2006/03/18 01:34:23 dawes Exp $
+XCOMM $XFree86: xc/programs/fc-cache/Imakefile,v 1.3 2009/02/01 20:55:58 tsi Exp $
 
-FONTCONFIGDIR = $(TOP)/extras/fontconfig
+  FONTCONFIGDIR = $(TOP)/extras/fontconfig
 
-INCLUDES=$(FREETYPE2INCLUDES) -I$(FONTCONFIGDIR)
+       INCLUDES = $(FREETYPE2INCLUDES) -I$(FONTCONFIGDIR)
 
-LOCAL_LIBRARIES=FontconfigClientLibs
-        DEPLIBS=FontconfigClientDepLibs
+#if StaticUtils
+# if BuildFontconfigLibrary
+  FONTCONFIGLIB = $(BUILDLIBDIR)/LibraryTargetName(fontconfig)
+# endif
+# if BuildFreetype2Library
+#  if defined(DarwinArchitecture) && DarwinQuartzSupport
+     FRAMEWORKS = -framework CoreServices -framework ApplicationServices
+#  endif
+   FREETYPE2LIB = $(BUILDLIBDIR)/LibraryTargetName(freetype) $(FRAMEWORKS)
+# endif
+# if BuildExpatLibrary
+       EXPATLIB = $(BUILDLIBDIR)/LibraryTargetName(expat)
+# endif
+LOCAL_LIBRARIES = $(FONTCONFIGLIB) $(FREETYPE2LIB) $(EXPATLIB)
+#else
+LOCAL_LIBRARIES = FontconfigClientLibs
+#endif
+        DEPLIBS = FontconfigClientDepLibs
 
-SRCS=fc-cache.c
-OBJS=fc-cache.o
+           SRCS = fc-cache.c
+           OBJS = fc-cache.o
 
 ComplexProgramTarget(fc-cache)
 LinkBuildBinary(ProgramTargetName(fc-cache))
Index: xc/programs/mkfontdir/Imakefile
diff -u xc/programs/mkfontdir/Imakefile:3.15 xc/programs/mkfontdir/Imakefile:3.16
--- xc/programs/mkfontdir/Imakefile:3.15	Fri Oct 14 08:17:31 2005
+++ xc/programs/mkfontdir/Imakefile	Sun Feb  1 12:55:58 2009
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/mkfontdir/Imakefile,v 3.15 2005/10/14 15:17:31 tsi Exp $
+XCOMM $XFree86: xc/programs/mkfontdir/Imakefile,v 3.16 2009/02/01 20:55:58 tsi Exp $
 
 /*
  * Copyright (c) 2004 by The XFree86 Project, Inc.
@@ -47,11 +47,20 @@
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#if StaticUtils
+       LOCAL_LIBRARIES = $(BUILDLIBDIR)/LibraryTargetName(Xfont) \
+			 $(BUILDLIBDIR)/LibraryTargetName(fntstubs)
+#else
        LOCAL_LIBRARIES = $(FONTLIB)
+#endif
                DEPLIBS = $(DEPFONTLIB)
               INCLUDES = -I$(FONTLIBSRC)/include
 #if GzipFontCompression
+#if StaticUtils && BuildZlib
+                  ZLIB = $(BUILDLIBDIR)/LibraryTargetName(z)
+#else
                   ZLIB = GzipLibrary
+#endif
               ZDEFINES = -DX_GZIP_FONT_COMPRESSION
 #endif
          SYS_LIBRARIES = MathLibrary $(ZLIB)
Index: xc/programs/mkfontscale/Imakefile
diff -u xc/programs/mkfontscale/Imakefile:1.10 xc/programs/mkfontscale/Imakefile:1.11
--- xc/programs/mkfontscale/Imakefile:1.10	Fri May 18 11:02:00 2007
+++ xc/programs/mkfontscale/Imakefile	Sun Feb  1 12:55:59 2009
@@ -1,21 +1,33 @@
-XCOMM $XFree86: xc/programs/mkfontscale/Imakefile,v 1.10 2007/05/18 18:02:00 tsi Exp $
+XCOMM $XFree86: xc/programs/mkfontscale/Imakefile,v 1.11 2009/02/01 20:55:59 tsi Exp $
 
-LOCAL_LIBRARIES = $(XFONTENCLIB) $(FREETYPE2LIB)
-        DEPLIBS = $(DEPXFONTENCLIB) $(DEPFREETYPE2LIB)
-
-SYS_LIBRARIES = GzipLibrary
+#if StaticUtils
+      XFONTENCLIB = $(BUILDLIBDIR)/LibraryTargetName(fontenc)
+# if BuildFreetype2Library
+#  if defined(DarwinArchitecture) && DarwinQuartzSupport
+       FRAMEWORKS = -framework CoreServices -framework ApplicationServices
+#  endif
+     FREETYPE2LIB = $(BUILDLIBDIR)/LibraryTargetName(freetype) $(FRAMEWORKS)
+# endif
+#endif
+  LOCAL_LIBRARIES = $(XFONTENCLIB) $(FREETYPE2LIB)
+          DEPLIBS = $(DEPXFONTENCLIB) $(DEPFREETYPE2LIB)
+#if StaticUtils && BuildZlib
+    SYS_LIBRARIES = $(BUILDLIBDIR)/LibraryTargetName(z)
+#else
+    SYS_LIBRARIES = GzipLibrary
+#endif
 
-SRCS = mkfontscale.c list.c hash.c ident.c
+             SRCS = mkfontscale.c list.c hash.c ident.c
 
-OBJS = mkfontscale.o list.o hash.o ident.o
+             OBJS = mkfontscale.o list.o hash.o ident.o
 
 #if !HasSnprintf
 SNPRINTF_DEFINES  = -DNEED_SNPRINTF
 SNPRINTF_INCLUDES = -I$(LIBSRC)/misc
 #endif
 
-INCLUDES = $(FREETYPE2INCLUDES) $(SNPRINTF_INCLUDES)
-DEFINES = $(FREETYPE2DEFINES) $(SNPRINTF_DEFINES)
+         INCLUDES = $(FREETYPE2INCLUDES) $(SNPRINTF_INCLUDES)
+          DEFINES = $(FREETYPE2DEFINES) $(SNPRINTF_DEFINES)
 
 ComplexProgramTarget(mkfontscale)
 LinkBuildBinary(ProgramTargetName(mkfontscale))
Index: xc/programs/xcursorgen/Imakefile
diff -u xc/programs/xcursorgen/Imakefile:1.7 xc/programs/xcursorgen/Imakefile:1.8
--- xc/programs/xcursorgen/Imakefile:1.7	Mon Dec 23 03:05:23 2002
+++ xc/programs/xcursorgen/Imakefile	Sun Feb  1 12:55:59 2009
@@ -1,7 +1,20 @@
-XCOMM $XFree86: xc/programs/xcursorgen/Imakefile,v 1.7 2002/12/23 11:05:23 herrb Exp $
+XCOMM $XFree86: xc/programs/xcursorgen/Imakefile,v 1.8 2009/02/01 20:55:59 tsi Exp $
+
 #define IHaveSubdirs
 #define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
 
+#if StaticUtils
+     XCURSORLIB = $(BUILDLIBDIR)/LibraryTargetName(Xcursor)
+     XRENDERLIB = $(BUILDLIBDIR)/LibraryTargetName(Xrender)
+           XLIB = $(BUILDLIBDIR)/LibraryTargetName(Xext) \
+		  $(BUILDLIBDIR)/LibraryTargetName(X11)
+#endif
+#if StaticUtils && BuildZlib
+           ZLIB = $(BUILDLIBDIR)/LibraryTargetName(z)
+#else
+           ZLIB = GzipLibrary
+#endif
+
         SUBDIRS = redglass whiteglass handhelds
   DEFAULT_THEME = DefaultCursorTheme
         ICONDIR = $(LIBDIR)/icons
@@ -9,7 +22,7 @@
        INCLUDES = $(LIBPNGINC)
         DEPLIBS = $(DEPXLIB)
 LOCAL_LIBRARIES = $(XCURSORLIB) $(XRENDERLIB) $(XLIB) $(LIBPNGLIB) \
-		  MathLibrary GzipLibrary
+		  MathLibrary $(ZLIB)
            SRCS = xcursorgen.c
            OBJS = xcursorgen.o
 
Index: xc/programs/xkbcomp/Imakefile
diff -u xc/programs/xkbcomp/Imakefile:3.26 xc/programs/xkbcomp/Imakefile:3.27
--- xc/programs/xkbcomp/Imakefile:3.26	Wed Apr  4 12:28:39 2007
+++ xc/programs/xkbcomp/Imakefile	Sun Feb  1 12:55:59 2009
@@ -1,19 +1,24 @@
-XCOMM $XFree86: xc/programs/xkbcomp/Imakefile,v 3.26 2007/04/04 19:28:39 tsi Exp $
+XCOMM $XFree86: xc/programs/xkbcomp/Imakefile,v 3.27 2009/02/01 20:55:59 tsi Exp $
 
 #define IHaveSubdirs
 #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
 
+#if StaticUtils
+     XKBFILELIB = $(BUILDLIBDIR)/LibraryTargetName(xkbfile)
+       XONLYLIB = $(BUILDLIBDIR)/LibraryTargetName(X11)
+#endif
+
 #if CrossCompiling
-         CROSS = cross
+          CROSS = cross
 #endif
-          SRCS = xkbcomp.c xkbscan.c expr.c vmod.c indicators.c misc.c \
-		 keymap.c keycodes.c keytypes.c compat.c action.c alias.c \
-		 symbols.c geometry.c xkbpath.c listing.c \
-		 xkbparse.c parseutils.c utils.c
-          OBJS = xkbcomp.o xkbscan.o expr.o vmod.o indicators.o misc.o alias.o \
-		 keymap.o keycodes.o keytypes.o compat.o action.o \
-		 symbols.o geometry.o xkbpath.o listing.o \
-		 xkbparse.o parseutils.o utils.o
+           SRCS = xkbcomp.c xkbscan.c expr.c vmod.c indicators.c misc.c \
+		  keymap.c keycodes.c keytypes.c compat.c action.c alias.c \
+		  symbols.c geometry.c xkbpath.c listing.c \
+		  xkbparse.c parseutils.c utils.c
+           OBJS = xkbcomp.o xkbscan.o expr.o vmod.o indicators.o misc.o \
+		  keymap.o keycodes.o keytypes.o compat.o action.o alias.o \
+		  symbols.o geometry.o xkbpath.o listing.o \
+		  xkbparse.o parseutils.o utils.o
         DEPLIBS = $(DEPXKBFILELIB) $(DEPXONLYLIB)
 LOCAL_LIBRARIES = $(XKBFILELIB) $(XONLYLIB)
         SUBDIRS = compat compiled $(CROSS) geometry keycodes keymap rules \
