Author: cazfi
Date: Fri Jul  8 07:27:35 2016
New Revision: 33201

URL: http://svn.gna.org/viewcvs/freeciv?rev=33201&view=rev
Log:
Made it possible to link stub AI statically in.

See patch #7388

Modified:
    branches/S2_6/ai/Makefile.am
    branches/S2_6/ai/stub/Makefile.am
    branches/S2_6/configure.ac
    branches/S2_6/server/Makefile.am
    branches/S2_6/server/aiiface.c

Modified: branches/S2_6/ai/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/Makefile.am?rev=33201&r1=33200&r2=33201&view=diff
==============================================================================
--- branches/S2_6/ai/Makefile.am        (original)
+++ branches/S2_6/ai/Makefile.am        Fri Jul  8 07:27:35 2016
@@ -14,6 +14,10 @@
 module_dirs += threaded
 endif
 
+if AI_MOD_STATIC_STUB
+module_dirs += stub
+endif
+
 AM_CPPFLAGS = -I$(top_srcdir)/utility -I$(top_srcdir)/common
 
 if AI_MODULES
@@ -24,7 +28,9 @@
 if !AI_MOD_STATIC_THREADED
 module_dirs += threaded
 endif
+if !AI_MOD_STATIC_STUB
 module_dirs += stub
+endif
 else
 # AI module loading supported, but experimental modules not built
 endif

Modified: branches/S2_6/ai/stub/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/stub/Makefile.am?rev=33201&r1=33200&r2=33201&view=diff
==============================================================================
--- branches/S2_6/ai/stub/Makefile.am   (original)
+++ branches/S2_6/ai/stub/Makefile.am   Fri Jul  8 07:27:35 2016
@@ -1,9 +1,16 @@
 ## Process this file with automake to produce Makefile.in
 
+if AI_MOD_STATIC_STUB
+noinst_LTLIBRARIES = libstubai.la
+else
 aimodule_LTLIBRARIES = fc_ai_stub.la
+endif
 
 AM_CPPFLAGS = -I$(top_srcdir)/utility -I$(top_srcdir)/common
 
+if AI_MOD_STATIC_STUB
+libstubai_la_SOURCES = stubai.c
+else
 fc_ai_stub_la_SOURCES = stubai.c
-
 fc_ai_stub_la_LDFLAGS = -module
+endif

Modified: branches/S2_6/configure.ac
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/configure.ac?rev=33201&r1=33200&r2=33201&view=diff
==============================================================================
--- branches/S2_6/configure.ac  (original)
+++ branches/S2_6/configure.ac  Fri Jul  8 07:27:35 2016
@@ -502,6 +502,7 @@
 
 ai_mod_static_classic=no
 ai_mod_static_threaded=no
+ai_mod_static_stub=no
 
 for module in $(echo $static_modules | $SED 's/,/ /g') ; do
   if test "x$module" = "xclassic" ; then
@@ -514,6 +515,10 @@
     ai_mod_default_needed=yes
     AC_DEFINE([AI_MOD_STATIC_THREADED], [1],
               [threaded ai module statically linked])
+  elif test "x$module" = "xstub" ; then
+    ai_mod_static_stub=yes
+    AC_DEFINE([AI_MOD_STATIC_STUB], [1],
+              [stub ai module statically linked]) 
   else
     AC_MSG_ERROR([bad value ${module} for --enable-ai-static])
   fi
@@ -526,6 +531,8 @@
 [test "x$ai_mod_static_classic" = "xyes" || test "x$enable_aimodules" != 
"xyes"])
 AM_CONDITIONAL([AI_MOD_STATIC_THREADED],
 [test "x$ai_mod_static_threaded" = "xyes"])
+AM_CONDITIONAL([AI_MOD_STATIC_STUB],
+[test "x$ai_mod_static_stub" = "xyes"])
 
 AC_ARG_WITH([default-ai],
   AS_HELP_STRING([--with-default-ai], [default ai type [first static]]),
@@ -548,6 +555,9 @@
   fc_ai_last=$fc_ai_last+1
 fi
 if test "x$ai_mod_static_threaded" = "xyes" ; then
+  fc_ai_last=$fc_ai_last+1
+fi
+if test "x$ai_mod_static_stub" = "xyes" ; then
   fc_ai_last=$fc_ai_last+1
 fi
 if test "x$enable_aimodules" = "xyes" ; then

Modified: branches/S2_6/server/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/Makefile.am?rev=33201&r1=33200&r2=33201&view=diff
==============================================================================
--- branches/S2_6/server/Makefile.am    (original)
+++ branches/S2_6/server/Makefile.am    Fri Jul  8 07:27:35 2016
@@ -134,6 +134,9 @@
 if AI_MOD_STATIC_THREADED
 da_libs += $(top_builddir)/ai/threaded/libthreadedai.la
 endif
+if AI_MOD_STATIC_STUB
+da_libs += $(top_builddir)/ai/stub/libstubai.la
+endif
 
 # These files are not generated to builddir, but to srcdir */
 MAINTAINERCLEANFILES = \

Modified: branches/S2_6/server/aiiface.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/aiiface.c?rev=33201&r1=33200&r2=33201&view=diff
==============================================================================
--- branches/S2_6/server/aiiface.c      (original)
+++ branches/S2_6/server/aiiface.c      Fri Jul  8 07:27:35 2016
@@ -36,6 +36,10 @@
 
 #ifdef AI_MOD_STATIC_THREADED
 bool fc_ai_threaded_setup(struct ai_type *ai);
+#endif
+
+#ifdef AI_MOD_STATIC_STUB
+bool fc_ai_stub_setup(struct ai_type *ai);
 #endif
 
 static struct ai_type *default_ai = NULL;
@@ -125,7 +129,7 @@
 void ai_init(void)
 {
   bool failure = FALSE;
-#if !defined(AI_MODULES) || defined(AI_MOD_STATIC_CLASSIC) || 
defined(AI_MOD_STATIC_THREADED)
+#if !defined(AI_MODULES) || defined(AI_MOD_STATIC_CLASSIC) || 
defined(AI_MOD_STATIC_THREADED) || defined(AI_MOD_STATIC_STUB)
   /* First !defined(AI_MODULES) case is for default ai support. */
   struct ai_type *ai;
 #endif
@@ -178,6 +182,17 @@
   }
 #endif /* AI_MOD_STATIC_THREADED */
 
+#ifdef AI_MOD_STATIC_STUB
+  ai = ai_type_alloc();
+  if (ai != NULL) {
+    init_ai(ai);
+    if (!fc_ai_stub_setup(ai)) {
+      log_error(_("Failed to setup \"%s\" AI module"), "stub");
+      ai_type_dealloc();
+    }
+  }
+#endif /* AI_MOD_STATIC_STUB */
+
   default_ai = ai_type_by_name(AI_MOD_DEFAULT);
 #ifdef AI_MODULES
   if (default_ai == NULL) {


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to