From 7a73080d871042028ba84cf0f36731f5959d6265 Mon Sep 17 00:00:00 2001
From: Arun Persaud <arun@nubati.net>
Date: Wed, 7 Nov 2012 22:14:20 -0800
Subject: [PATCH] fix configure script for --with-Xaw and --with-gtk

made Xaw the default and included xaw or gtk sources as extras
in case the other frontend is selected for make distcheck
---
 Makefile.am  |   41 ++++++++++++++++++++---------------------
 configure.ac |   14 ++++++++------
 2 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 96aebba..c388b7e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,19 +9,29 @@ else
 endif
 
 ### define sources for the front-end and backend
-
-GTKsources = gtk/xboard.c  gtk/xboard.h \
+GTKsources = gtk/xboard.c    gtk/xboard.h \
              gtk/xoptions.c  gtk/xtimer.c \
              gtk/xengineoutput.c
 
-Xsources   = xaw/xboard.c xaw/xboard.h \
-             xaw/xengineoutput.c \
+Xsources   = xaw/xboard.c    xaw/xboard.h    \
+             xaw/xengineoutput.c             \
              xaw/xgamelist.c xaw/xgamelist.h \
-             xaw/xhistory.c xaw/xhistory.h \
-             xaw/xoptions.c
-             
+             xaw/xhistory.c  xaw/xhistory.h  \
+             xaw/xoptions.c \
+             bitmaps/checkmark.bm bitmaps/icon_black.bm bitmaps/icon_white.bm
+
+if withGTK
+  FRONTENDsources = $(GTKsources)
+  FRONTENDextras = $(Xsources)
+  headers = -I gtk
+endif
+if withXaw
+  FRONTENDsources = $(Xsources)
+  FRONTENDextras = $(GTKsources)
+  headers = -I xaw -DX11
+endif
 
-backendsources = backend.c backend.h backendz.h \
+xboard_SOURCES = backend.c backend.h backendz.h \
 	 	 book.c \
 		 childio.c childio.h \
 	 	 common.h \
@@ -42,18 +52,7 @@ backendsources = backend.c backend.h backendz.h \
 		 history.c nhistory.c \
 	 	 menus.c menus.h \
 	 	 usounds.c usystem.c usystem.h \
-		 $(ZPY)
-
-### combine sources depending on front-end
-
-if withGTK
-  xboard_SOURCES = $(backendsources) $(GTKsources)
-  headers = -I gtk
-endif
-if withXaw
-  xboard_SOURCES = $(backendsources) $(Xsources)
-  headers = -I xaw -DX11
-endif
+		 $(ZPY) $(FRONTENDsources)
 
 ###
 
@@ -64,7 +63,7 @@ EXTRA_DIST = pixmaps shogi png sounds winboard \
 	xboard.texi gpl.texinfo texi2man texinfo.tex xboard.man xboard.desktop \
 	xboard-fen-viewer.desktop  xboard-pgn-viewer.desktop  xboard-tourney.desktop xboard.xml \
 	COPYRIGHT FAQ.html engine-intf.html ics-parsing.txt readme.htm zippy.README \
-	xboard.conf.in SHORTLOG DIFFSTAT history.c ABOUT-NLS
+	xboard.conf.in SHORTLOG DIFFSTAT history.c ABOUT-NLS $(FRONTENDextras)
 
 DISTCLEANFILES = stamp-h
 
diff --git a/configure.ac b/configure.ac
index 981f058..a7675ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -147,11 +147,6 @@ AC_ARG_WITH([Xaw],
             [with_Xaw=yes],
             [with_Xaw=no])
 
-dnl | make results available in Makefile.am
-AM_CONDITIONAL([withGTK],   [test x"$with_GTK" = x"yes"])
-AM_CONDITIONAL([withXaw],   [test x"$with_Xaw3d" = x"yes"])
-AM_CONDITIONAL([withXaw],   [test x"$with_Xaw" = x"yes"])
-
 dnl | check for libraries
 if test x"$with_GTK" = x"yes" ; then
   PKG_CHECK_MODULES([GTK], [ gtk+-2.0 >= 2.16.0 gmodule-2.0 ])
@@ -191,8 +186,9 @@ dnl | check availability of Xaw3d
                     [AC_MSG_ERROR([--with-Xaw3d was given, but test for Xaw3d failed. Make sure that you have Xaw3d installed, else you might want to try the configure option --without-Xaw3d])],
 			       [-lXaw])])
 
-dnl | no Xaw3d, check for Xaw
+dnl | no Xaw3d, check for Xaw; make it the default
   if test x"$with_Xaw3d" = x"no" ; then
+     with_Xaw=yes
      save_cflags="$CFLAGS"
      save_cppflags="$CPPFLAGS"
      CFLAGS="$CFLAGS $X_CFLAGS"
@@ -210,6 +206,12 @@ dnl | no Xaw3d, check for Xaw
 
 fi
 
+dnl | make results available in Makefile.am
+AM_CONDITIONAL([withGTK],   [test x"$with_GTK" = x"yes"])
+AM_CONDITIONAL([withXaw],   [test x"$with_Xaw3d" = x"yes"])
+AM_CONDITIONAL([withXaw],   [test x"$with_Xaw" = x"yes"])
+
+
 AC_SUBST(FRONTEND_CFLAGS)
 AC_SUBST(FRONTEND_LIBS)
 
-- 
1.7.0.4