Subject: Re: porting XF3 servers to XF4
To: None <tech-x11@netbsd.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: tech-x11
Date: 12/28/2003 19:35:02
In article <28073.1072591772@splode.eterna.com.au>
mrg@eterna.com.au wrote:

> we need people to look at porting these hw/netbsd servers:
> 	alpha amiga arm32vidc dec dreamcast hpc mac68k pmax vax x68k

Before starting effort of XF4 migration,
I'd like to cleanup MACHINE_CPU and MACHINE specific definitions
in Imake.cf and NetBSD.cf, which are awfully ugly in XF3.

The attached diff contains:
- separate and sort "fooArchitecture" definitions
  for MACHINE_CPU and MACHINE in Imake.cf
- centralize MACHINE_CPU and MACHINE dependent defeintions in NetBSD.cf
  (some stuff is still left in different place, though)
- avoid #elif to check fooArchitecture
- normalize format of OS*version check
- fix indent etc.

I've checked only "make all" on i386, and definitions for some
MACHINE/MACHINE_CPU might require some fixes, but they should
be trivial.

Comments?
---
Izumi Tsutsui
tsutsui@ceres.dti.ne.jp

Index: config/cf/Imake.cf
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/config/cf/Imake.cf,v
retrieving revision 1.10
diff -u -r1.10 Imake.cf
--- config/cf/Imake.cf	27 Dec 2003 08:44:24 -0000	1.10
+++ config/cf/Imake.cf	28 Dec 2003 08:48:54 -0000
@@ -171,57 +171,87 @@
 # define MacroFile NetBSD.cf
 # undef __NetBSD__
 # define NetBSDArchitecture
-# ifdef __i386__
+  /* MACHINE_CPU specific definitions ("__${MACHINE_CPU}__ is defined by cpp) */
+# if defined(__alpha__) || defined(alpha)
+#  define AlphaArchitecture
+#  define AlphaBsdArchitecture
+#  undef alpha
+# endif
+# if defined(__arm__) || defined(arm)
+#  define armArchitecture
+#  undef arm
+# endif
+# if defined(__hppa__) || defined(hppa)
+#  define hppaArchitecture
+#  undef mips
+# endif
+# if defined(__i386__) || defined(i386)
 #  define i386BsdArchitecture
 #  define i386Architecture
 #  undef i386
 # endif
-# if defined(__sparc64__) || defined(__sparc_v9__) || defined(__arch64__)
-#  define Sparc64Architecture
+# if defined(__m68000__) || defined(m68000)
+#  define m68000Architecture
+#  define Mc68000Architecture
+#  undef m68000
 # endif
-# if defined(__sparc__) || defined(sparc)
-#  define SparcArchitecture
-#  undef sparc
-#  if defined(__sparc_v9__) || defined(__arch64__)
-#    define Sparc64Architecture
-#  endif
+# if defined(__m68k__) || defined(m68k)
+#  define m68kArchitecture
+#  define Mc68020Architecture
+#  undef m68k
 # endif
-# ifdef mips
-#   define MipsArchitecture
-#   define ArcArchitecture
-#   undef mips
+# if defined(__mips__) || defined(mips)
+#  define MipsArchitecture
+#  undef mips
 # endif
-# ifdef __alpha__
-#   define AlphaArchitecture
-#   define AlphaBsdArchitecture
-#   undef __alpha__
+# if defined(__ns32k__) || defined(ns32k)
+#  define ns32kArchitecture
+#  undef ns32k
 # endif
-# ifdef mc68000
-#   define Mc68020Architecture
+# if defined(__powerpc__) || defined(powerpc)
+#  define PpcArchitecture
+#  undef powerpc
 # endif
-# ifdef __arm32__
-#   define Arm32Architecture
-#   undef __arm32__
-# endif
-# ifdef __cats__
-#   define CatsArchitecture
-#   undef __cats__
-# endif
-# ifdef __vax__
-#   define VaxArchitecture
-#   undef __vax__
+# if defined(__sh__) || defined(sh)
+#  define shArchitecture
+#  if defined(__SH5__)
+#   define sh5Architecture
+#  else
+#   define sh3Architecture
+#  endif
+#  undef sh
 # endif
