--- config/cf/Imake.cf
+++ config/cf/Imake.cf
@@ -555,6 +555,9 @@
 # ifdef i386
 #  define i386Architecture
 #  undef i386
+#  undef i486
+#  undef i586
+#  undef i686
 # endif /* i386 */
 # ifdef __i386__
 #  ifndef i386Architecture
@@ -578,6 +581,36 @@
 #  define PowerPCArchitecture
 #  undef powerpc
 # endif
+# if ( defined(__powerpc64__) || defined(__ppc64__) )
+#  define PowerPC64Architecture
+#  undef powerpc64
+# endif
+# ifdef __s390__
+#  define s390Architecture
+#  undef __s390__
+# endif
+# ifdef __s390x__
+#  define s390xArchitecture
+#  undef __s390x__
+# endif
+# ifdef __x86_64__
+#  define x86_64Architecture
+#  undef __x86_64__
+# endif
+# ifdef mips
+#  define MipsArchitecture
+#  undef mips
+# endif
+# ifdef sparc
+#  define SparcArchitecture
+#  undef sparc
+# endif
+# ifdef __sparc__
+#  ifndef SparcArchitecture
+#   define SparcArchitecture
+#  endif
+#  undef __sparc__
+# endif
 # if defined(arm) || defined(__arm__)
 #   define ArmArchitecture
 #   undef arm
@@ -592,9 +625,13 @@
 #     undef __ARM_ARCH_3__
 #   endif
 # endif
+# ifdef __ia64__
+#  define ia64Architecture
+#  undef __ia64__
+# endif /* __ia64__ */
 #endif /* linux */
 
-#if (defined(__Lynx__) || defined(Lynx)) && (defined(i386) || defined(__i386__) || defined(__x86__) || defined(__powerpc__) || defined(__sparc__) || defined(sparc))
+#if (defined(__Lynx__) || defined(Lynx)) && (defined(i386) || defined(__i386__) || defined(__x86__) || defined(__powerpc__) || defined(powerpc64) || defined(__ppc64__)  || defined(__powerpc64__) || defined(__sparc__) || defined(sparc))
 # define MacroIncludeFile <lynx.cf>
 # define MacroFile lynx.cf
 # define LynxOSArchitecture
@@ -611,6 +648,10 @@
 #  define ppcArchitecture
 #  undef __powerpc__
 # endif
+# ifdef __powerpc64__
+#  define PowerPC64Architecture
+#  undef __powerpc64__
+# endif
 # if defined(sparc) || defined(__sparc__)
 #  define SparcArchitecture
 #  undef sparc
@@ -709,6 +750,10 @@
 # define PPCArchitecture
 # undef PPC
 #else
+#ifdef PPC64
+# define PowerPC64Architecture
+# undef PPC64
+#else
 #ifdef MIPS
 # define mipsArchitecture
 # undef MIPS
@@ -719,6 +764,7 @@
 #endif
 #endif
 #endif
+#endif
 #endif /* QNX/Neutrino */
 
 #ifndef MacroIncludeFile
--- config/cf/Imake.tmpl
+++ config/cf/Imake.tmpl
@@ -502,14 +502,18 @@
 #define	DefaultUsrBin /usr/bin
 #endif
 
+#ifndef LibDirName
+# define LibDirName lib
+#endif
+
 #ifndef UsrLibDir
 #ifdef ProjectRoot
-#define UsrLibDir Concat(ProjectRoot,/lib)
+#define UsrLibDir Concat3(ProjectRoot,/,LibDirName)
 #ifndef AlternateUsrLibDir
 #define AlternateUsrLibDir YES
 #endif
 #else
-#define UsrLibDir /usr/lib
+#define UsrLibDir Concat(/usr/,LibDirName)
 #ifndef AlternateUsrLibDir
 #define AlternateUsrLibDir NO
 #endif
--- config/imake/imakemdep.h
+++ config/imake/imakemdep.h
@@ -333,6 +333,18 @@
 # ifdef __i386__
 	"-D__i386__",
 # endif
