[Freeciv-Dev] (PR#40640) [Patch] Unified client common library

2009-03-04 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=40640 >

> [cazf...@gmail.com - Wed Jan 07 21:23:18 2009]:
> 
>  SDL uses macro magic to rename our main() as SDL_main(). This means
> that client common code library has different symbols when compiling
> SDL client than otherwise. Fixing this is step toward building
> multiple clients at once.
> 
>  Attached patch renames current main() in client common code as
> client_main() and adds new gui specific main(), that only calls
> client_main(). Now SDL can have SDL_main() while others have main().
> 

SDL is also needed for SDL_mixer, so when compiling with audio support
all clients need SDL_main(), but without audio support only the SDL
client needs SDL_main().

The attached patch adds the conditional inclusion of SDL.h to all
gui_main.c files and $(SOUND_CFLAGS) to AM_CPPFLAGS in each gui's
Makefile.am.

Index: client/gui-ftwl/gui_main.c
===
--- client/gui-ftwl/gui_main.c	(revision 15567)
+++ client/gui-ftwl/gui_main.c	(working copy)
@@ -15,6 +15,10 @@
 #include 
 #endif
 
+#ifdef SDL
+#include "SDL.h"
+#endif
+
 #include 
 #include 
 
Index: client/gui-ftwl/Makefile.am
===
--- client/gui-ftwl/Makefile.am	(revision 15567)
+++ client/gui-ftwl/Makefile.am	(working copy)
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
 noinst_LTLIBRARIES = libguiclient.la
-AM_CPPFLAGS = -I. -I$(top_srcdir)/utility -I$(top_srcdir)/utility/ftwl -I$(top_srcdir)/common -I$(top_srcdir)/common/aicore -I$(srcdir)/.. -I$(srcdir)/../include $(CLIENT_CFLAGS)
+AM_CPPFLAGS = -I. -I$(top_srcdir)/utility -I$(top_srcdir)/utility/ftwl -I$(top_srcdir)/common -I$(top_srcdir)/common/aicore -I$(srcdir)/.. -I$(srcdir)/../include $(CLIENT_CFLAGS) $(SOUND_CFLAGS)
 
 libguiclient_la_SOURCES = \
 	canvas.c	\
Index: client/gui-gtk-2.0/gui_main.c
===
--- client/gui-gtk-2.0/gui_main.c	(revision 15567)
+++ client/gui-gtk-2.0/gui_main.c	(working copy)
@@ -15,6 +15,10 @@
 #include 
 #endif
 
+#ifdef SDL
+#include "SDL.h"
+#endif
+
 #include 
 #ifdef HAVE_LOCALE_H
 #include 
Index: client/gui-gtk-2.0/Makefile.am
===
--- client/gui-gtk-2.0/Makefile.am	(revision 15567)
+++ client/gui-gtk-2.0/Makefile.am	(working copy)
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
 noinst_LTLIBRARIES = libguiclient.la
-AM_CPPFLAGS = -I. -I$(srcdir)/.. -I$(srcdir)/../include -I$(top_srcdir)/utility -I$(top_srcdir)/common -I$(top_srcdir)/common/aicore -I$(srcdir)/../agents $(CLIENT_CFLAGS) $(GGZ_GTK_INCLUDES)
+AM_CPPFLAGS = -I. -I$(srcdir)/.. -I$(srcdir)/../include -I$(top_srcdir)/utility -I$(top_srcdir)/common -I$(top_srcdir)/common/aicore -I$(srcdir)/../agents $(CLIENT_CFLAGS) $(SOUND_CFLAGS) $(GGZ_GTK_INCLUDES)
 
 # The AM_CPPFLAGS "-I." is so resources.c includes the locally generated 
 # Freeciv.h in the builddir, in preference to the one 
Index: client/gui-sdl/Makefile.am
===
--- client/gui-sdl/Makefile.am	(revision 15567)
+++ client/gui-sdl/Makefile.am	(working copy)
@@ -2,7 +2,7 @@
 
 noinst_LTLIBRARIES = libguiclient.la
 
-AM_CPPFLAGS = -I$(srcdir)/.. -I$(srcdir)/../include -I$(top_srcdir)/utility -I$(top_srcdir)/common -I$(top_srcdir)/common/aicore -I$(srcdir)/../agents $(CLIENT_CFLAGS)
+AM_CPPFLAGS = -I$(srcdir)/.. -I$(srcdir)/../include -I$(top_srcdir)/utility -I$(top_srcdir)/common -I$(top_srcdir)/common/aicore -I$(srcdir)/../agents $(CLIENT_CFLAGS) $(SOUND_CFLAGS)
 
 libguiclient_la_SOURCES = \
 	SDL_rotozoom.c	\
Index: client/gui-stub/gui_main.c
===
--- client/gui-stub/gui_main.c	(revision 15567)
+++ client/gui-stub/gui_main.c	(working copy)
@@ -15,6 +15,10 @@
 #include 
 #endif
 
+#ifdef SDL
+#include "SDL.h"
+#endif
+
 #include 
 
 /* utility */
Index: client/gui-stub/Makefile.am
===
--- client/gui-stub/Makefile.am	(revision 15567)
+++ client/gui-stub/Makefile.am	(working copy)
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
 noinst_LTLIBRARIES = libguiclient.la
-AM_CPPFLAGS = -I. -I$(srcdir)/.. -I$(srcdir)/../include -I$(top_srcdir)/utility -I$(top_srcdir)/common $(CLIENT_CFLAGS)
+AM_CPPFLAGS = -I. -I$(srcdir)/.. -I$(srcdir)/../include -I$(top_srcdir)/utility -I$(top_srcdir)/common $(CLIENT_CFLAGS) $(SOUND_CFLAGS)
 
 libguiclient_la_SOURCES = \
 	canvas.c	\
Index: client/gui-win32/gui_main.c
===
--- client/gui-win32/gui_main.c	(revision 15567)
+++ client/gui-win32/gui_main.c	(working copy)
@@ -15,6 +15,10 @@
 #include 
 #endif
 
+#ifdef SDL
+#include "SDL.h"
+#endif
+
 #include 
 #include 
 #include 
Index: client/gui-win3

[Freeciv-Dev] (PR#40640) [Patch] Unified client common library

2009-01-07 Thread Marko Lindqvist

http://bugs.freeciv.org/Ticket/Display.html?id=40640 >

 SDL uses macro magic to rename our main() as SDL_main(). This means
that client common code library has different symbols when compiling
SDL client than otherwise. Fixing this is step toward building
multiple clients at once.

 Attached patch renames current main() in client common code as
client_main() and adds new gui specific main(), that only calls
client_main(). Now SDL can have SDL_main() while others have main().


 - ML

diff -Nurd -X.diff_ignore freeciv/client/civclient.c freeciv/client/civclient.c
--- freeciv/client/civclient.c  2008-11-04 16:19:19.0 +0200
+++ freeciv/client/civclient.c  2009-01-07 23:05:20.0 +0200
@@ -19,10 +19,6 @@
 #include/* LoadLibrary() */
 #endif
 
-#ifdef SDL
-#include "SDL.h"
-#endif
-
 #include 
 #include 
 #include 
@@ -202,9 +198,9 @@
 }
 
 /**
-...
+  Entry point for common client code.
 **/
-int main(int argc, char *argv[])
+int client_main(int argc, char *argv[])
 {
   int i, loglevel;
   int ui_options = 0;
diff -Nurd -X.diff_ignore freeciv/client/civclient.h freeciv/client/civclient.h
--- freeciv/client/civclient.h  2008-11-04 16:19:19.0 +0200
+++ freeciv/client/civclient.h  2009-01-07 22:59:36.0 +0200
@@ -33,6 +33,8 @@
   C_S_OVER,   /* Connected with game over. */
 };
 
+int client_main(int argc, char *argv[]);
+
 void client_packet_input(void *packet, int type);
 
 void send_report_request(enum report_type type);
diff -Nurd -X.diff_ignore freeciv/client/gui-ftwl/gui_main.c 
freeciv/client/gui-ftwl/gui_main.c
--- freeciv/client/gui-ftwl/gui_main.c  2008-11-11 17:38:45.0 +0200
+++ freeciv/client/gui-ftwl/gui_main.c  2009-01-07 23:07:55.0 +0200
@@ -174,7 +174,15 @@
 }
 
 /**
-  The main loop for the UI.  This is called from main(), and when it
+  Entry point for whole freeciv client program.
+**/
+int main(int argc, char **argv)
+{
+  return client_main(argc, argv);
+}
+
+/**
+  The main loop for the UI.  This is called from client_main(), and when it
   exits the client will exit.
 **/
 void ui_main(int argc, char *argv[])
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/gui_main.c 
freeciv/client/gui-gtk-2.0/gui_main.c
--- freeciv/client/gui-gtk-2.0/gui_main.c   2008-11-09 00:26:56.0 
+0200
+++ freeciv/client/gui-gtk-2.0/gui_main.c   2009-01-07 23:07:18.0 
+0200
@@ -1422,7 +1422,15 @@
 }
 
 /**
- called from main(), is what it's named.
+  Entry point for whole freeciv client program.
+**/
+int main(int argc, char **argv)
+{
+  return client_main(argc, argv);
+}
+
+/**
+  Called from client_main(), is what it's named.
 **/
 void ui_main(int argc, char **argv)
 {
diff -Nurd -X.diff_ignore freeciv/client/gui-sdl/gui_main.c 
freeciv/client/gui-sdl/gui_main.c
--- freeciv/client/gui-sdl/gui_main.c   2008-11-11 17:38:45.0 +0200
+++ freeciv/client/gui-sdl/gui_main.c   2009-01-07 23:07:05.0 +0200
@@ -884,6 +884,16 @@
 }
 
 /**
+  Entry point for freeciv client program. SDL has macro magic to turn
+  this in to function named SDL_main() and it provides actual main()
+  itself.
+**/
+int main(int argc, char **argv)
+{
+  return client_main(argc, argv);
+}
+
+/**
   The main loop for the UI.  This is called from main(), and when it
   exits the client will exit.
 **/
diff -Nurd -X.diff_ignore freeciv/client/gui-stub/gui_main.c 
freeciv/client/gui-stub/gui_main.c
--- freeciv/client/gui-stub/gui_main.c  2008-11-11 17:38:45.0 +0200
+++ freeciv/client/gui-stub/gui_main.c  2009-01-07 23:07:31.0 +0200
@@ -59,6 +59,14 @@
 }
 
 /**
+  Entry point for whole freeciv client program.
+**/
+int main(int argc, char **argv)
+{
+  return client_main(argc, argv);
+}
+
+/**
   The main loop for the UI.  This is called f