-# ifdef __powerpc__
-#   define PpcArchitecture
-#   undef __powerpc__
+# if defined(__sparc__)
+#  define SparcArchitecture
+#  undef sparc
+#  if defined(__sparc_v9__) || defined(__arch64__)
+#   define Sparc64Architecture
+#  endif
 # endif
-# ifdef __macppc__
-#   define macppcArchitecture
-#   undef __macppc__
+# if defined(__sparc64__) || defined(__sparc_v9__) || defined(sparc64)
+#  define Sparc64Architecture
+#  undef sparc64
+# endif
+# if defined(__vax__) || defined(vax)
+#  define VaxArchitecture
+#  undef vax
 # endif
-# ifdef __x86_64__
+# if defined(__x86_64__) || defined(x86_64)
 #  define x86_64Architecture
-#  undef __x86_64__
+#  undef x86_64
+# endif
+  /* MACHINE specific definitions ("__${MACHINE}__" is defined by imake) */
+# if defined(__acorn32__)
+#  define acorn32Architecture
+#  undef __acorn32__
+# endif
+# if defined(__cats__)
+#  define catsArchitecture
+#  undef __cats__
+# endif
+# if defined(__macppc__)
+#  define macppcArchitecture
+#  undef __macppc__
 # endif
 #endif /* NetBSD */
 
Index: config/cf/NetBSD.cf
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/config/cf/NetBSD.cf,v
retrieving revision 1.59
diff -u -r1.59 NetBSD.cf
--- config/cf/NetBSD.cf	27 Dec 2003 08:46:58 -0000	1.59
+++ config/cf/NetBSD.cf	28 Dec 2003 08:48:54 -0000
@@ -52,11 +52,11 @@
 # define HasLibCrypt		YES
 #endif
 #ifndef HasShm
-# if OSMajorVersion == 0 && OSMinorVersion == 9 && OSTeenyVersion == 2
 /*
  * Shm memory was removed in 0.9B because it was encumbered.
  * A free version was added in 0.9C
  */
+# if (OSMajorVersion == 0 && OSMinorVersion == 9 && OSTeenyVersion == 2)
 #  define HasShm          	NO
 # else
 #  define HasShm          	YES
@@ -68,27 +68,30 @@
  */
 #if ((OSMajorVersion == 1 && OSMinorVersion < 2) || \
      (OSMajorVersion == 1 && OSMinorVersion == 2 && OSTeenyVersion < 2))
-#  define HasDlsymBug		YES
+# define HasDlsymBug		YES
 #endif
 /* Mkstemp is there since 1.2 (at least) */
-#if (!(OSMajorVersion == 0 || \
-       (OSMajorVersion == 1 && OSMinorVersion < 2))) 
-#define HasMkstemp		YES
+#if ((OSMajorVersion > 1) || \
+     (OSMajorVersion == 1 && OSMinorVersion >= 2)) 
+# define HasMkstemp		YES
 #endif
-/* But the standalone mktemp doesn't exist before NetBSD 1.5*/
-#if (OSMajorVersion ==0 || (OSMajorVersion == 1 && OSMinorVersion <= 4))
+/* But the standalone mktemp doesn't exist before NetBSD 1.5 */
+#if ((OSMajorVersion == 0) || \
+     (OSMajorVersion == 1 && OSMinorVersion <= 4))
 # define HasMktemp		NO
 #else
 # define HasMktemp		YES
 #endif
 
 #ifndef HasIssetugid
-# if (OSMajorVersion > 1 || (OSMajorVersion == 1 && OSMinorVersion >= 5))
+# if ((OSMajorVersion > 1) || \
+      (OSMajorVersion == 1 && OSMinorVersion >= 5))
 #  define HasIssetugid          YES
 # endif
 #endif
 
