--- Makefile.am
+++ Makefile.am
@@ -28,6 +28,5 @@
              include \
              tools \
              clients \
-             doc \
-             demos
-AUTOMAKE_OPTIONS = 1.4
+             doc
+AUTOMAKE_OPTIONS = 1.4 foreign
--- clients/uil/Makefile.am
+++ clients/uil/Makefile.am
@@ -6,7 +6,7 @@
 #
 bin_PROGRAMS = uil
 
-LDFLAGS = -version-info @CURRENT@:@REVISION@:@AGE@
+libUil_la_LDFLAGS = -version-info @CURRENT@:@REVISION@:@AGE@
 
 UilParser.lo: UilParser.c
 	$(LTCOMPILE) -DCALLABLE -c UilParser.c
@@ -42,7 +42,7 @@
 		UilLstMac.c	UilSemVal.c	UilSemCSet.c	UilDB.c
 
 SRCS =		$(COMMON_SRC)
-SRCS2 =		$(COMMON_SRC)	UilMain.c
+SRCS2 =		UilMain.c
 
 HEADERS_1 = 	Uil.h		UilSymGl.h	UilSymDef.h \
 		UilDef.h	XmAppl.uil
@@ -72,6 +72,7 @@
 	$(LN_S) $(srcdir)/../../tools/wml/UilDBDef.h UilDBDef.h
 
 uil_SOURCES = $(SRCS2)
+uil_LDADD += libUil.la
 
 if MessageCatalog
 
--- config/cf/Imake.cf
+++ config/cf/Imake.cf
@@ -570,6 +570,9 @@
 # ifdef i386
 #  define i386Architecture
 #  undef i386
+#  undef i486
+#  undef i586
+#  undef i686
 # endif /* i386 */
 # ifdef __i386__
 #  ifndef i386Architecture
@@ -593,6 +596,32 @@
 #  define PowerPCArchitecture
 #  undef powerpc
 # 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
@@ -607,6 +636,10 @@
 #     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))
--- 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/cf/linux.cf
+++ config/cf/linux.cf
@@ -41,8 +41,9 @@
 /* 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)
+    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)
+#  define HaveLib64 YES
+# else
+#  define HaveLib64 NO
+# endif
+#endif
+
 #define MkdirHierCmd		mkdir -p
+
+#ifndef HaveLib64
+# if defined (x86_64Architecture) || defined (s390xArchitecture)
+#  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,14 @@
 #define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
 #endif /* PowerPCArchitecture */
 
+#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 +339,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 +416,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>
--- 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
--- configure.in
+++ configure.in
@@ -53,12 +53,13 @@
 save_CFLAGS="$CFLAGS"
 LIBS="$X_LIBS $LIBS"
 CFLAGS="$X_CFLAGS $CFLAGS"