+# ifdef __ia64__
+	"-D__ia64__",
+# endif
+# ifdef __s390__
+	"-D__s390__",
+# endif
+# ifdef __s390x__
+	"-D__s390x__",
+# endif
+# ifdef __x86_64__
+	"-D__x86_64__",
+# endif
 # ifdef __sparc__
 	"-D__sparc__",
 # endif
@@ -936,6 +948,18 @@
 #ifdef __alpha__
 	{"__alpha__", "1"},
 #endif
+#ifdef __ia64__
+	{"__ia64__", "1"},
+#endif
+#ifdef __x86_64__
+	{"__x86_64__", "1"},
+#endif
+#ifdef __s390__
+	{"__s390__", "1"},
+#endif
+#ifdef __s390x__
+	{"__s390x__", "1"},
+#endif
 #ifdef __DECC
 	{"__DECC",  "1"},
 #endif
--- demos/programs/getsubres/getsubres.c
+++ demos/programs/getsubres/getsubres.c
@@ -384,7 +384,8 @@
 }
 
 static String fallbacks[] = {
-    "*help_manager.helpFile: getsubres"
+    "*help_manager.helpFile: getsubres",
+    NULL
 };
 
 #define APP_CLASS "XmdGetsubres"
--- lib/Mrm/MrmIheader.c
+++ lib/Mrm/MrmIheader.c
@@ -226,12 +226,7 @@
 			    file_id, NULL, MrmNOT_VALID);
     }
 
-  {
-    /* sscanf() may call ungetc(), which would write the XmConst string. */
-    char buf[XtNumber(idb__database_version) + 1];
-    strcpy(buf, idb__database_version);
-    sscanf(buf, "URM %d.%d", &db_major, &db_minor);
-  }
+  sscanf(idb__database_version, "URM %d.%d", &db_major, &db_minor);
     
   if ((file_major > db_major) ||
       ((file_major == db_major) && (file_minor > db_minor)))
--- lib/Mrm/MrmItop.c
+++ lib/Mrm/MrmItop.c
@@ -642,10 +642,12 @@
    *  Local variables
    */
   Cardinal	result ;		/* function results */
+  IDBResource resource_id;
 
   if ( (result=Idb__FIL_Valid((IDBFile)file_id)) != MrmSUCCESS ) return result ;
   result = Idb__RID_NextRID ((IDBFile)file_id, 
-			     (IDBResource *)resource_id_return) ;
+			     &resource_id) ;
+  *resource_id_return = resource_id;
   return result ;
 
 }
--- lib/Xm/Resolve.c
+++ lib/Xm/Resolve.c
@@ -149,11 +149,11 @@
     *  Update the part size value (initially, it is the size of this part)
     */
    w_class->core_class.widget_size =
-       _ALIGN(w_class->core_class.widget_size) + super->core_class.widget_size;
+       _ALIGN(w_class->core_class.widget_size) + _ALIGN(super->core_class.widget_size);
    if (cc && scc)
        cc->constraint_class.constraint_size =
 	   _ALIGN(cc->constraint_class.constraint_size) +
-	       scc->constraint_class.constraint_size;
+	       _ALIGN(scc->constraint_class.constraint_size);
 
    /*
     *  Count the number of superclasses and allocate the offset record(s)
@@ -186,7 +186,7 @@
 	    scc = (ConstraintWidgetClass)(scc->core_class.superclass), i--)
 	   if (IsConstraintClass((WidgetClass)scc))
 	       (*constraint_offset)[i] = 
-		   scc->constraint_class.constraint_size;
+		   _ALIGN(scc->constraint_class.constraint_size);
 	   else
 	       (*constraint_offset)[i] = 0;
 	
--- lib/Xm/XmRenderT.c
+++ lib/Xm/XmRenderT.c
@@ -1461,6 +1461,7 @@
   else {
     union {
       long	longval;
+      int	intval;
       short	shortval;
       char	charval;
       char*	charptr;
@@ -1468,6 +1469,7 @@
     } u;
     char *p = (char*)&u;
     if      (size == sizeof(long))	    u.longval = (long)src;
+    else if (size == sizeof(int))	    u.longval = (int)src;
     else if (size == sizeof(short))	    u.shortval = (short)src;
     else if (size == sizeof(char))	    u.charval = (char)src;
     else if (size == sizeof(XtPointer))	    u.ptr = (XtPointer)src;
@@ -1486,6 +1488,7 @@
      * but preserve for compatibility as long as arglist contains NULL.
      */
     if	    (size == sizeof(long))	   *dst = (XtArgVal)*(long*)src;