-#if (OSMajorVersion == 1 && OSMinorVersion >= 5 || OSMajorVersion > 1) 
+#if ((OSMajorVersion > 1) || \
+     (OSMajorVersion == 1 && OSMinorVersion >= 5)) 
 #define HasGetIfAddrs		YES
 #endif
 
@@ -125,11 +128,18 @@
 # define ThreadedX		NO
 #endif
 
-#if (OSMajorVersion >= 2 || \
-      (OSMajorVersion == 1 && OSMinorVersion == 6 && OSTeenyVersion >= 2))
+#if ((OSMajorVersion > 1) || \
+     (OSMajorVersion == 1 && OSMinorVersion == 6 && OSTeenyVersion >= 2))
 # define HasArc4random
 #endif
 
+#if ((OSMajorVersion > 1) || \
+     (OSMajorVersion == 1 && OSMinorVersion >= 4))
+/* XXX: When has /dev/urandom support been added? 1.4 or 1.5? */
+# define HasDevRandom		YES
+# define RandomDeviceFile	/dev/urandom
+#endif
+
 /*
  * Compiler Features
  */
@@ -148,18 +158,11 @@
 #undef CcCmd
 #define CcCmd 			gcc
 #ifndef DefaultCCOptions
-#if defined(UseInstalled)
-#define DefaultCCOptions 	/**/
-#else
-#if defined(Arm32Architecture) || defined(CatsArchitecture)
-#define DefaultCCOptions 	-ansi -Dasm=__asm -fsigned-char \
-				-fomit-frame-pointer
-#elif defined(PpcArchitecture)
-# define DefaultCCOptions	-ansi -Dasm=__asm -fsigned-char
-#else
-# define DefaultCCOptions 	-ansi -Dasm=__asm
-#endif
-#endif
+# if defined(UseInstalled)
+#  define DefaultCCOptions 	/**/
+# else
+#  define DefaultCCOptions 	-ansi -Dasm=__asm
+# endif
 #endif
 
 #define CppCmd			cpp
@@ -181,33 +184,48 @@
 # endif
 #endif
 
-#if 0
-/* one day we should enable this, but support is needed in the Xserver */
+/*
+ * Shared lib/dynamic loading supported starting in 1.0 on a.out platforms,
+ * and on all ELF platforms.
+ * XXX: not all ELF platforms support shared lib yet.
+ */
 #if UseElfFormat
-# ifndef DoLoadableServer
-#  define DoLoadableServer	YES
+# ifndef HasSharedLibraries
+# if (!defined(ns32kArchitecture) && \
+      !defined(m68000Architecture) && \
+      !defined(sh3Architecture) && \
+      !defined(sh5Architecture) && \
+      !defined(VaxArchitecture))
+# define HasSharedLibraries	YES
+# endif /* !defined(__Architectures without ELF shlib support__) */
 # endif
-#endif
-#endif
-
+# if defined(i386Architecture) || defined(PpcArchitecture)
 /*
- * Dynamic loading supported starting in 1.0 on a.out platforms,
- * and on all ELF platforms.
- *
- * XXX May not be correct on NetBSD/pmax (ELF, but might not have
- * working shared libs).
- *
- * Disabled for NetBSD/vax until I figure out the scheme. --CS 
+ * XXX one day we should enable this for all architechtures,
+ * XXX but support is needed in the Xserver
  */
-#if ((OSMajorVersion > 0) && defined(i386Architecture)) || \
-    defined(PpcArchitecture)
 #  ifndef DoLoadableServer
 #  define DoLoadableServer	YES
 #  endif
-#else
+# endif /* defined(i386Architecture) || defined(PpcArchitecture) */
+#else /* UseElfFormat */
+# if (OSMajorVersion > 0) && \
+     (!defined(AlphaArchitecture) && !defined(MipsArchitecture))
+   /* XXX: what port lacked a.out shlib support? */
+#  ifndef HasSharedLibraries
+#  define HasSharedLibraries	YES
+#  endif
+   /* XXX: what port had a.out dynamic loading support? Only i386? */
 #  ifndef DoLoadableServer
-#  define DoLoadableServer	NO
+#  define DoLoadableServer	YES
 #  endif
