diff -Nurd -x'*~' xpaint-2.9.9.1.orig/Makefile.am xpaint-2.9.9.1/Makefile.am
--- xpaint-2.9.9.1.orig/Makefile.am	2012-03-01 15:12:56.000000000 -0500
+++ xpaint-2.9.9.1/Makefile.am	2012-06-11 01:17:36.000000000 -0400
@@ -3,7 +3,7 @@
 ## Local Configuration arguments
 BINDIR = $(prefix)/bin
 SHAREDIR = $(prefix)/share/xpaint
-XAPPLOADDIR = /etc/X11/app-defaults
+XAPPLOADDIR = $(prefix)/etc/X11/app-defaults
 
 ## Printing system defaults
 PRINT_COMMAND = lpr
@@ -39,7 +39,7 @@
   -DXPAINT_VERSION=\"$(PACKAGE_VERSION)\" \
   -DLPCCMD=\""$(LPCCMD)"\"
 
-XAWLIB_DEFINES = -DXAW3D -DXAW3DG -DXAW3DXFT `pkg-config xaw3d  --cflags`
+XAWLIB_DEFINES = -DXAW3D -DXAW3DG -DXAW3DXFT
 
 ## CDEBUGFLAGS =
 #define PassCDebugFlags CDEBUGFLAGS='$(CDEBUGFLAGS)'
@@ -48,13 +48,13 @@
 
 bin_PROGRAMS  = xpaint
 dist_man_MANS = xpaint.1 imgmerge.1
-AM_CFLAGS   = @X_CFLAGS@ @SPECIAL_CFLAGS@ $(xpaint_DEFINES)
-BUILT_SOURCES = version.h DefaultRC.txt.h messages.h XPaint.ad.h xpaint.1 \
-		rw/.libs/librw.a
+AM_CPPFLAGS   = @XAW3D_CFLAGS@ @X_CFLAGS@ $(xpaint_DEFINES)
+BUILT_SOURCES = version.h DefaultRC.txt.h messages.h XPaint.ad.h xpaint.1
 AM_YFLAGS     = -d
 CLEANFILES    = preproc substads \
 	version.h DefaultRC.txt.h messages.h XPaint.ad.h xpaint.1
 EXTRA_DIST    = 
+ACLOCAL_AMFLAGS = -I m4
 
 BASE_HDRS = bitmap.h color.h crc32.h \
 	Colormap.h ColormapP.h graphic.h hash.h image.h \
@@ -74,7 +74,7 @@
 
 xpaint_SOURCES = $(BASE_HDRS) $(BASE_SRCS)
 
-xpaint_LDADD = rw/.libs/librw.a @X_LIBS@ $(X_LIBS_EXTRA)
+xpaint_LDADD = rw/librw.la @XAW3D_LIBS@ @X_LIBS@
 
 docs: INSTALL README TODO ChangeLog
 .PHONY:
@@ -111,8 +111,7 @@
 xpaint.1: xpaint.1.in version.h
 	./substads -single xpaint.1.in xpaint.1 XPAINT_VERSION $(PACKAGE_VERSION)
 
-rw/.libs/librw.a:
-	cd rw ; ./configure --prefix=$(prefix) ; make
+SUBDIRS = rw
 
 install-exec-hook:
 	mkdir -p $(DESTDIR)$(BINDIR)
@@ -138,12 +137,9 @@
 	mkdir -p $(DESTDIR)$(SHAREDIR)/messages
 	cd share/messages ; $(RM) -f *~ ; cp -f Messages* $(DESTDIR)$(SHAREDIR)/messages
 	chmod -R a+r $(DESTDIR)$(SHAREDIR)/
-	cd util ; make ; make install DESTDIR=$(DESTDIR)$
 
 clean-local:
-	cd rw ; make clean
 	cd util ; make clean
 
 distclean-local:
-	cd rw ; make distclean
 	cd util ; make distclean