-AC_CHECK_HEADERS(X11/Xmu/Editres.h,
-AC_CHECK_LIB(Xmu, _XEditResCheckMessages,
+AC_CHECK_HEADERS(X11/Xmu/Editres.h, [
+AC_CHECK_LIB(Xmu, _XEditResCheckMessages, [
 X_XMU=-lXmu
-AC_DEFINE(HAVE_LIBXMU)
-, X_XMU="", -lXt -lX11)
-)
+AC_DEFINE(HAVE_LIBXMU, 1, [ ])
+], X_XMU="", -lXt -lX11)
+], [],
+[#include <X11/Intrinsic.h>])
 AC_SUBST(X_XMU)
 LIBS="$save_LIBS"
 CFLAGS="$save_CFLAGS"
@@ -140,8 +141,8 @@
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/malloc.h strings.h sys/file.h sys/time.h unistd.h wchar.h)
-AC_CHECK_HEADERS(wctype.h, AC_DEFINE(HAS_WIDECHAR_FUNCTIONS))
-AC_CHECK_HEADER(langinfo.h,,AC_DEFINE(CSRG_BASED))
+AC_CHECK_HEADERS(wctype.h, [AC_DEFINE(HAS_WIDECHAR_FUNCTIONS, 1, [Define if wctype.h is available])])
+AC_CHECK_HEADER(langinfo.h,,[AC_DEFINE(CSRG_BASED, 1, [ ])])
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
@@ -164,23 +165,23 @@
 AC_FUNC_VPRINTF
 AM_FUNC_VOID_SPRINTF
 AC_CHECK_FUNCS(wcslen wcscpy wcsncpy wcschr wcscat wcsncat getcwd gettimeofday mkdir re_comp regcmp select strcspn strerror strstr strtod strtol uname)
-AC_CHECK_FUNCS(strdup,,AC_DEFINE(NEED_STRDUP))
-AC_CHECK_FUNCS(strcasecmp,,AC_DEFINE(NEED_STRCASECMP))
-AC_CHECK_FUNCS(putenv,,AC_DEFINE(NO_PUTENV))
-AC_CHECK_FUNCS(regcomp,,AC_DEFINE(NO_REGCOMP))
-AC_CHECK_FUNCS(memmove,,AC_DEFINE(NO_MEMMOVE))
+AC_CHECK_FUNCS(strdup,,AC_DEFINE(NEED_STRDUP, 1, [ ]))
+AC_CHECK_FUNCS(strcasecmp,,AC_DEFINE(NEED_STRCASECMP, 1, [ ]))
+AC_CHECK_FUNCS(putenv,,AC_DEFINE(NO_PUTENV, 1, [ ]))
+AC_CHECK_FUNCS(regcomp,,AC_DEFINE(NO_REGCOMP, 1, [ ]))
+AC_CHECK_FUNCS(memmove,,AC_DEFINE(NO_MEMMOVE, 1, [ ]))
 
 AC_ARG_ENABLE(message-catalog, [  --enable-message-catalog
                           Enable building of the message catalog (default=no)])
 if test "$enable_message_catalog" != "yes"
 then
-    AC_DEFINE(NO_MESSAGE_CATALOG)
+    AC_DEFINE(NO_MESSAGE_CATALOG, 1, [define to avoid building the message catalog])
 fi
 AM_CONDITIONAL(MessageCatalog, test x$enable_message_catalog = xyes)
 
 if test -f $srcdir/lib/Xm/SlideC.h
 then
-    AC_DEFINE(HAVE_SLIDEC_H)
+    AC_DEFINE(HAVE_SLIDEC_H, 1, [ ])
     SLIDE_DIST="SlideC.c SlideC.h SlideCP.h"
 fi
 AC_SUBST(SLIDE_DIST)
@@ -190,7 +191,7 @@
 then
     CFLAGS="$CFLAGS -Wall -Wno-unused -Wno-comment"
 fi
-AC_DEFINE(NO_OL_COMPAT)
+AC_DEFINE(NO_OL_COMPAT, 1, [Define to disable OpenLook compatibility])
 
 CDE_INSTALLATION_TOP="\${prefix}/dt"
 AC_SUBST(CDE_INSTALLATION_TOP)
@@ -198,13 +199,13 @@
 CDE_CONFIGURATION_TOP="\${prefix}/etc/dt"
 AC_SUBST(CDE_CONFIGURATION_TOP)
 
-LIBDIR="${libdir}/X11"
+LIBDIR="${datadir}/X11"
 AC_SUBST(LIBDIR)
 
 INCDIR="${includedir}/X11"
 AC_SUBST(INCDIR)
 
-XMBINDDIR_FALLBACK="${libdir}/X11/bindings"
+XMBINDDIR_FALLBACK="${datadir}/X11/bindings"
 AC_SUBST(XMBINDDIR_FALLBACK)
 
 case "$target_os" in
--- demos/programs/Column/column.c
+++ demos/programs/Column/column.c
@@ -4,6 +4,7 @@
 #include <Xm/XmAll.h>
 #include <Xm/Column.h>
 #include <Xm/DataF.h>
+#include <Xm/TabStack.h>
 
 
 #define phone_width 16
--- demos/programs/DropDown/dropdown.c
+++ demos/programs/DropDown/dropdown.c
@@ -3,6 +3,7 @@
 #include <Xm/Xm.h>
 #include <Xm/DropDown.h>
 #include <Xm/XmAll.h>
+#include <Xm/TabStack.h>
 
 static int done = 0;
 
--- 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/Makefile.am
+++ lib/Mrm/Makefile.am
@@ -8,7 +8,7 @@
 
 libMrm_la_LIBADD = ../Xm/libXm.la ${X_LIBS} -lXt ${X_PRE_LIBS} -lX11 ${X_EXTRA_LIBS}
 
-LDFLAGS = -version-info @CURRENT@:@REVISION@:@AGE@
+libMrm_la_LDFLAGS = -version-info @CURRENT@:@REVISION@:@AGE@
 
 lib_LTLIBRARIES = libMrm.la
 
--- 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/EditresCom.c
+++ lib/Xm/EditresCom.c
@@ -1772,7 +1772,7 @@
     XtFree((char *)widget_list);
 }
 