+# endif /* ((OSMajorVersion > 0) && defined(i386Architecture)) */
+#endif
+#ifndef HasSharedLibraries
+#define HasSharedLibraries	NO
+#endif 
+#ifndef DoLoadableServer
+#define DoLoadableServer	NO
 #endif
 
 #if UseElfFormat
@@ -219,98 +237,184 @@
 /* All ELF NetBSD systems support Weak symbols */
 #define HasWeakSymbols		UseElfFormat 
 
+/*
+ * MACHINE_CPU specific (mostly toolchain specific) options
+ */
+
+/* arm */
+#ifdef armArchitecture
+# undef  DefaultCCOptions
+# define DefaultCCOptions 	-ansi -Dasm=__asm -fsigned-char \
+				-fomit-frame-pointer
+#endif
+
+/* i386 */
 #ifdef i386Architecture
 # ifndef DefaultGcc2i386Opt
-#  if OSMajorVersion > 1 || (OSMajorVersion == 1 && OSMinorVersion > 2)
+#  if ((OSMajorVersion > 1) || \
+       (OSMajorVersion == 1 && OSMinorVersion > 2))
     /* The GCC strength-reduce bug is fixed for NetBSD 1.3 and later */
-#   define DefaultGcc2i386Opt -O2
+#   define DefaultGcc2i386Opt	-O2
 #  endif
 # endif
 # define OptimizedCDebugFlags 	DefaultGcc2i386Opt
-# if OSMajorVersion < 1
-#  define ServerOSDefines	XFree86ServerOSDefines -DXNO_SYSCONF
-# else
-#  define ServerOSDefines	XFree86ServerOSDefines
+#endif
+
+/* m68k */
+#ifdef m68kArchitecture
+# if (OSMajorVersion == 1 && OSMinorVersion <= 3)
+#  define OptimizedCDebugFlags	-O
 # endif
-# if OSMajorVersion == 1 && OSMinorVersion >= 1 || OSMajorVersion >= 2
-#  define ServerExtraSysLibs	-li386
+#endif
+
+/* mips */
+#ifdef MipsArchitecture
+#define PositionIndependentCFlags
+#define SharedLibraryLoadFlags	-x -shared --whole-archive \
+				-soname `echo $@ | sed 's/\.[0-9]*$$//'`
+#define SharedXtReqs	$(XLIBONLY) $(SMLIB) $(ICELIB)
+#define SharedXmuReqs	$(LDPRELIB) $(XTOOLONLYLIB) $(XONLYLIB) $(EXTENSIONLIB)
+#endif
+
+/* powerpc */
+#ifdef PpcArchitecture
+# undef  DefaultCCOptions
+# define DefaultCCOptions	-ansi -Dasm=__asm -fsigned-char
+#endif
+
+/* sh3 */
+#ifdef sh3Architecture
+# define OptimizedCDebugFlags	-O
+#endif
+
+/* x86_64 */
+#if defined(x86_64Architecture)
+# define OptimizedCDebugFlags	-O2	/* XXX not needed anymore? */
+#endif
+
+/* set default */
+#ifndef OptimizedCDebugFlags
+#define OptimizedCDebugFlags 	-O2
+#endif
+/* End of MACHINE_CPU specific options */
+
+/*
+ * MACHINE specific (mostly Xserver dependent) definitions
+ */
+
+/* acorn32 */
+#if defined(acorn32Architecture)
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME
+# define ServerExtraDefines	GccGasOption XFree86ServerDefines
+# ifndef XFree86ConsoleDefines
+# define XFree86ConsoleDefines	-DPCCONS_SUPPORT
 # endif