\ No newline at end of file
diff -Nurd -x'*~' xpaint-2.9.9.1.orig/configure.ac xpaint-2.9.9.1/configure.ac
--- xpaint-2.9.9.1.orig/configure.ac	2012-03-01 15:12:52.000000000 -0500
+++ xpaint-2.9.9.1/configure.ac	2012-06-11 00:07:48.000000000 -0400
@@ -13,6 +13,7 @@
 
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([-Wall -Werror])
+LT_INIT
 
 AC_LANG_C
 
@@ -28,61 +29,27 @@
 AC_TYPE_UINT32_T
 AC_TYPE_UINT64_T
 
-CFLAGS="-I/usr/include -I/usr/include/X11"
+AC_MSG_CHECKING([for sys_errlist])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+    [AC_INCLUDES_DEFAULT],
+    [char *foo = sys_errlist@<:@0@:>@;]
+  )],
+  [AC_MSG_RESULT([yes])
+   AC_DEFINE(SYS_ERRLIST_DEFINED, 1, [Define if your system headers declare a sys_errlist variable.])],
+  AC_MSG_RESULT([no])
+)
+
 LIBS="$LIBS -lm"
 echo "VERSION = $VERSION" > .version
 
 dnl check X11
-AC_CHECK_LIB([X11], [XOpenDisplay], have_x11="yes")
-if test x"$have_x11" = xyes; then
-  AC_SUBST([X_LIBS], ["-lXmu -lXt -lSM -lICE -lXext -lX11 -lXpm -ldl -rdynamic"])
-  AC_SUBST([X_CFLAGS], ["-I/usr/include/X11"])
-else
-  echo "X11 libraries not installed !"
-  exit 1
-fi
-
-dnl check Xft support
-AC_MSG_CHECKING([checking Xft support])
-AC_ARG_ENABLE(
-  xft,
-[  --enable-xft        Xft support [default=yes]],
-	if test x$enableval = "xyes"; then
-		AC_MSG_RESULT([yes])
-		AC_CHECK_LIB(Xft, XftFontOpen,
-			AC_DEFINE(HAVE_XFT, 1, "Xft support")
-			LIBS="$LIBS -lXft -lfreetype -lfontconfig"
-			XFT=true)
-		AC_CHECK_LIB(freetype, FT_Init_FreeType,
-			LIBS="$LIBS -lfreetype -lfontconfig")
-	else
-		AC_MSG_RESULT([no])
-	fi,
-	AC_MSG_RESULT([yes])
-	AC_CHECK_LIB(Xft, XftFontOpen,
-		AC_DEFINE(HAVE_XFT,, "Xft support")
-		LIBS="$LIBS -lXft"
-		XFT=true)
-	AC_CHECK_LIB(freetype, FT_Init_FreeType,
-		LIBS="$LIBS -lfreetype -lfontconfig")
-)
+PKG_CHECK_MODULES([X], [xmu xt xext x11 xpm])
+X_LIBS="$X_LIBS -lSM -lICE"
 
 dnl checking for libXaw3d, version >= 1.6.2
-AC_CHECK_HEADER([X11/Xaw3d/Box.h],
-  [AC_CHECK_LIB([Xaw3d], [Xaw3dXftDrawString],
-    [AC_MSG_NOTICE([[Using libXaw3d for Athena Widgets.]])
-     AC_SUBST([X_LIBS_EXTRA], ["-lXaw3d"])],
-       AC_DEFINE(HAVE_XAW3DXFT)
-     [AC_MSG_ERROR([found Xaw3d headers but not libXaw3d version >= 1.6.2; try setting LDFLAGS.])],
-     [-lXft -lXmu -lXt -lSM -lICE -lXext -lX11 -lXpm $X_LIBS_EXTRA])],
-     exit 1
-)
+PKG_CHECK_MODULES([XAW3D], [xaw3d >= 1.6.2])
 