-#if 0
+#if 1
 /************************************************************
  *
  * All of the following routines are public.
@@ -1923,7 +1923,7 @@
  *	Returns: TRUE if sucessful.
  */
 
-Boolean
+Bool
 _XEditResGet8(stream, val)
 ProtocolStream * stream;
 unsigned char * val;
@@ -1943,7 +1943,7 @@
  *	Returns: TRUE if sucessful.
  */
 
-Boolean
+Bool
 _XEditResGet16(stream, val)
 ProtocolStream * stream;
 unsigned short * val;
@@ -1964,7 +1964,7 @@
  *	Returns: TRUE if sucessful.
  */
 
-Boolean
+Bool
 _XEditResGetSigned16(stream, val)
 ProtocolStream * stream;
 short * val;
@@ -1993,7 +1993,7 @@
  *	Returns: TRUE if sucessful.
  */
 
-Boolean
+Bool
 _XEditResGet32(stream, val)
 ProtocolStream * stream;
 unsigned long * val;
@@ -2015,7 +2015,7 @@
  *	Returns: True if retrieval was successful.
  */
 
-Boolean
+Bool
 _XEditResGetString8(stream, str)
 ProtocolStream * stream;
 char ** str;
@@ -2048,7 +2048,7 @@
  *	Returns: True if retrieval was successful.
  */
 
-Boolean
+Bool
 _XEditResGetWidgetInfo(stream, info)
 ProtocolStream * stream;
 WidgetInfo * info;
--- lib/Xm/FontS.c
+++ lib/Xm/FontS.c
@@ -2865,7 +2865,7 @@
 
     XmFontS_use_scaling(fsw) = info->set;
     if (!info->set) {
-	Boolean map_bad = (map = SizeMapping(cf->point_size) == 0);
+	Boolean map_bad = (map = SizeMapping(cf->point_size)) == 0;
 	Boolean bad_75 = (CheckFlag(XmFontS_user_state(fsw), DPI_75) && 
 			  !CheckLongFlag(family->sizes_75, map));
 	Boolean bad_100 = (CheckFlag(XmFontS_user_state(fsw), DPI_100) && 
--- lib/Xm/Makefile.am
+++ lib/Xm/Makefile.am
@@ -9,7 +9,7 @@
            ${X_CFLAGS}
 xmdir = $(includedir)/Xm
 
-LDFLAGS = -version-info @CURRENT@:@REVISION@:@AGE@
+libXm_la_LDFLAGS = -version-info @CURRENT@:@REVISION@:@AGE@
 
 lib_LTLIBRARIES = libXm.la
 
--- 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