-#else
-# define OptimizedCDebugFlags 	-O2
-# if defined(SparcArchitecture)
-#  define ServerOSDefines 	-DDDXOSINIT
-# elif defined(AlphaArchitecture)
-#  define ServerOSDefines 	XFree86ServerOSDefines
-# elif defined(Arm32Architecture)
-#   define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME
-# elif defined(CatsArchitecture)
-#   define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME 
-# elif defined(PpcArchitecture)
-#  define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DDDXOSINIT
-# elif defined(x86_64Architecture)
-#  undef OptimizedCDebugFlags
-#  define OptimizedCDebugFlags	-O2
-#  define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME
-# else
-#  define ServerOSDefines 	/**/
+#endif
+
+/* alpha */
+#if defined(AlphaArchitecture)
+# define ServerOSDefines 	XFree86ServerOSDefines
+# define ServerExtraDefines	GccGasOption XFree86ServerDefines -D_XSERVER64
+# ifndef XFree86ConsoleDefines
+# define XFree86ConsoleDefines	-DWSCONS_SUPPORT -DPCCONS_SUPPORT -DPCVT_SUPPORT
 # endif
-# if defined(AlphaArchitecture)
-#  define ServerExtraSysLibs	-lalpha
-# elif defined(x86_64Architecture)
-#  define ServerExtraSysLibs	-lx86_64
-# else
-#  define ServerExtraSysLibs	/**/
+# define ServerExtraSysLibs	-lalpha
+#endif
+
+/* amd64 (XXX: identical with x86_64 for now) */
+#if defined(x86_64Architecture)
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME
+# define ServerExtraDefines	GccGasOption XFree86ServerDefines -D_XSERVER64
+# ifndef XFree86ConsoleDefines
+# define XFree86ConsoleDefines	-DWSCONS_SUPPORT
+# endif
+# define ServerExtraSysLibs	-lx86_64
+#endif
+
+/* cats */
+#if defined(catsArchitecture)
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME 
+# define ServerExtraDefines	GccGasOption XFree86ServerDefines
+# ifndef XFree86ConsoleDefines
+# define XFree86ConsoleDefines	-DPCCONS_SUPPORT -DPCVT_SUPPORT -DWSCONS_SUPPORT
 # endif
 #endif
+
+/* i386 */
 #ifdef i386Architecture
+# if (OSMajorVersion < 1)
+#  define ServerOSDefines	XFree86ServerOSDefines -DXNO_SYSCONF
+# else
+#  define ServerOSDefines	XFree86ServerOSDefines
+# endif
+# if ((OSMajorVersion > 1) || \
+      (OSMajorVersion == 1 && OSMinorVersion >= 1))
+#  define ServerExtraSysLibs	-li386
+# endif
 # define ServerExtraDefines GccGasOption XFree86ServerDefines
 # ifndef XFree86ConsoleDefines
-#  if (OSMajorVersion == 1 && ((OSMinorVersion == 3 && OSTeenyVersion >= 6) \
-	                       || OSMinorVersion >= 4) \
-       || OSMajorVersion >= 2)  
-#   define XFree86ConsoleDefines -DPCCONS_SUPPORT -DPCVT_SUPPORT -DWSCONS_SUPPORT
+#  if ((OSMajorVersion > 1) || \
+       (OSMajorVersion == 1 && OSMinorVersion == 3 && OSTeenyVersion >= 6) || \
+       (OSMajorVersion == 1 && OSMinorVersion >= 4))
+#   define XFree86ConsoleDefines -DPCCONS_SUPPORT -DPCVT_SUPPORT \
+	-DWSCONS_SUPPORT
 #  else
 #   define XFree86ConsoleDefines -DPCCONS_SUPPORT -DPCVT_SUPPORT
 #  endif
 # endif