-dnl libz is required by libpng.
-AC_CHECK_HEADER([zlib.h], [],
-                [AC_MSG_ERROR([cannot find zlib.h; try setting CFLAGS.])])
-AC_CHECK_LIB([z], [zlibVersion], [],
-             [AC_MSG_ERROR([cannot find libz; try setting LDFLAGS.])])
+AC_CHECK_HEADERS([error.h])
 
 dnl libpng check
 AC_CHECK_HEADER(png.h, AC_DEFINE(HAVE_PNG_H,,[png.h needs to be included]))
@@ -236,16 +203,5 @@
  ])
 
 
-AC_MSG_CHECKING([location of freetype2 headers])
-AC_PREPROC_IFELSE(
-  [AC_LANG_PROGRAM([[#include <freetype/config/ftheader.h>]])],
-  [AC_MSG_RESULT([already in path])],
-  [AC_PREPROC_IFELSE(
-    [AC_LANG_PROGRAM([[#include </usr/include/freetype2/freetype/config/ftheader.h>]])],
-    [AC_MSG_RESULT([/usr/include/freetype2])
-     AC_SUBST([SPECIAL_CFLAGS], ["-I/usr/include/freetype2"])],
-    [AC_MSG_ERROR([cannot find freetype2 headers; try setting CFLAGS.])]
-  )]
-)
 
-AC_OUTPUT(Makefile)
+AC_OUTPUT([Makefile rw/Makefile])
diff -Nurd -x'*~' xpaint-2.9.9.1.orig/graphic.c xpaint-2.9.9.1/graphic.c
--- xpaint-2.9.9.1.orig/graphic.c	2012-03-01 08:51:26.000000000 -0500
+++ xpaint-2.9.9.1/graphic.c	2012-06-11 00:44:42.000000000 -0400
@@ -7345,16 +7345,16 @@
 **
  */
 
-void setWriteTextSensitive(Widget w, Boolean bool)
+void setWriteTextSensitive(Widget w, Boolean _bool)
 {
     WidgetList wlist;
     Widget ww;
     XtVaGetValues(w, XtNmenuwidgets, &wlist, NULL);
     if (wlist) {
         if ((ww=wlist[W_FONT_WRITE])) 
-            XtVaSetValues(ww, XtNsensitive, bool, NULL);
+            XtVaSetValues(ww, XtNsensitive, _bool, NULL);
         if ((ww=wlist[W_TOPMENU+W_FONT_WRITE]))
-            XtVaSetValues(ww, XtNsensitive, bool, NULL);
+            XtVaSetValues(ww, XtNsensitive, _bool, NULL);
     }
 }
 
diff -Nurd -x'*~' xpaint-2.9.9.1.orig/misc.h xpaint-2.9.9.1/misc.h
--- xpaint-2.9.9.1.orig/misc.h	2012-03-01 08:17:50.000000000 -0500
+++ xpaint-2.9.9.1/misc.h	2012-06-11 00:44:36.000000000 -0400
@@ -17,22 +17,6 @@
 #define USE_DRAND
 #endif
 
-#if defined(SVR4) || defined(__osf__)
-#define SHORT_RANGE
-#else
-#if !defined(__GLIBC__) & !defined(random) & !defined(__CYGWIN__)
-long random(void);
-#endif
-
-#if !defined(__VMS) & !defined(linux) & !defined(__EMX__) & !defined(__FreeBSD__) & !defined(__CYGWIN__) & !defined(__NetBSD__) & !defined(__DragonFly__) & !defined(__GLIBC__)
-#if defined(BSD4_4) || defined(HPArchitecture) || defined(SGIArchitecture) || defined(_AIX) || defined(_SCO_DS)
-void srandom(unsigned int);
-#else
-int srandom(unsigned int);
-#endif	/* BSD4_4 */
-#endif	/* linux */
-#endif
-
 #ifdef USE_DRAND
 #ifdef DECLARE_DRAND48
 extern double drand48();
@@ -193,7 +177,7 @@
 extern Boolean inCanvasPixmaps(Widget paint, Pixmap pix);
 extern void AddFileToGlobalList(char * file);
 extern void RemoveFileFromGlobalList(char * file);
-extern void setWriteTextSensitive(Widget w, Boolean bool);
+extern void setWriteTextSensitive(Widget w, Boolean _bool);
 extern void StdWriteText(Widget w, XtPointer infoArg, XtPointer junk);
 extern void StdOpenFile(Widget w, XtPointer paintArg, XtPointer junk);
 extern void 
diff -Nurd -x'*~' xpaint-2.9.9.1.orig/rw/Makefile.am xpaint-2.9.9.1/rw/Makefile.am
--- xpaint-2.9.9.1.orig/rw/Makefile.am	2012-03-01 15:15:11.000000000 -0500
+++ xpaint-2.9.9.1/rw/Makefile.am	2012-06-11 01:30:43.000000000 -0400
@@ -21,11 +21,11 @@
   -DSHAREDIR=\"$(SHAREDIR)\" \
   -DXPAINT_VERSION=\"$(PACKAGE_VERSION)\"
 
-XAWLIB_DEFINES = -DXAW3D -DXAW3DG -DXAW3DXFT `pkg-config xaw3d  --cflags` -I..
+XAWLIB_DEFINES = -DXAW3D -DXAW3DG -DXAW3DXFT -I..
 
 xpaint_DEFINES = $(ARCH_DEFINES) $(EXTRA_DEFINES) $(XAWLIB_DEFINES)
 
-AM_CFLAGS   = @X_CFLAGS@ @SPECIAL_CFLAGS@ $(xpaint_DEFINES)
+AM_CPPFLAGS   = @XAW3D_CFLAGS@ @X_CFLAGS@ $(xpaint_DEFINES)
 AM_YFLAGS     = -d
 CLEANFILES    = 
 EXTRA_DIST    = 
@@ -39,9 +39,8 @@
 	readWriteSGI.c readWriteTGA.c readWriteTIFF.c readWriteXBM.c \
 	readWriteXPM.c readWriteXWD.c rwTable.c
 
-lib_LTLIBRARIES = librw.la
+noinst_LTLIBRARIES = librw.la
 librw_la_SOURCES = ${BASE_HDRS} ${BASE_SRCS}
-librw_la_LIBADD = @X_LIBS@ $(X_LIBS_EXTRA)
-ACLOCAL_AMFLAGS = -I m4
+librw_la_LIBADD = @X_LIBS@
 
 .PHONY:
diff -Nurd -x'*~' xpaint-2.9.9.1.orig/rw/readWriteICO.c xpaint-2.9.9.1/rw/readWriteICO.c
--- xpaint-2.9.9.1.orig/rw/readWriteICO.c	2010-08-02 12:41:07.000000000 -0400
+++ xpaint-2.9.9.1/rw/readWriteICO.c	2012-06-09 17:37:31.000000000 -0400
@@ -34,7 +34,9 @@
 #include <ctype.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef HAVE_ERROR_H
 #include <error.h>
+#endif
 #include <errno.h>
 #include <getopt.h>
 
diff -Nurd -x'*~' xpaint-2.9.9.1.orig/rw/readWritePNG.c xpaint-2.9.9.1/rw/readWritePNG.c
--- xpaint-2.9.9.1.orig/rw/readWritePNG.c	2012-02-05 08:09:01.000000000 -0500
+++ xpaint-2.9.9.1/rw/readWritePNG.c	2012-06-10 14:04:46.000000000 -0400
@@ -9,14 +9,13 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <png.h>
+#include <X11/Xlib.h>
+#include <X11/Intrinsic.h>
 
-typedef char *String;
 #include <messages.h>
 #include <image.h>
 #include "rwTable.h"
 
-#include <X11/Xlib.h>
-#include <X11/Intrinsic.h>
 #include "xpaint.h"
 #include "../version.h"
 