+    else if (size == sizeof(int))	   *dst = (XtArgVal)*(int*)src;
     else if (size == sizeof(short))    *dst = (XtArgVal)*(short*)src;
     else if (size == sizeof(char))	   *dst = (XtArgVal)*(char*)src;
     else if (size == sizeof(XtPointer)) *dst = (XtArgVal)*(XtPointer*)src;
@@ -1496,6 +1499,7 @@
   else {
     /* proper GetValues semantics: argval is pointer to destination */
     if	(size == sizeof(long))	   *((long*)*dst) = *(long*)src;
+    else if (size == sizeof(int))    *((int*)*dst) = *(int*)src;
     else if (size == sizeof(short))    *((short*)*dst) = *(short*)src;
     else if (size == sizeof(char))	   *((char*)*dst) = *(char*)src;
     else if (size == sizeof(XtPointer)) *((XtPointer*)*dst) = *(XtPointer*)src;
--- localized/util/mkcatdefs.c
+++ localized/util/mkcatdefs.c
@@ -76,9 +76,8 @@
 #include <limits.h>
 #include <string.h>
 
-#ifndef NL_TEXTMAX
+#undef NL_TEXTMAX
 #define NL_TEXTMAX 8192
-#endif
 
 #ifndef PATH_MAX
 #define PATH_MAX 1024
--- config/cf/linux.cf
+++ config/cf/linux.cf
@@ -40,9 +40,10 @@
 
 /* Set some defaults for the Default* values in case imake doesn't find them */
 #ifndef DefaultLinuxCLibMajorVersion
-#if defined(AlphaArchitecture) || defined(PowerPCArchitecture) || \
-    defined(SparcArchitecture) || defined(ArmArchitecure) || \
-    defined(i386Architecture)
+#if defined(AlphaArchitecture) || defined(PowerPC64Architecture) || defined(PowerPCArchitecture) || \
+    defined(SparcArchitecture) || defined(ArmArchitecure) || defined(MipsArchitecure) || \
+    defined(i386Architecture)  || defined(ia64Architecture) || defined(s390Architecture) || \
+    defined(s390xArchitecture) || defined(x86_64Architecture)
 #define DefaultLinuxCLibMajorVersion	6
 #else
 #define DefaultLinuxCLibMajorVersion	5
@@ -159,7 +160,24 @@
 #define UseStaticTermcapLib	NO
 #endif
 
+#ifndef HaveLib64
+# if defined (x86_64Architecture) || defined (s390xArchitecture) || defined (PowerPC64Architecture)
+#  define HaveLib64 YES
+# else
+#  define HaveLib64 NO
+# endif
+#endif
+
 #define MkdirHierCmd		mkdir -p
+
+#ifndef HaveLib64
+# if defined (x86_64Architecture) || defined (s390xArchitecture) || defined (PowerPC64Architecture)
+#  define HaveLib64 YES
+# else
+#  define HaveLib64 NO
+# endif
+#endif
+
 #if LinuxElfDefault
 #if UseElfFormat
 #define CcCmd			gcc
@@ -234,7 +252,7 @@
 #endif
 #define CppCmd			/lib/cpp
 #ifdef USE_BYACC
-#define YaccCmd			byacc
+#define YaccCmd			yacc
 #else
 #define YaccCmd			bison -y
 #endif
@@ -261,6 +279,35 @@
 #define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines -D_XSERVER64
 #endif /* AlphaArchitecture */
 
+#ifdef s390xArchitecture
+#define DefaultCCOptions	-fsigned-char
+#define OptimizedCDebugFlags	-O2
+#define LinuxMachineDefines	-D__s390x__
+#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME -DPART_NET
+#define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines -D_XSERVER64
+#else
+#ifdef s390Architecture
+#define OptimizedCDebugFlags	-O2
+#define LinuxMachineDefines	-D__s390__
+#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME -DPART_NET
+#define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+#endif /* s390Architecture */
+#endif /* s390xArchitecture */
+
+#ifdef ia64Architecture
+#define OptimizedCDebugFlags  -O2
+#define LinuxMachineDefines   -D__ia64__
+#define ServerOSDefines       XFree86ServerOSDefines -DDDXTIME -DPART_NET
+#define ServerExtraDefines    -DGCCUSESGAS XFree86ServerDefines -D_XSERVER64
+#endif /* ia64Architecture */
+
+#ifdef x86_64Architecture
+#define OptimizedCDebugFlags  -O2
+#define LinuxMachineDefines   -D__x86_64__
+#define ServerOSDefines       XFree86ServerOSDefines -DDDXTIME -DPART_NET
+#define ServerExtraDefines    -DGCCUSESGAS XFree86ServerDefines -D_XSERVER64
+#endif /* ia64Architecture */
+
 #ifdef Mc68020Architecture
 #define OptimizedCDebugFlags	-O2
 #define LinuxMachineDefines 	-D__mc68000__
@@ -276,6 +323,22 @@
 #define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
 #endif /* PowerPCArchitecture */
 
+#ifdef PowerPC64Architecture
+#define DefaultCCOptions        -fsigned-char
+#define OptimizedCDebugFlags	-O2
+#define LinuxMachineDefines 	-D__powerpc64__
+#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME -DPART_NET
+#define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+#endif /* PowerPC64Architecture */
+
+#ifdef MipsArchitecture
+#define DefaultCCOptions        -fsigned-char
+#define OptimizedCDebugFlags	-O2 -mips2
+#define LinuxMachineDefines 	-D__mips__
+#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME -DPART_NET
+#define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+#endif /* MipsArchitecture */
+
 #ifdef ArmArchitecture
 #define DefaultCCOptions        -fsigned-char
 #define OptimizedCDebugFlags   -O2
@@ -284,6 +347,19 @@
 #define ServerExtraDefines     -DGCCUSESGAS XFree86ServerDefines
 #endif /* Arm */
 
+#ifdef SparcArchitecture
+#define OptimizedCDebugFlags    -O2
+#define LinuxMachineDefines     -D__sparc__
+#define ServerOSDefines         XFree86ServerOSDefines -DDDXTIME -DPART_NET
+#define ServerExtraDefines      -DGCCUSESGAS XFree86ServerDefines
+#define AsVISOption -Av9a
+#ifdef Sparc64Architecture
+#define AsOutputArchSize 64
+#else
+#define AsOutputArchSize 32
+#endif
+#endif
+
 #define StandardDefines		-Dlinux LinuxMachineDefines LinuxSourceDefines
 
 #ifndef TermcapLibrary
@@ -348,5 +424,11 @@
 #define MakeNamedTargetSubdir(dir,flags,subname)\
 	$(MAKE) -C dir $(MFLAGS) $(PARALLELMFLAGS) flags subname
 
+#if HaveLib64
+# ifndef LibDirName
+#  define LibDirName lib64
+# endif
+#endif
+
 #include <lnxLib.rules>
 #include <xfree86.cf>
--- clients/mwm/Imakefile
+++ clients/mwm/Imakefile
@@ -217,7 +217,6 @@
 CppFileTarget(sys.mwmrc,sys.mwmrc.src,$(LOCAL_CPP_DEFINES),)
 */
 
-InstallNonExecFile(system.mwmrc,$(XPROJECTROOT)/lib/X11)
 InstallAppDefaults(Mwm)
 
 MessageCatalogRule(Mwm)