-#elif defined(SparcArchitecture)
-#  if defined(Sparc64Architecture)
-#   define ServerExtraDefines XFree86ServerDefines -D_XSERVER64
-#  else
-#   define ServerExtraDefines XFree86ServerDefines
-#  endif
-# elif defined(AlphaArchitecture)
-	/* XXX for the following */
-#  define ServerExtraDefines GccGasOption XFree86ServerDefines -D_XSERVER64
-#  ifndef XFree86ConsoleDefines
-#   define XFree86ConsoleDefines -DWSCONS_SUPPORT -DPCCONS_SUPPORT -DPCVT_SUPPORT
-#  endif
-#elif defined(AlphaArchitecture)
-#   define ServerExtraDefines GccGasOption -D_XSERVER64
-#elif defined(Arm32Architecture)
-#  define ServerExtraDefines GccGasOption XFree86ServerDefines
-#  ifndef XFree86ConsoleDefines
-#    define XFree86ConsoleDefines -DPCCONS_SUPPORT
-#  endif
-#elif defined(CatsArchitecture)
-#  define ServerExtraDefines GccGasOption XFree86ServerDefines
-#  ifndef XFree86ConsoleDefines
-#    define XFree86ConsoleDefines	-DPCCONS_SUPPORT -DPCVT_SUPPORT -DWSCONS_SUPPORT
-#  endif
-#elif defined(PpcArchitecture)
-#  define ServerExtraDefines	GccGasOption XFree86ServerDefines
-#  ifndef XFree86ConsoleDefines
-#    define XFree86ConsoleDefines	-DWSCONS_SUPPORT
-#  endif
-#elif defined(x86_64Architecture)
-# define ServerExtraDefines	GccGasOption XFree86ServerDefines -D_XSERVER64
-#  ifndef XFree86ConsoleDefines
-#    define XFree86ConsoleDefines -DWSCONS_SUPPORT
-#  endif
-#else
-#  define ServerExtraDefines GccGasOption
 #endif
 
+/* macppc */
+#if defined(macppcArchitecture)
+# define XmacppcServer		YES
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DDDXOSINIT
+# define ServerExtraDefines	GccGasOption XFree86ServerDefines
+# define XkbServerDefines	-DXKB_ALWAYS_USES_SOFT_REPEAT
+# ifndef XFree86ConsoleDefines
+# define XFree86ConsoleDefines	-DWSCONS_SUPPORT
+# endif
+#endif
+
+/* sparc */
+#if defined(SparcArchitecture)
+# define ServerOSDefines 	-DDDXOSINIT
+# define ServerExtraDefines	XFree86ServerDefines
+#endif
+
+/* sparc64 */
+#if defined(Sparc64Architecture)
+# define ServerOSDefines 	-DDDXOSINIT
+# define ServerExtraDefines	XFree86ServerDefines -D_XSERVER64
+# if 0 /* XXX: we should just remove this line?  */
+# define XkbServerDefines	-DXKB_ALWAYS_USES_SOFT_REPEAT
+# endif
+# ifndef XF86Server
+# define XF86Server		YES
+# endif
+# if XF86Server
+#  define XF86OSCardDrivers	/* wsfb sunffb */
+#  define AsOutputArchSize	64
+#  define AsVISOption		-Av9a
+#  define XFree86ConsoleDefines	-DWSCONS_SUPPORT
+# endif
+#endif
+
+/* vax */
+#ifdef VaxArchitecture
+/* XXX: is this needed? */
+#define BuildServer	NO
+#endif
+
+/* set default */
+#ifndef ServerExtraDefines
+#define ServerExtraDefines	GccGasOption
+#endif
+#ifndef ServerOSDefines
+#define ServerOSDefines		/**/	
+#endif
+/* End of MACHINE specific compiler options */
+
+
 #define StandardDefines	-DCSRG_BASED
 /* Citrus mb locale were added in 1.5P */
 #if ((OSMajorVersion > 1) || \
@@ -331,8 +435,8 @@
  * be a release for 1.4.9.
  */
 # if ((OSMajorVersion > 1) || \
-     (OSMajorVersion == 1 && OSMinorVersion > 4) || \
-     (OSMajorVersion == 1 && OSMinorVersion == 4 && OSTeenyVersion > 9))
+      (OSMajorVersion == 1 && OSMinorVersion > 4) || \
+      (OSMajorVersion == 1 && OSMinorVersion == 4 && OSTeenyVersion > 9))
 #  define UseGnuMalloc		NO
 # else
 #  define UseGnuMalloc		YES
@@ -407,10 +511,12 @@
 # ifndef HasNetBSDApertureDriver
 #  define HasNetBSDApertureDriver	YES
 # endif
+#endif /* i386Architecture */
 
 /*
  * Builtin MTRR support (NetBSD 1.5Y and up)
  */
+#if defined(i386Architecture)
 # if ((OSMajorVersion > 1) || \
       (OSMajorVersion == 1 && OSMinorVersion >= 6) || \
       (OSMajorVersion == 1 && OSMinorVersion == 5 && \
@@ -431,7 +537,7 @@
 #if defined(x86_64Architecture)
 # define HasMTRRBuiltin       YES
 # define XF86AFB              YES
-#endif
+#endif /* x86_64Architecture */
 
 /*
  * agpgart support (NetBSD 1.5Y and up)
@@ -450,7 +556,8 @@
  * necessary kernel and toolchain support.
  */
 #if defined(i386Architecture) &&  \
-	((OSMajorVersion > 1) || (OSMajorVersion == 1 && OSMinorVersion > 5))
+     ((OSMajorVersion > 1) || \
+      (OSMajorVersion == 1 && OSMinorVersion > 5))
 # define HasX86Support          YES
 # define HasMMXSupport          YES
 # define Has3DNowSupport        YES
@@ -463,12 +570,11 @@
 #endif
 
 #ifndef HasCookieMaker
-# if OSMajorVersion == 1 && OSMinorVersion >= 5 || OSMajorVersion >= 2
-   /* NetBSD 1.5 and later have /dev/urandom */
+# if HasDevRandom
 #  define HasCookieMaker	YES
 #  define MkCookieCmd \
 	'dd if=/dev/urandom bs=16 count=1 2>/dev/null | hexdump -e \\"%08x\\"'
-# else
+# else /* HasDevRandom */
 #  define HasCookieMaker	NO
 # endif
 #endif
@@ -576,21 +682,6 @@
 									@@\
 InstallManPageAliasesBase(file,destdir,aliases)
 
-/*
- * Shared libraries supported starting in 1.0 on a.out platforms,
- * and on all ELF platforms.
- *
- * XXX May not be correct on NetBSD/pmax (ELF, but might not have
- * working shared libs).
- */
-#if ((OSMajorVersion > 0) && \
-     !defined(AlphaArchitecture) && !defined(MipsArchitecture)) || \
-    UseElfFormat
-# ifndef HasSharedLibraries
-# define HasSharedLibraries	YES
-# endif
-#endif
-
 #ifndef OSBinaryType
 #if UseElfFormat
 #define OSBinaryType	[ELF]
@@ -599,18 +690,22 @@
 #endif
 #endif
 
-#ifndef HasSharedLibraries
-#define HasSharedLibraries	NO
-#endif 
-
 #if HasSharedLibraries
 #include <bsdLib.rules>
 #endif /* HasSharedLibraries */
 
-/* Always build the XInput library, regardless of server support on this plattform */
+/*
+ * Always build the XInput library, regardless of server support
+ * on this plattform
+ */
 #define BuildXInputLib          YES
 
-#if defined(i386Architecture) || defined(Arm32Architecture) || defined(AlphaArchitecture) || defined(PpcArchitecture) || defined(CatsArchitecture) || defined(x86_64Architecture)
+#if defined(acorn32Architecture) || \
+    defined(AlphaArchitecture) || \
+    defined(catsArchitecture) || \
+    defined(i386Architecture) || \
+    defined(macppcArchitecture) || \
+    defined(x86_64Architecture)
 # include <xfree86.cf>
 #endif
 
@@ -622,21 +717,22 @@
 
 /*
  * Definitions for the SUN server on NetBSD/sparc
+ * XXX: maybe these definitions should be moved to MACHINE specific part.
  */
 #ifdef	SparcArchitecture
 
-#ifndef Xsun24Server
-#define Xsun24Server	YES
-#endif
-#ifndef XsunServer
-#define XsunServer	YES
-#endif
-#ifndef XsunMonoServer
-#define XsunMonoServer	YES
-#endif
-#ifndef BuildScreenSaverLibrary
-#define BuildScreenSaverLibrary	YES
-#endif
+# ifndef Xsun24Server
+# define Xsun24Server	YES
+# endif
+# ifndef XsunServer
+# define XsunServer	YES
+# endif
+# ifndef XsunMonoServer
+# define XsunMonoServer	YES
+# endif
+# ifndef BuildScreenSaverLibrary
+# define BuildScreenSaverLibrary	YES
+# endif
 
 /*
  * XFree86 uses its own (more portable) database routines to speed up 
@@ -644,87 +740,22 @@
  * However, if you want to use ndbm anyway, you can set that to NO in 
  * site.def
  */
-#ifndef UseRgbTxt
-#define UseRgbTxt	YES
-#endif
-
-#define BuildXF86VidModeExt	NO
-
-#if !defined(Sparc64Architecture)
-
-#define BuildXF86DGA		NO
-#define BuildXInputExt		NO
-#include <xfree86.cf>
-
-#else /* Sparc64Architecture */
-# define OptimizedCDebugFlags	-O2
-
-# ifndef XF86Server
-#  define XF86Server		YES
-# endif
-
-/* # define XkbServerDefines  -DXKB_ALWAYS_USES_SOFT_REPEAT */
-
-# if XF86Server
-#   ifndef DoLoadableServer
-#     define DoLoadableServer	NO
-#   endif
-#   define XF86OSCardDrivers	/* wsfb sunffb */
-#   define AsOutputArchSize	64
-#   define AsVISOption		-Av9a
-#   define XFree86ConsoleDefines -DWSCONS_SUPPORT
-# endif
-
-#define BuildXF86DGA		YES
-#define BuildXInputExt		YES
-#include <xfree86.cf>
-
-#endif
-
-#endif
-
-/*
- * Definition for compiling on MIPS machines
- */
-#ifdef MipsArchitecture
-#define PositionIndependentCFlags
-#define SharedLibraryLoadFlags -x -shared --whole-archive -soname `echo $@ |
-sed 's/\.[0-9]*$$//'`
-#define SharedXtReqs $(XLIBONLY) $(SMLIB) $(ICELIB)
-#define SharedXmuReqs $(LDPRELIB) $(XTOOLONLYLIB) $(XONLYLIB) $(EXTENSIONLIB)
-#endif
-
-/*
- * Definition for compile on macppc machines
- */
-#ifdef macppcArchitecture
-
-# define OptimizedCDebugFlags 	-O2
-# define XkbServerDefines	-DXKB_ALWAYS_USES_SOFT_REPEAT
-
-# ifndef DoLoadableServer
-#   define DoLoadableServer	YES
+# ifndef UseRgbTxt
+# define UseRgbTxt	YES
 # endif
 
-# define UseElfFormat		YES
-
-# define XmacppcServer		YES
-
-#endif
+# define BuildXF86VidModeExt	NO
 
-/*
- * Definition for compiling on cats machines
- */
-#ifdef CatsArchitecture
-/* nothing is needed */
-#endif
+# if !defined(Sparc64Architecture)
+#  define BuildXF86DGA		NO
+#  define BuildXInputExt	NO
+# else /* Sparc64Architecture */
+#  define BuildXF86DGA		YES
+#  define BuildXInputExt	YES
+# endif /* !defined(Sparc64Architecture) */
+# include <xfree86.cf>
 
-/*
- * Definition for compiling on VAX machines
- */
-#ifdef VaxArchitecture
-#define BuildServer	NO
-#endif
+#endif /* defined(SparcArchitecture) */
 
 /* 
  * General settings for all platforms 
@@ -740,10 +771,3 @@
 #ifndef UseSeparateConfDir
 #define UseSeparateConfDir NO	/* We don't want appdefs in "/etc/X11". */
 #endif
-
-#if defined(NetBSDArchitecture) && \
-     ((OSMajorVersion > 1) || \
-      (OSMajorVersion == 1 && OSMinorVersion > 3))
-#define HasDevRandom		YES
-#define RandomDeviceFile	/dev/urandom
-#endif