1dnl configure.ac for freeciv
2dnl Process this file with autoconf to produce a configure script.
3
4AC_INIT([Freeciv], m4_esyscmd([./fc_version | tr -d '\n']),
5        [https://osdn.net/projects/freeciv/ticket/],
6        [freeciv])
7AC_PREREQ(2.61)
8
9dnl Initialize with some random file to ensure the source is here.
10AC_CONFIG_SRCDIR([common/game.c])
11AC_CONFIG_AUX_DIR(bootstrap) # This can't be quoted or automake will fail
12AC_CONFIG_MACRO_DIR([m4])
13ifdef([AC_CONFIG_MACRO_DIRS],[AC_CONFIG_MACRO_DIRS([dependencies/m4])])
14AC_CONFIG_HEADERS([gen_headers/fc_config.h gen_headers/freeciv_config.h gen_headers/liblua_config.h])
15AC_CANONICAL_HOST
16AC_USE_SYSTEM_EXTENSIONS
17AC_C_BIGENDIAN
18
19BUG_URL="$PACKAGE_BUGREPORT"
20WIKI_URL="http://www.freeciv.org/"
21MAIL_ADDRESS="freeciv-dev AT freelists.org"
22
23dnl Explain fc_config.h to end users (e.g., on Windows)
24AH_TOP(
25[/* This header file is shipped in some binary distributions.
26 * It is included purely for reference as to how the executables were built,
27 * and changing it will have no functional effect on pre-built binaries. */])
28
29AC_DEFINE(FC_CONFIG_H, 1, [Configuration autogenerated])
30AC_DEFINE_UNQUOTED([BUG_URL], ["$BUG_URL"], [Bug reporting URL])
31AC_DEFINE([FREECIV_META_URL], ["http://meta.freeciv.org/metaserver.php"], [Metaserver URL])
32AC_DEFINE_UNQUOTED([WIKI_URL], ["$WIKI_URL"], [Informational URL])
33
34AC_DEFINE(DEFAULT_SOCK_PORT, 5556, [Connection TCP Port])
35
36AC_SUBST([BUG_URL])
37AC_SUBST([WIKI_URL])
38AC_SUBST([MAIL_ADDRESS])
39
40dnl client/server should always have the same major and minor versions
41dnl different patch versions are compatible
42VERSION_SCRIPT_SILENT=yes
43m4_include(fc_version)
44
45AC_ARG_VAR([FREECIV_LABEL_FORCE], [Forced version label format])
46
47AC_DEFINE_UNQUOTED([MAJOR_VERSION], [$MAJOR_VERSION], [Major version])
48AC_DEFINE_UNQUOTED([MINOR_VERSION], [$MINOR_VERSION], [Minor version])
49AC_DEFINE_UNQUOTED([PATCH_VERSION], [$PATCH_VERSION], [Patch version])
50if test x$EMERGENCY_VERSION != x ; then
51  AC_DEFINE_UNQUOTED([EMERGENCY_VERSION], [$EMERGENCY_VERSION], [Emergency version])
52fi
53AC_DEFINE_UNQUOTED([VERSION_LABEL], ["${VERSION_LABEL}"], [Version label])
54AC_DEFINE_UNQUOTED([VERSION_STRING], ["${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${EMERG_PART}${VERSION_LABEL}"], [Version string])
55AC_DEFINE_UNQUOTED([IS_DEVEL_VERSION], [$IS_DEVEL_VERSION], [Is this a devel version])
56AC_DEFINE_UNQUOTED([IS_FREEZE_VERSION], [$IS_FREEZE_VERSION], [Is this a frozen version])
57AC_DEFINE_UNQUOTED([IS_BETA_VERSION], [$IS_BETA_VERSION], [Is this a beta version])
58AC_DEFINE_UNQUOTED([NEXT_STABLE_VERSION], ["$NEXT_STABLE_VERSION"], [Version number of next release])
59AC_DEFINE_UNQUOTED([FREECIV_RELEASE_MONTH], [$RELEASE_MONTH], [Month next version will be released])
60AC_SUBST([MAJOR_VERSION])
61AC_SUBST([MINOR_VERSION])
62
63AC_DEFINE_UNQUOTED([NETWORK_CAPSTRING_MANDATORY],
64		   ["$NETWORK_CAPSTRING_MANDATORY"],
65		   [Network capability string])
66AC_SUBST([NETWORK_CAPSTRING_MANDATORY])
67AC_DEFINE_UNQUOTED([NETWORK_CAPSTRING_OPTIONAL],
68		   ["$NETWORK_CAPSTRING_OPTIONAL"],
69		   [Additional optional network capabilities])
70AC_SUBST([NETWORK_CAPSTRING_OPTIONAL])
71
72AC_DEFINE_UNQUOTED([DATASUBDIR],
73                   ["$DATASUBDIR"],
74                   [Version specific subdir for default data path])
75AC_SUBST([DATASUBDIR])
76
77AC_DEFINE_UNQUOTED([FREECIV_DISTRIBUTOR], ["$FREECIV_DISTRIBUTOR"],
78                   [Distribution this freeciv is built for])
79
80dnl Initialize automake stuff
81AM_INIT_AUTOMAKE([subdir-objects dist-bzip2 dist-zip])
82
83dnl Use Automake 1.11 silent rules by default if available
84dnl verbose build using  make V=1
85ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
86
87UTILITY_LIBS=
88
89AC_PROG_MKDIR_P
90
91dnl Sed is needed for the configuration
92dnl of the clients, database setting and the mapimg toolkits.
93AC_PROG_SED
94
95AC_CACHE_CHECK([can we call malloc(0)], [fc_cv_malloc_zero_ok], [
96AC_RUN_IFELSE([AC_LANG_SOURCE([[
97#include <stdlib.h>
98
99int
100main()
101{
102  void *allocation = malloc(0);
103
104  if (allocation != NULL) {
105    free(allocation);
106  }
107
108  return (allocation == NULL);
109}
110]])], [fc_cv_malloc_zero_ok=yes], [fc_cv_malloc_zero_ok=no], [fc_cv_malloc_zero_ok=no])])
111
112if test "x$fc_cv_malloc_zero_ok" = "xyes" ; then
113  AC_DEFINE([MALLOC_ZERO_OK], [1], [It's ok to call malloc() for zero bytes])
114fi
115
116dnl set default values
117fcdb_all=no
118fcdb_mysql=no
119fcdb_postgres=no
120fcdb_sqlite3=no
121
122dnl checks for databases
123dnl all:                  Autodetect as many as possible [default].
124dnl mysql:                use mysql database
125dnl postgres:             use postgres database
126dnl comma-separated-list: Detect these or abort.
127AC_ARG_ENABLE([fcdb],
128  AS_HELP_STRING([--enable-fcdb[=no/all/mysql/postgres/sqlite3]],
129                 [database backends [no](no, or list)]),
130[databases=${enableval}],
131[databases=no])
132
133for db in $(echo $databases | $SED 's/,/ /g') ; do
134  if test "x$db" = "xall" ; then
135    fcdb_all=yes
136  elif test "x$db" = "xno" ; then
137    fcdb_all=no
138  elif test "x$db" = "xmysql" ; then
139    fcdb_mysql=yes
140  elif test "x$db" = "xpostgres" ; then
141    fcdb_postgres=yes
142  elif test "x$db" = "xsqlite3" ; then
143    fcdb_sqlite3=yes
144  else
145    AC_MSG_ERROR([bad value ${db} for --enable-fcdb])
146  fi
147done
148
149dnl checks for database mysql
150dnl sets FCDB_MYSQL(conditional), FCDB_MYSQL_CFLAGS
151FC_FCDB_MYSQL
152
153dnl checks for database postgres
154dnl sets FCDB_POSTGRES(conditional), FCDB_POSTGRES_CFLAGS
155FC_FCDB_POSTGRES
156
157dnl checks for database sqlite3
158dnl sets FCDB_SQLITE3(conditional), FCDB_SQLITE3_CFLAGS
159FC_FCDB_SQLITE3
160
161dnl check if a database backend is available
162if test "x$fcdb_mysql" = "xyes" || test "x$fcdb_postgres" = "xyes" \
163   || test "x$fcdb_sqlite3" = "xyes"; then
164  enable_fcdb=yes
165  AC_DEFINE([HAVE_FCDB], [1], [Database backend available])
166else
167  enable_fcdb=no
168fi
169AM_CONDITIONAL([FCDB_DB], [test "x$enable_fcdb" = "xyes"])
170
171dnl  no=do not compile server,  yes=compile server,  *=error
172AC_ARG_ENABLE([server],
173  AS_HELP_STRING([--disable-server], [do not compile the server]),
174[case "${enableval}" in
175  yes) server=yes ;;
176  no)  server=no ;;
177  *)   AC_MSG_ERROR(bad value ${enableval} for --disable-server) ;;
178esac], [server=yes])
179AM_CONDITIONAL(SERVER, test x$server = xyes)
180
181dnl Host type variable defaults
182MINGW=no
183AMIGA=no
184
185dnl Settings specific to host OS
186case "$host_os" in
187
188  *mingw*)
189    dnl Windows-specific settings
190    MINGW=yes
191    FC_WINSOCK2_INCLUDE([AC_DEFINE([FREECIV_HAVE_WINSOCK2], [1], [Mingw-specific setting - winsock2])])
192    AC_DEFINE([FREECIV_HAVE_WINSOCK], [1], [Mingw-specific setting - winsock])
193    AC_CHECK_HEADERS([ws2tcpip.h], [AC_DEFINE([FREECIV_HAVE_WS2TCPIP_H], [1], [ws2tcpip.h available])])
194    AC_CHECK_HEADERS([direct.h])
195
196    dnl Without WINSOCK2, use: LIBS="$LIBS -lwsock32"
197    LIBS="${LIBS} -lws2_32"
198    ;;
199
200  *haiku*)
201    LIBS="$LIBS -lnetwork"
202    ;;
203esac
204
205dnl Networking headers
206AC_CHECK_HEADERS([sys/types.h], [AC_DEFINE([FREECIV_HAVE_SYS_TYPES_H], [1], [sys/types.h available])])
207
208dnl Avoid including the unix emulation layer if we build mingw executables
209dnl There would be type conflicts between winsock and bsd/unix includes
210if test "x$MINGW" != "xyes"; then
211  AC_CHECK_HEADERS([sys/socket.h], [AC_DEFINE([FREECIV_HAVE_SYS_SOCKET_H], [1], [sys/socket.h available])])
212fi
213
214dnl Check getaddrinfo just once here, and remember the result
215AC_CHECK_FUNCS([getaddrinfo], [have_getaddrinfo=yes], [
216  AC_MSG_CHECKING([getaddrinfo() as a macro])
217  AC_LINK_IFELSE([AC_LANG_PROGRAM([
218#ifdef FREECIV_HAVE_WS2TCPIP_H
219#include <ws2tcpip.h>
220#endif], [getaddrinfo(NULL, NULL, NULL, NULL);])], [
221  AC_MSG_RESULT([yes])
222  have_getaddrinfo=yes
223  AC_DEFINE([HAVE_GETADDRINFO])], [AC_MSG_RESULT([no])])])
224
225dnl yes     - Support for IPv6 required
226dnl no      - Legacy IPv4 support
227dnl test    - Try to enable IPv6 support
228AC_ARG_ENABLE([ipv6],
229  AS_HELP_STRING([--enable-ipv6=yes/no/test], [use IPv6 [test]]),
230[case "${enableval}" in
231  yes|no|test) ipv6=${enableval} ;;
232  *)   AC_MSG_ERROR(bad value ${enableval} for --enable-ipv6) ;;
233esac], [ipv6=test])
234if test x$ipv6 != xno ; then
235  if test "x$have_getaddrinfo" = "xyes" ; then
236    enable_ipv6=yes
237    AC_CHECK_FUNCS([inet_pton], [],
238       [AC_MSG_CHECKING([inet_pton() as a macro])
239      AC_LINK_IFELSE([AC_LANG_PROGRAM([
240#ifdef FREECIV_HAVE_WS2TCPIP_H
241#include <ws2tcpip.h>
242#endif], [inet_pton(0, NULL, NULL);])], [
243      AC_MSG_RESULT([yes])], [enable_ipv6=no])])
244    AC_CHECK_FUNCS([inet_ntop], [],
245       [AC_MSG_CHECKING([inet_ntop() as a macro])
246      AC_LINK_IFELSE([AC_LANG_PROGRAM([
247#ifdef FREECIV_HAVE_WS2TCPIP_H
248#include <ws2tcpip.h>
249#endif], [inet_ntop(0, NULL, NULL, 0);])], [
250      AC_MSG_RESULT([yes])], [enable_ipv6=no])])
251    AC_CHECK_FUNCS([getnameinfo], [],
252       [AC_MSG_CHECKING([getnameinfo() as a macro])
253      AC_LINK_IFELSE([AC_LANG_PROGRAM([
254#ifdef FREECIV_HAVE_WS2TCPIP_H
255#include <ws2tcpip.h>
256#endif], [getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);])], [
257      AC_MSG_RESULT([yes])], [enable_ipv6=no])])
258  else
259     enable_ipv6=no
260  fi
261  if test x$enable_ipv6 = xyes ; then
262    AC_MSG_CHECKING([for AF_INET6])
263    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
264#ifdef FREECIV_HAVE_WINSOCK2
265#include <winsock2.h>
266#endif
267#ifdef FREECIV_HAVE_SYS_TYPES_H
268#include <sys/types.h>
269#endif
270#ifdef FREECIV_HAVE_SYS_SOCKET_H
271#include <sys/socket.h>
272#endif]], [[return AF_INET6;]])], [AC_MSG_RESULT([yes])],
273       [AC_MSG_RESULT([no])
274        enable_ipv6=no])
275  fi
276  if test x$enable_ipv6 = xno && test x$ipv6 = xyes ; then
277    AC_MSG_ERROR([Cannot enable IPv6 functionality])
278  fi
279  if test x$enable_ipv6 = xyes ; then
280    AC_DEFINE([FREECIV_IPV6_SUPPORT], [1], [IPv6 Support built in])
281  else
282    feature_ipv6=missing
283  fi
284fi
285
286AC_ARG_WITH([readline],
287  AS_HELP_STRING([--with-readline], [support fancy command line editing]),
288WITH_READLINE=$withval,	dnl yes/no - required to use / never use
289WITH_READLINE="maybe"	dnl maybe  - use if found [default]
290)
291
292FOLLOWTAG=${DEFAULT_FOLLOW_TAG}
293AC_ARG_WITH([followtag],
294  AS_HELP_STRING([--with-followtag], [version tag to follow]),
295[FOLLOWTAG=${withval}])
296AC_DEFINE_UNQUOTED([FOLLOWTAG], ["${FOLLOWTAG}"], [Version tag to follow])
297
298AC_ARG_WITH([modlist],
299  AS_HELP_STRING([--with-modlist], [default modlist URL]),
300[modlist_url=${withval}])
301if test "x$modlist_url" != "x" ; then
302  AC_DEFINE_UNQUOTED([MODPACK_LIST_URL], ["${modlist_url}"], [Default modpack list URL])
303fi
304
305AC_ARG_WITH([desktopdir],
306  AS_HELP_STRING([--with-desktopdir], [install desktop files to given dir]),
307[ DESKTOPDIR=${withval} ], [ DESKTOPDIR="\$(prefix)/share/applications" ])
308AC_SUBST([DESKTOPDIR])
309
310AC_ARG_WITH([appdatadir],
311  AS_HELP_STRING([--with-appdatadir], [install appdata files to given dir]),
312[ APPDATADIR=${withval} ], [ APPDATADIR="\$(prefix)/share/appdata" ])
313AC_SUBST([APPDATADIR])
314
315AC_ARG_ENABLE([patient-connect],
316  AS_HELP_STRING([--enable-patient-connect=yes/no],
317                 [enable client to be very patient in connecting spawned server]),
318  [case "${enableval}" in
319    yes) AC_DEFINE([FREECIV_PATIENT_CONNECT], [1],
320                   [Client is very patient when connecting to spawned server]) ;;
321    no) ;;
322    *) AC_MSG_ERROR([bad value ${enableval} for --enable-patient-connect]) ;;
323  esac])
324
325dnl set default values
326mapimg_all=auto
327mapimg_magickwand=no
328
329dnl map images
330dnl all:                  Autodetect as many as possible [default].
331dnl no:                   No additional toolkits.
332dnl magickwand:           compile magickwand (imagemagick) support.
333dnl comma-separated-list: Detect these or abort.
334AC_ARG_ENABLE([mapimg],
335  AS_HELP_STRING([--enable-mapimg=no/auto/magickwand],
336                 [additional map image toolkits to compile [auto](no, or list)]),
337[toolkits=${enableval}],
338[enable_mapimg=auto])
339
340for toolkit in $(echo $toolkits | $SED 's/,/ /g') ; do
341  if test "x$toolkit" = "xauto" ; then
342    enable_mapimg=auto
343  elif test "x$toolkit" = "xno" ; then
344    enable_mapimg=no
345  else
346    enable_mapimg=selected
347  fi
348
349  if test "x$toolkit" = "xmagickwand" ; then
350    mapimg_magickwand=yes
351  fi
352done
353
354dnl checks for MagickWand mapimg support
355dnl sets MAPIMG_WAND_CFLAGS, MAPIMG_WAND_LIBS
356FC_MAPIMG_MAGICKWAND
357
358dnl Option not available in stable branch
359fcweb=false
360
361FC_WEB_CLIENT
362
363FC_TESTMATIC
364
365dnl no:   Do not compile client.
366dnl auto: Autodetect one.
367dnl all:  Autodetect as many as possible.
368dnl comma-separated-list: Detect these or abort.
369AC_ARG_ENABLE([client],
370  AS_HELP_STRING([--enable-client=auto/all/gtk2/gtk3/gtk3.22/sdl/sdl2/xaw/qt/stub],
371                 [clients to compile [auto](list for multiple)]),
372[clients=${enableval}],
373[client=auto])
374
375if test "x$fcweb" = "xtrue" ; then
376  if test "x$clients" != "x" && test "x$clients" != "xauto" &&
377     test "x$clients" != "xno" ; then
378    AC_MSG_ERROR([One cannot enable any clients for freeciv-web build])
379  fi
380  clients=no
381fi
382
383gui_gtk2=no
384gui_gtk3_22=no
385gui_gtk3=no
386gui_sdl=no
387gui_sdl2=no
388gui_xaw=no
389gui_qt=no
390gui_stub=no
391
392for gui in $(echo $clients | $SED 's/,/ /g') ; do
393  if test "x$gui" = "xno" ; then
394    client=no
395  elif test "x$gui" = "xauto" || test "x$gui" = "xyes" ; then
396    client=auto
397  elif test "x$gui" = "xall" ; then
398    client=all
399  else
400    if test "x$gui" = "xgtk2"   ||
401       test "x$gui" = "xgtk2.0" ||
402       test "x$gui" = "xgtk20"  ||
403       test "x$gui" = "xgtk-2.0" ; then
404      gui_gtk2=yes
405    elif test "x$gui" = "xgtk3.22" ; then
406      gui_gtk3_22=yes
407    elif test "x$gui" = "xgtk3"   ||
408         test "x$gui" = "xgtk3.0" ||
409         test "x$gui" = "xgtk30"  ||
410         test "x$gui" = "xgtk-3.0" ; then
411      gui_gtk3=yes
412    elif test "x$gui" = "xgtk" ; then
413      AC_MSG_WARN([for requested client 'gtk' enabled gtk3-client, that has changed since earlier versions])
414      gui_gtk3=yes
415    else
416      if test ! -d "${srcdir}/client/gui-$gui" ; then
417        AC_MSG_ERROR(bad value ${gui} for --enable-client)
418      fi
419      eval "gui_$gui=yes"
420    fi
421    client=yes
422  fi
423done
424
425AC_ARG_WITH([xaw],
426  [AS_HELP_STRING([--with-xaw], [use the Xaw widget set for the xaw client])],
427  [WITH_XAW=1])
428
429AC_ARG_WITH([xaw3d],
430  [AS_HELP_STRING([--with-xaw3d], [use the Xaw3d widget set for the xaw client])],
431  [WITH_XAW3D=1])
432
433if test "x$WITH_XAW" != "x" && test "x$WITH_XAW3D" != "x" ; then
434  AC_MSG_ERROR([Cannot use both --with-xaw and --with-xaw3d at the same time])
435fi
436
437AC_ARG_ENABLE([gitrev],
438  AS_HELP_STRING([--enable-gitrev], [get git revision to version information]),
439[case "${enableval}" in
440  yes) gitrev=true  ;;
441  no)  gitrev=false ;;
442  *)   AC_MSG_ERROR([bad value ${enableval} for --enable-gitrev]) ;;
443esac], [gitrev=false])
444AM_CONDITIONAL([GITREV], [test x$gitrev = xtrue])
445if test x$gitrev = xtrue ; then
446  AC_DEFINE([GITREV], [1], [Get git revision information to version number])
447fi
448
449AC_ARG_ENABLE([make_data],
450  AS_HELP_STRING([--disable-make-data], [do not recurse make into data directories]),
451[case "${enableval}" in
452  yes) make_data=true ;;
453  no)  make_data=false ;;
454  *)   AC_MSG_ERROR(bad value ${enableval} for --disable-make-data) ;;
455esac], [make_data=true])
456AM_CONDITIONAL(MAKE_DATA, test x$make_data = xtrue)
457
458AC_ARG_ENABLE([make_include],
459  AS_HELP_STRING([--enable-make-include], [force make to recurse into include directory]),
460[case "${enableval}" in
461  yes) make_include=true ;;
462  no)  make_include=false ;;
463  *)   AC_MSG_ERROR(bad value ${enableval} for --enable-make-include) ;;
464esac], [make_include=false])
465AM_CONDITIONAL(MAKE_CLIENT_INCLUDE, test "$make_include" = "true")
466
467AC_ARG_WITH([efence],
468  AS_HELP_STRING([--with-efence], [use Electric Fence, malloc debugger]),
469  WITH_EFENCE=1
470)
471
472AC_ARG_ENABLE([aimodules],
473  AS_HELP_STRING([--enable-aimodules=yes/no/experimental], [support for ai modules [no]]),
474[case "${enableval}" in
475  yes) enable_aimodules=yes ;;
476  no)  enable_aimodules=no ;;
477  experimental) enable_aimodules=yes
478                exp_aimodules=yes ;;
479  *)   AC_MSG_ERROR([bad value ${enable_aimodules} for --enable-aimodules]) ;;
480esac], [enable_aimodules=no])
481aimoduledir="${libdir}/fcai"
482AC_SUBST(aimoduledir)
483AM_CONDITIONAL(AI_MODULES, test "x$enable_aimodules" = "xyes")
484if test $enable_aimodules = yes ; then
485  if test x$enable_shared != xyes ; then
486    AC_MSG_ERROR([cannot enable ai module support if also build of shared libraries is not enabled with --enable-shared])
487  fi
488  LIBS_TMP="$LIBS"
489  LIBS="$LIBS -lltdl"
490  AC_MSG_CHECKING([whether can build modules])
491  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ltdl.h>]],
492     [[lt_dlopenext(NULL);]])],
493     [AC_MSG_RESULT([yes])],
494     [AC_MSG_RESULT([no])
495      AC_MSG_ERROR([cannot build loadable AI modules as requested])])
496  LIBS="$LIBS_TMP"
497  SERVER_LIBS="${SERVER_LIBS} -lltdl"
498  AC_DEFINE([AI_MODULES], [1], [Enable ai modules])
499  CPPFLAGS="${CPPFLAGS} -DAI_MODULEDIR=\"\\\"${aimoduledir}\\\"\""
500  ai_mod_default_needed=yes
501fi
502AM_CONDITIONAL(EXP_AI_MODULES, test "x$exp_aimodules" = "xyes")
503
504AC_ARG_ENABLE([ai-static],
505  AS_HELP_STRING([--enable-ai-static], [statically link listed modules to server]),
506[static_modules="${enableval}"],
507[static_modules="classic"])
508
509ai_mod_static_classic=no
510ai_mod_static_threaded=no
511ai_mod_static_stub=no
512
513for module in $(echo $static_modules | $SED 's/,/ /g') ; do
514  if test "x$module" = "xclassic" ; then
515    ai_mod_static_classic=yes
516    ai_mod_default_needed=yes
517    AC_DEFINE([AI_MOD_STATIC_CLASSIC], [1],
518              [classic ai module statically linked])
519  elif test "x$module" = "xthreaded" ; then
520    ai_mod_static_threaded=yes
521    ai_mod_default_needed=yes
522    AC_DEFINE([AI_MOD_STATIC_THREADED], [1],
523              [threaded ai module statically linked])
524  elif test "x$module" = "xstub" ; then
525    ai_mod_static_stub=yes
526    AC_DEFINE([AI_MOD_STATIC_STUB], [1],
527              [stub ai module statically linked])
528  else
529    AC_MSG_ERROR([bad value ${module} for --enable-ai-static])
530  fi
531  if test "x$default_ai_set" = "x" ; then
532    dnl Make first static module default ai type
533    default_ai_set="${module}"
534  fi
535done
536AM_CONDITIONAL([AI_MOD_STATIC_CLASSIC],
537[test "x$ai_mod_static_classic" = "xyes" || test "x$enable_aimodules" != "xyes"])
538AM_CONDITIONAL([AI_MOD_STATIC_THREADED],
539[test "x$ai_mod_static_threaded" = "xyes"])
540AM_CONDITIONAL([AI_MOD_STATIC_STUB],
541[test "x$ai_mod_static_stub" = "xyes"])
542
543AC_ARG_WITH([default-ai],
544  AS_HELP_STRING([--with-default-ai], [default ai type [first_static]]),
545  [default_ai_set="${withval}"],
546  [])
547
548AC_ARG_WITH([ai-lib],
549  AS_HELP_STRING([--with-ai-lib], [build in default AI code [if_needed]]),
550  [ai_mod_default_needed=yes], [])
551
552AM_CONDITIONAL([AI_MOD_DEFAULT_NEEDED],
553[test  "x${ai_mod_default_needed}" = "xyes" || test "x${default_ai_set}" = "x"])
554
555if test "x${default_ai_set}" = "x" ; then
556  default_ai_set="classic"
557fi
558
559fc_ai_last=0
560if test "x$ai_mod_static_classic" = "xyes" ; then
561  fc_ai_last=$fc_ai_last+1
562fi
563if test "x$ai_mod_static_threaded" = "xyes" ; then
564  fc_ai_last=$fc_ai_last+1
565fi
566if test "x$ai_mod_static_stub" = "xyes" ; then
567  fc_ai_last=$fc_ai_last+1
568fi
569if test "x$enable_aimodules" = "xyes" ; then
570  dnl Dynamic modules allowed, give slots for them
571  fc_ai_last=$fc_ai_last+3
572fi
573AC_DEFINE_UNQUOTED([FREECIV_AI_MOD_LAST], [(${fc_ai_last})], [Max number of AI modules])
574
575AC_DEFINE_UNQUOTED([AI_MOD_DEFAULT], ["${default_ai_set}"], [Default ai type name])
576
577dnl Checks for programs.
578AC_PROG_AWK
579AC_PROG_CC
580AC_PROG_CPP
581AC_PROG_LN_S
582AC_DISABLE_SHARED
583dnl Replace AC_PROG_LIBTOOL with LT_INIT when minimum libtool
584dnl version 2.2
585m4_ifdef([AM_PROG_AR], [AM_PROG_AR], [AC_CHECK_TOOL([AR], [ar])])
586AC_PROG_LIBTOOL
587AC_SUBST(LIBTOOL)
588if test -z $AR; then
589	AC_MSG_ERROR([*** 'ar' missing.  Install binutils, fix your \$PATH, or set \$AR manually. ***])
590fi
591
592AM_PROG_CC_C_O
593AC_PROG_CXX
594FC_WORKING_CXX
595FC_C99_TOKEN_CONCENATION
596
597AC_CHECK_PROG(UNAME,uname,uname,:)
598
599AC_CHECK_SIZEOF([int])
600
601dnl Programs already checked by AM_INIT_AUTOMAKE:
602dnl
603dnl AC_PROG_MAKE_SET required with automake-ng
604AC_PROG_MAKE_SET
605
606dnl Check for libiconv (which is usually included in glibc, but may be
607dnl distributed separately).  The libcharset check must come after the
608dnl iconv check.  This whole thing must come before the gettext check below.
609AM_ICONV
610FC_LIBCHARSET
611AM_LANGINFO_CODESET
612if test "$am_cv_func_iconv" != yes; then
613  AC_MSG_ERROR([Iconv is missing. You can get libiconv from http://gnu.org/, \
614or try using --with-libiconv-prefix.])
615fi
616LIBS="$LIBS $LIBICONV"
617
618dnl I18n support
619ALL_LINGUAS="ar bg cs ca da de el en_GB eo es et fa fi fr ga gd he hu id it ja
620ko lt nl nb pl pt pt_BR ro ru sr sv tr uk zh_CN zh_TW"
621PODOMAINS="freeciv nations ruledit"
622
623AM_GNU_GETTEXT([external], [need-ngettext])
624
625if test "x$USE_NLS" = "xyes" ; then
626  AC_DEFINE([FREECIV_ENABLE_NLS], [1], [Native language support enabled])
627fi
628
629AM_XGETTEXT_OPTION([--keyword=Q_])
630AM_XGETTEXT_OPTION([--keyword=PL_:1,2])
631AM_XGETTEXT_OPTION([--language=C])
632AM_XGETTEXT_OPTION([--escape])
633AM_XGETTEXT_OPTION([--add-comments="TRANS:"])
634AM_XGETTEXT_OPTION([--from-code=UTF-8])
635
636PKG_PROG_PKG_CONFIG
637if test "x$PKG_CONFIG" = "x" ; then
638  AC_MSG_ERROR([pkg-config not found])
639fi
640PKG_CHECK_MODULES([CURL], [libcurl >= 7.12.1],,
641    [AC_MSG_ERROR([libcurl development files required])])
642UTILITY_CFLAGS="${UTILITY_CFLAGS} ${CURL_CFLAGS}"
643UTILITY_LIBS="${UTILITY_LIBS} ${CURL_LIBS}"
644
645AC_ARG_ENABLE([xml-registry],
646  AS_HELP_STRING([--enable-xml-registry], [build xml-backend for registry (WIP)]),
647[case "${enableval}" in
648  yes) XMLREGISTRY=yes ;;
649  no)  XMLREGISTRY=no  ;;
650  *)   AC_MSG_ERROR([bad value ${enableval} for --enable-xml-registry]) ;;
651esac], [XMLREGISTRY=no])
652
653if test "x$XMLREGISTRY" = "xyes" ; then
654  PKG_CHECK_MODULES([LIBXML2], [libxml-2.0],,
655      [AC_MSG_ERROR([libxml2 development files required])])
656  UTILITY_CFLAGS="${UTILITY_CFLAGS} ${LIBXML2_CFLAGS}"
657  UTILITY_LIBS="${UTILITY_LIBS} ${LIBXML2_LIBS}"
658  AC_DEFINE([FREECIV_HAVE_XML_REGISTRY], [1], [Build xml-backend for registry])
659fi
660
661dnl Set debug flags supported by compiler
662EXTRA_DEBUG_CFLAGS=""
663EXTRA_DEBUG_CXXFLAGS=""
664EXTRA_DEBUG_LDFLAGS=""
665dnl check debugging
666FC_DEBUG
667dnl check profiling
668FC_GPROF
669
670AC_C99_VARIADIC_MACROS
671AC_C99_VARIABLE_ARRAYS
672AC_C99_INITIALIZERS
673AC_C99_STDINT_H
674
675FC_INITIALIZER_BRACES
676
677FC_C11_STATIC_ASSERT
678FC_C11_AT_QUICK_EXIT
679
680FC_CXX11_STATIC_ASSERT
681FC_CXX11_NULLPTR
682
683dnl BeOS-specific settings
684if test x`$UNAME -s` = xBeOS ; then
685  AC_DEFINE([FREECIV_SOCKET_ZERO_NOT_STDIN], [1], [BeOS-specific setting])
686  CFLAGS="$CFLAGS -Wno-multichar"
687  LDFLAGS="$LDFLAGS -x none"
688  if test x$enable_debug = xyes ; then
689    CFLAGS="$CFLAGS -gdwarf-2"
690    LDFLAGS="$LDFLAGS -gdwarf-2"
691  fi
692  # We used to set ARFLAGS here, but under recent versions of automake this
693  # broke compilation on other systems.  Setting ARFLAGS shouldn't be
694  # necessary with a working automake.
695fi
696
697dnl Defaults to override with host specific values
698HOST_PATH_SEPARATOR=":"
699HOST_DIR_SEPARATOR="/"
700
701dnl Settings specific to host OS
702case "$host_os" in
703
704  *mingw*)
705    dnl Windows-specific settings
706    AC_CHECK_TOOL([WINDRES], [windres])
707    if test -z $WINDRES; then
708	  AC_MSG_ERROR([*** 'windres' missing.  Install binutils, fix your \$PATH, or set \$WINDRES manually. ***])
709    fi
710
711    HOST_PATH_SEPARATOR=";"
712    HOST_DIR_SEPARATOR="\\"
713
714    AC_DEFINE([FREECIV_SOCKET_ZERO_NOT_STDIN], [1], [Mingw-specific setting - stdin])
715    AC_DEFINE([ALWAYS_ROOT], [1], [Can execute program as root - Mingw])
716    AC_DEFINE([FREECIV_MSWINDOWS], [1], [Windows build])
717
718    dnl Backward compatibility macro, FREECIV_MSWINDOWS is the preferred one, and
719    dnl one that must be used in public headers.
720    AC_DEFINE([WIN32_NATIVE], [1], [Mingw-specific setting - native])
721    AC_DEFINE([NONBLOCKING_SOCKETS], [1], [nonblocking sockets support])
722    ;;
723
724  *skyos*)
725    dnl SkyOS specific settings
726    AC_DEFINE([ALWAYS_ROOT], [1], [Can execute program as root - SkyOS])
727    ;;
728
729  *haiku*)
730    dnl Haiku specific settings
731    HAIKU=yes
732    AC_DEFINE([HAIKU], [1], [Built for Haiku OS])
733    AC_DEFINE([ALWAYS_ROOT], [1], [Can execute program as root - Haiku])
734    ;;
735
736  *amigaos*)
737    AMIGA=yes
738    AC_DEFINE([ALWAYS_ROOT], [1], [Can execute program as root - Amiga])
739    ;;
740
741esac
742
743dnl Autoconf provides path separator for build system.
744dnl Use that instead of our own guess in case of native build.
745dnl Actually; Don't, since at least with autoconf-2.69 msys2 builds got wrong separator this way
746dnl if test x$build = x$host ; then
747dnl   HOST_PATH_SEPARATOR=$PATH_SEPARATOR
748dnl fi
749
750dnl note this has to match the path installed by translations/freeciv/Makefile
751if test x"$MINGW" != "xyes"; then
752  CPPFLAGS="$CPPFLAGS -DLOCALEDIR=\"\\\"$localedir\\\"\""
753else
754  AC_DEFINE_UNQUOTED([LOCALEDIR], [".\\\\share\\\\locale"], [Locale directory (windows)])
755fi
756
757CPPFLAGS="$CPPFLAGS -DBINDIR=\"\\\"$bindir\\\"\""
758
759COMMON_LIBS=-lm
760
761dnl Check for zlib
762AC_CHECK_LIB([z], [gzgets],
763  [AC_DEFINE([FREECIV_HAVE_LIBZ], [1], [zlib is available])
764UTILITY_LIBS="${UTILITY_LIBS} -lz"
765COMMON_LIBS="$COMMON_LIBS -lz"],
766  AC_MSG_ERROR([Could not find zlib library.]))
767
768AC_CHECK_HEADER(zlib.h, ,
769  AC_MSG_ERROR([zlib found but not zlib.h.
770You may need to install a zlib devel package.]))
771
772AC_PATH_PROG(GZIP, gzip, "no")
773if test "$GZIP" = "no"; then
774  AC_MSG_ERROR([You need the gzip program for compilation.])
775fi
776
777dnl Check for bzip2 compression
778AC_ARG_WITH([libbz2],
779  AS_HELP_STRING([--with-libbz2], [support bzip2 compressed files [if_possible]]),
780[WITH_BZ2="${withval}"],
781[WITH_BZ2="test"])
782
783if test "x$WITH_BZ2" != xno ; then
784  AC_CHECK_LIB([bz2], [BZ2_bzReadOpen],
785    [AC_CHECK_HEADERS([bzlib.h],
786     [AC_DEFINE([FREECIV_HAVE_LIBBZ2], [1], [libbzip2 is available])
787  UTILITY_LIBS="${UTILITY_LIBS} -lbz2"
788  libbz2_available=true])])
789  if test "x$libbz2_available" != "xtrue" ; then
790    if test "x$WITH_BZ2" = "xyes" ; then
791      AC_MSG_ERROR([Could not find libbz2 devel files])
792    fi
793    feature_bz2=missing
794  fi
795fi
796
797dnl Check for xz compression
798AC_ARG_WITH([liblzma],
799  AS_HELP_STRING([--with-liblzma], [support xz compressed files [if_possible]]),
800[WITH_XZ="${withval}"],
801[WITH_XZ="test"])
802
803if test "x$WITH_XZ" != xno ; then
804  AC_CHECK_LIB([lzma], [lzma_code],
805    [AC_CHECK_HEADERS([lzma.h],
806     [AC_DEFINE([FREECIV_HAVE_LIBLZMA], [1], [liblzma is available])
807  UTILITY_LIBS="${UTILITY_LIBS} -llzma"
808  libxz_available=true])])
809  if test "x$libxz_available" != "xtrue" ; then
810    if test "x$WITH_XZ" = "xyes" ; then
811      AC_MSG_ERROR([Could not find liblzma devel files])
812    fi
813    feature_xz=missing
814  fi
815fi
816
817UTILITY_LIBS="${UTILITY_LIBS} ${LTLIBINTL}"
818
819AC_SUBST([UTILITY_CFLAGS])
820AC_SUBST([UTILITY_LIBS])
821AC_SUBST([COMMON_LIBS])
822
823AC_ARG_ENABLE([crosser],
824  AS_HELP_STRING([--enable-crosser], [build version to be used with crosser environment]),
825[case "${enableval}" in
826  yes) crosser=yes
827       AC_DEFINE([CROSSER], [1], [this is crosser based build]) ;;
828  no)  crosser=no ;;
829  *)   AC_MSG_ERROR([bad value ${enableval} for --enable-crosser]) ;;
830esac], [crosser=no])
831if test x$crosser = xyes && test x$MINGW != xyes ; then
832  AC_MSG_ERROR([--enable-crosser is Windows build specific option])
833fi
834
835AC_ARG_WITH([cacert-path],
836  AS_HELP_STRING([--with-cacert-path], [path to ca cert bundle]),
837[case "${withval}" in
838 yes) AC_MSG_ERROR([Path must be given for --with-cacert-path]) ;;
839 *)   custom_cacert_path="${withval}" ;;
840esac])
841
842if test "x$custom_cacert_path" != "x" ; then
843  AC_DEFINE_UNQUOTED([CUSTOM_CACERT_PATH], ["$custom_cacert_path"], [Path to CA cert bundle])
844fi
845
846dnl Check thread implementation
847AC_MSG_CHECKING([for threads implementation])
848thread_impl=none
849
850CFLAGS_SAVE="${CFLAGS}"
851LIBS_SAVE="${LIBS}"
852
853if test x$crosser != xyes ; then
854  FC_C_FLAGS([-pthread], [], [CFLAGS])
855  FC_LD_FLAGS([-pthread], [], [LIBS])
856  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
857    [[return pthread_create(NULL, NULL, NULL, NULL);]])],
858    [AC_DEFINE([FREECIV_HAVE_PTHREAD], [1], [Use pthreads as thread implementation])
859    thread_impl=pthreads
860    AC_MSG_RESULT([pthreads])
861    AC_DEFINE([FREECIV_HAVE_THREAD_COND], [1], [Has thread condition variable implementation])])
862    thread_cond=true
863fi
864
865if test "x$thread_impl" = "xnone" ; then
866  CFLAGS="$CFLAGS_SAVE"
867  LDFLAGS="$LDFLAGS_SAVE"
868
869  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <windows.h>]],
870    [[CreateThread(NULL, 0, NULL, NULL, 0, NULL);]])],
871    [AC_DEFINE([FREECIV_HAVE_WINTHREADS], [1], [Use Windows threads as thread implementation])
872    thread_impl=windows
873    AC_MSG_RESULT([windows])])
874fi
875
876if test "x$thread_impl" = "xnone" ; then
877  AC_MSG_ERROR([No usable thread implementation available])
878fi
879
880if test "x$thread_cond" != "xtrue" ; then
881  feature_thr_cond=missing
882fi
883
884if test "x$MINGW" = "xyes" ; then
885  MWINDOWS_FLAG="-mwindows"
886else
887  MWINDOWS_FLAG=""
888fi
889
890dnl Check and choose clients
891if test "x$client" != "xno"; then
892
893  dnl Check for sound support, sets SOUND_CFLAGS, SOUND_LIBS, AUDIO_SDL
894  dnl Client gui checks need to know which mixer version this has selected
895  FC_CHECK_SOUND()
896
897  dnl if specified --with-xaw or --with-xaw3d, assume --enable-client=xaw
898  if test -n "$WITH_XAW" || test -n "$WITH_XAW3D"; then
899    if test "x$client" = "xauto" ; then
900      gui_xaw=yes
901      client=yes
902    elif test "x$client" = "xall" ; then
903      gui_xaw=yes
904    fi
905  fi
906
907  dnl if need to guess client, announce checking
908  if test "x$client" = "xauto"; then
909    AS_MESSAGE([checking for which client to compile:...])
910  elif test "x$client" = "xall" ; then
911    AS_MESSAGE([checking for which clients to compile:...])
912  fi
913
914  dnl Gtk-3.0-specific overrides
915  FC_GTK3_CLIENT
916
917  dnl Gtk-3.22-specific overrides
918  FC_GTK3_22_CLIENT
919
920  dnl Gtk-2.0-specific overrides
921  FC_GTK2_CLIENT
922
923  dnl QT-specific overrides
924  FC_QT_CLIENT
925
926  dnl SDL-specific overrides
927  FC_SDL_CLIENT
928
929  dnl SDL2-specific overrides
930  FC_SDL2_CLIENT
931
932  dnl Xaw-specific overrides
933  FC_XAW_CLIENT
934
935  dnl Stub-specific overrides
936  if test "x$gui_stub" = "xyes" || test "x$client" = "xall" ; then
937    gui_stub=yes
938    if test "x$client" = "xauto" ; then
939      client=yes
940    fi
941    gui_stub_libs="-lm"
942  fi
943
944  dnl If client still "auto", error out since we couldn't select any of them
945  if test "x$client" = "xauto" ; then
946    AC_MSG_ERROR([can not build any of the supported clients])
947  fi
948fi
949
950if test "x$client" = "xall" ; then
951  if test "x$gui_gtk2" = "xyes" ||
952     test "x$gui_gtk3_22" = "xyes" ||
953     test "x$gui_gtk3" = "xyes" ||
954     test "x$gui_sdl" = "xyes" ||
955     test "x$gui_sdl2" = "xyes" ||
956     test "x$gui_xaw" = "xyes" ||
957     test "x$gui_qt" = "xyes" ||
958     test "x$gui_stub" = "xyes" ; then
959    client=yes
960  else
961    client=no
962  fi
963fi
964
965FC_LD_FLAGS(["-Wl,-rpath=${lib_prefix}"], [], [LDFLAGS])
966
967AM_CONDITIONAL([CLIENT], [test "x$client" = "xyes"])
968
969AC_ARG_ENABLE([freeciv-manual],
970  AS_HELP_STRING([--enable-freeciv-manual=no/yes/wiki/html], [build freeciv-manual [wiki]]),
971[case "${enableval}" in
972  yes|wiki) fcmanual=wiki ;;
973  no)       fcmanual=no ;;
974  html)     fcmanual=html ;;
975  *) AC_MSG_ERROR([bad value ${enableval} for --enable-freeciv-manual]) ;;
976esac], [fcmanual=wiki])
977
978AM_CONDITIONAL([FCMANUAL], [test "x$fcmanual" != "xno"])
979
980if test x$fcmanual = xhtml ; then
981  AC_DEFINE([MANUAL_USE_HTML], [1], [Build freeciv-manual with html formatting])
982fi
983
984dnl freeciv-modpack checks
985AC_ARG_ENABLE([fcmp],
986  AS_HELP_STRING([--enable-fcmp=no/yes/gtk2/gtk3/qt/cli/all/auto], [build freeciv-modpack-program [auto]]),
987[fc_mp=${enableval}],
988[fc_mp=auto])
989
990fcmp_cli=no
991fcmp_gtk2=no
992fcmp_gtk3=no
993fcmp_qt=no
994fcmp_list=
995
996if test "x$fc_mp" = "xcli" ; then
997  dnl Only cli requested -> no gui needed
998  modinst=cli
999fi
1000
1001for mp in $(echo $fc_mp | $SED 's/,/ /g') ; do
1002  if test "x$mp" = "xno" ; then
1003    modinst=no
1004  elif test "x$mp" = "xauto" || test "x$mp" = "xyes" ; then
1005    modinst=auto
1006  elif test "x$mp" = "xall" ; then
1007    modinst=all
1008  else if test "x$mp" = "xgtk2"   ||
1009          test "x$mp" = "xgtk2.0" ||
1010          test "x$mp" = "xgtk20"  ||
1011          test "x$mp" = "xgtk-2.0" ; then
1012      req_fcmp_gtk2=yes
1013    elif test "x$mp" = "xgtk3"   ||
1014         test "x$mp" = "xgtk3.0" ||
1015         test "x$mp" = "xgtk30"  ||
1016         test "x$mp" = "xgtk-3.0" ; then
1017      req_fcmp_gtk3=yes
1018    elif test "x$mp" = "xqt" ; then
1019      req_fcmp_qt=yes
1020    elif test "x$mp" = "xcli" ; then
1021      req_fcmp_cli=yes
1022    elif test "x$mp" != "xyes" ; then
1023      AC_MSG_ERROR([bad value ${mp} for --enable-fcmp])
1024    fi
1025  fi
1026done
1027
1028if test "x$req_fcmp_gtk3" = "xyes" ||
1029   test "x$modinst" = "xall" || test "x$modinst" = "xauto" ; then
1030  PKG_CHECK_MODULES([GTK3MP], [gtk+-3.0 >= 3.8.0],
1031[
1032  GTK3MP_CFLAGS="$GTK3MP_CFLAGS -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_8 -DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_8"
1033  GTK3MP_CFLAGS="$GTK3MP_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36"
1034  PKG_CHECK_MODULES([GTHREAD_GTK3], [gthread-2.0],
1035[
1036  fcmp_gtk3=yes
1037  fcmp_list="$fcmp_list gtk3"
1038  mp_gtk3_cflags="$GTK3MP_CFLAGS $GTHREAD_GTK3_CFLAGS"
1039  mp_gtk3_libs="$GTK3MP_LIBS $GTHREAD_GTK3_LIBS"
1040  if test "x$MINGW" = "xyes"; then
1041    dnl Required to compile gtk3 on Windows platform
1042    mp_gtk3_cflags="$mp_gtk3_cflags -mms-bitfields"
1043    mp_gtk3_ldflags="$mp_gtk3_ldflags $MWINDOWS_FLAG"
1044  fi
1045
1046  if test "x$modinst" = "xauto" ; then
1047    modinst=found
1048  fi
1049], [fcmp_gtk3=no])], [fcmp_gtk3=no])
1050fi
1051
1052if test "x$req_fcmp_gtk3" = "xyes" && test "x$fcmp_gtk3" != "xyes" ; then
1053  AC_MSG_ERROR([Cannot build gtk3-version of freeciv-modpack as requested])
1054fi
1055
1056if test "x$req_fcmp_gtk2" = "xyes" ||
1057   test "x$modinst" = "xauto" || test "x$modinst" = "xall" ; then
1058  AM_PATH_GTK_2_0([2.12.0],
1059[
1060  PKG_CHECK_MODULES([GTHREAD_GTK2], [gthread-2.0],
1061[
1062  fcmp_gtk2=yes
1063  fcmp_list="$fcmp_list gtk2"
1064  mp_gtk2_cflags="$GTK2_CFLAGS $GTHREAD_GTK2_CFLAGS"
1065  mp_gtk2_libs="$GTK2_LIBS $GTHREAD_GTK2_LIBS"
1066  if test "x$MINGW" = "xyes"; then
1067     dnl Required to compile gtk2 on Windows platform
1068     mp_gtk2_cflags="$mp_gtk2_cflags -mms-bitfields"
1069     mp_gtk2_ldflags="$mp_gtk2_ldflags $MWINDOWS_FLAG"
1070  fi
1071
1072  if test "x$modinst" = "xauto" ; then
1073    modinst=found
1074  fi
1075], [])], [])
1076fi
1077
1078if test "x$req_fcmp_gtk2" = "xyes" && test "x$fcmp_gtk2" != "xyes" ; then
1079  AC_MSG_ERROR([Cannot build gtk2-version of freeciv-modpack as requested])
1080fi
1081
1082if test "x$req_fcmp_qt" = "xyes" ||
1083   test "x$modinst" = "xauto" || test "x$modinst" = "xall" ; then
1084
1085   if test "x$cxx_works" = "xyes" ; then
1086     FC_QT5
1087
1088     if test "x$fc_qt5_usable" = "xtrue" ; then
1089       fcmp_qt=yes
1090       fcmp_list="$fcmp_list qt"
1091
1092       mp_qt_cppflags=$FC_QT5_CPPFLAGS
1093       mp_qt_cxxflags=$FC_QT5_CXXFLAGS
1094       mp_qt_libs="$FC_QT5_LIBS $MWINDOWS_FLAG"
1095
1096       if test "x$modinst" = "xauto" ; then
1097         modinst=found
1098       fi
1099     fi
1100   fi
1101
1102fi
1103
1104if test "x$req_fcmp_qt" = "xyes" && test "x$fcmp_qt" != "xyes" ; then
1105  AC_MSG_ERROR([Cannot build Qt-version of freeciv-modpack as requested])
1106fi
1107
1108dnl Cli does not satisfy --enable-fcmp=auto as it's not an gui.
1109if test "x$req_fcmp_cli" = "xyes" || test "x$modinst" = "xall" ; then
1110  fcmp_cli=yes
1111  fcmp_list="$fcmp_list cli"
1112fi
1113
1114if test "x$modinst" != "xfound" &&
1115   test "x$modinst" != "xno" &&
1116   test "x$modinst" != "xcli" &&
1117   test "x$fcmp_gtk3" != "xyes" &&
1118   test "x$fcmp_gtk2" != "xyes" &&
1119   test "x$fcmp_qt" != "xyes" ;then
1120  AC_MSG_ERROR([Cannot build modpack installer with any gui])
1121fi
1122
1123if test "x$modinst" != "xno" && test "x$MINGW" != "xyes" ; then
1124  dnl Hack to get a run-time icon -- not needed on Windows
1125  mp_gtk2_cflags="$mp_gtk2_cflags -DMPICON_PATH=\"\\\"$datadir/freeciv/misc/mpicon.png\\\"\""
1126  mp_gtk3_cflags="$mp_gtk3_cflags -DMPICON_PATH=\"\\\"$datadir/freeciv/misc/mpicon.png\\\"\""
1127fi
1128
1129if test "x$fcmp_list" = "x" ; then
1130  fcmp_list="none"
1131fi
1132
1133AM_CONDITIONAL([MODINST], [test "x$modinst" != "xno"])
1134AM_CONDITIONAL([MODINST_GTK3], [test "x$fcmp_gtk3" = "xyes"])
1135AM_CONDITIONAL([MODINST_GTK2], [test "x$fcmp_gtk2" = "xyes"])
1136AM_CONDITIONAL([MODINST_QT], [test "x$fcmp_qt" = "xyes"])
1137AM_CONDITIONAL([MODINST_CLI], [test "x$fcmp_cli" = "xyes"])
1138
1139AC_ARG_ENABLE([ruledit],
1140  AS_HELP_STRING([--enable-ruledit], [build freeciv-ruledit (WIP)]),
1141[case "${enableval}" in
1142  yes)  ruledit=yes ;;
1143  no)   ruledit=no ;;
1144  test) ruledit=test ;;
1145  *)   AC_MSG_ERROR([bad value ${enableval} for --enable-ruledit]) ;;
1146esac], [ruledit=test])
1147if test "x$ruledit" = "xyes" || test "x$ruledit" = "xtest" ; then
1148  if test "x$cxx_works" = "xyes" ; then
1149    FC_QT5
1150
1151    if test "x$fc_qt5_usable" = "xtrue" ; then
1152      ruledit_cppflags=$FC_QT5_CPPFLAGS
1153      ruledit_cxxflags=$FC_QT5_CXXFLAGS
1154      ruledit_libs=$FC_QT5_LIBS
1155      ruledit=yes
1156      ruledit_libs="$ruledit_libs $MWINDOWS_FLAG"
1157    elif test "x$ruledit" = "xyes" ; then
1158      AC_MSG_ERROR([Qt5 not found for building freeciv-ruledit])
1159    fi
1160  elif test "x$ruledit" = "xyes" ; then
1161    AC_MSG_ERROR([No working C++ compiler found for building freeciv-ruledit])
1162  fi
1163fi
1164if test "x$ruledit" = "xtest" ; then
1165  dnl Still not set to 'yes' so failed tests
1166  ruledit=no
1167  feature_ruledit=missing
1168fi
1169AM_CONDITIONAL([RULEDIT], [test "x$ruledit" = "xyes"])
1170
1171AC_SUBST([gui_gtk2_cflags])
1172AC_SUBST([gui_gtk2_libs])
1173AC_SUBST([gui_gtk2_ldflags])
1174AC_SUBST([gui_gtk3_22_cflags])
1175AC_SUBST([gui_gtk3_22_libs])
1176AC_SUBST([gui_gtk3_22_ldflags])
1177AC_SUBST([gui_gtk3_cflags])
1178AC_SUBST([gui_gtk3_libs])
1179AC_SUBST([gui_gtk3_ldflags])
1180AC_SUBST([gui_sdl_cflags])
1181AC_SUBST([gui_sdl_libs])
1182AC_SUBST([gui_sdl_ldflags])
1183AC_SUBST([gui_sdl2_cflags])
1184AC_SUBST([gui_sdl2_libs])
1185AC_SUBST([gui_sdl2_ldflags])
1186AC_SUBST([gui_xaw_cflags])
1187AC_SUBST([gui_xaw_libs])
1188AC_SUBST([gui_xaw_ldflags])
1189AC_SUBST([gui_qt_cppflags])
1190AC_SUBST([gui_qt_cflags])
1191AC_SUBST([gui_qt_cxxflags])
1192AC_SUBST([gui_qt_libs])
1193AC_SUBST([gui_qt_ldflags])
1194AC_SUBST([gui_stub_cflags])
1195AC_SUBST([gui_stub_libs])
1196AC_SUBST([gui_stub_ldflags])
1197AC_SUBST([mp_cli_cflags])
1198AC_SUBST([mp_cli_libs])
1199AC_SUBST([mp_cli_ldflags])
1200AC_SUBST([mp_gtk2_cflags])
1201AC_SUBST([mp_gtk2_libs])
1202AC_SUBST([mp_gtk2_ldflags])
1203AC_SUBST([mp_gtk3_cflags])
1204AC_SUBST([mp_gtk3_libs])
1205AC_SUBST([mp_gtk3_ldflags])
1206AC_SUBST([mp_qt_cppflags])
1207AC_SUBST([mp_qt_cxxflags])
1208AC_SUBST([mp_qt_libs])
1209AC_SUBST([ruledit_cppflags])
1210AC_SUBST([ruledit_cxxflags])
1211AC_SUBST([ruledit_libs])
1212AC_SUBST([SOUND_CFLAGS])
1213AC_SUBST([SOUND_LIBS])
1214AC_SUBST([VERSION_LABEL])
1215AC_SUBST([HOST_PATH_SEPARATOR])
1216AC_SUBST([HOST_DIR_SEPARATOR])
1217AM_CONDITIONAL(AUDIO_SDL, test "x$SDL_mixer" != "xno")
1218AM_CONDITIONAL(CLIENT_GUI_SDL, test "x$gui_sdl" = "xyes")
1219AM_CONDITIONAL(CLIENT_GUI_SDL2, test "x$gui_sdl2" = "xyes")
1220AM_CONDITIONAL(CLIENT_GUI_GTK_2_0, test "x$gui_gtk2" = "xyes")
1221AM_CONDITIONAL(CLIENT_GUI_GTK_3_22, test "x$gui_gtk3_22" = "xyes")
1222AM_CONDITIONAL(CLIENT_GUI_GTK_3_0, test "x$gui_gtk3" = "xyes")
1223AM_CONDITIONAL(CLIENT_GUI_XAW, test "x$gui_xaw" = "xyes")
1224AM_CONDITIONAL(CLIENT_GUI_QT, test "x$gui_qt" = "xyes")
1225AM_CONDITIONAL(CLIENT_GUI_STUB, test "x$gui_stub" = "xyes")
1226AM_CONDITIONAL(MINGW, test x"$MINGW" = "xyes")
1227
1228dnl Additional client libraries:
1229if test "x$client" = "xyes"; then
1230    CLIENT_LIBS=" -lm "
1231    AC_SUBST(CLIENT_LIBS)
1232fi
1233
1234dnl Checks for additional server libraries:
1235if test "x$server" = "xyes"; then
1236    SERVER_LIBS="-lm ${SERVER_LIBS}"
1237
1238    dnl Some systems (e.g., BeOS) need this lib
1239    AC_CHECK_LIB(bind, gethostbyaddr, SERVER_LIBS="-lbind $SERVER_LIBS")
1240
1241    dnl Readline library and header files.
1242    FC_HAS_READLINE()
1243    AC_SUBST([SERVER_LIBS])
1244    AC_SUBST([SRV_LIB_LIBS])
1245fi
1246
1247AC_CHECK_LIB(nls,main)
1248
1249dnl Checks for header files.
1250AC_HEADER_SYS_WAIT
1251AC_CHECK_HEADERS([fcntl.h sys/utsname.h sys/file.h signal.h strings.h execinfo.h libgen.h time.h])
1252AC_CHECK_HEADERS([sys/time.h], [AC_DEFINE([FREECIV_HAVE_SYS_TIME_H], [1], [sys/time.h available])])
1253AC_CHECK_HEADERS([unistd.h], [AC_DEFINE([FREECIV_HAVE_UNISTD_H], [1], [unistd.h available])])
1254AC_CHECK_HEADERS([locale.h], [AC_DEFINE([FREECIV_HAVE_LOCALE_H], [1], [locale.h available])])
1255AC_CHECK_HEADERS([libintl.h], [AC_DEFINE([FREECIV_HAVE_LIBINTL_H], [1], [libint.h available])])
1256AC_HEADER_STDBOOL
1257if test $ac_cv_header_stdbool_h = yes; then
1258  AC_DEFINE([FREECIV_HAVE_STDBOOL_H], [1], [Have standard compliant stdbool.h])
1259fi
1260
1261AC_CHECK_HEADERS([pwd.h])
1262
1263dnl Avoid including the unix emulation layer if we build mingw executables
1264dnl There would be type conflicts between winsock and bsd/unix includes
1265if test "x$MINGW" != "xyes"; then
1266  AC_CHECK_HEADERS([arpa/inet.h netdb.h sys/ioctl.h sys/signal.h sys/termio.h sys/uio.h termios.h])
1267  AC_CHECK_HEADERS([sys/select.h], [AC_DEFINE([FREECIV_HAVE_SYS_SELECT_H], [1], [sys/select.h available])])
1268  AC_CHECK_HEADERS([netinet/in.h], [AC_DEFINE([FREECIV_HAVE_NETINET_IN_H], [1], [netinet/in.h available])])
1269fi
1270if test "x$gui_xaw" = "xyes" ; then
1271  dnl Want to get appropriate -I flags:
1272  fc_save_CPPFLAGS="$CPPFLAGS"
1273  CPPFLAGS="$CPPFLAGS $gui_xaw_cflags"
1274  AC_CHECK_HEADER(X11/xpm.h, ,
1275    AC_MSG_ERROR(need X11/xpm.h header; perhaps try/adjust --with-xpm-include))
1276  CPPFLAGS="$fc_save_CPPFLAGS"
1277fi
1278
1279dnl Checks for typedefs, structures, and compiler characteristics.
1280AC_C_CONST
1281AC_STRUCT_TM
1282AC_CHECK_TYPES([socklen_t], [AC_DEFINE([FREECIV_HAVE_SOCKLEN_T], [1], [Have socklen_t type defined])],
1283[],
1284[#ifdef FREECIV_HAVE_SYS_TYPES_H
1285#include <sys/types.h>
1286#endif
1287#ifdef FREECIV_HAVE_SYS_SOCKET_H
1288#include <sys/socket.h>
1289#endif
1290#ifdef FREECIV_HAVE_WS2TCPIP_H
1291#include <ws2tcpip.h>
1292#endif
1293])
1294AC_TYPE_INTPTR_T
1295dnl Headers that might contain the intptr_t definition found earlier
1296AC_CHECK_HEADERS([inttypes.h],
1297  [AC_DEFINE([FREECIV_HAVE_INTTYPES_H], [1], [inttypes.h available])])
1298AC_CHECK_HEADERS([stdint.h],
1299  [AC_DEFINE([FREECIV_HAVE_STDINT_H], [1], [stdint.h available])])
1300
1301dnl Checks for library functions.
1302AC_FUNC_FORK
1303AC_FUNC_STRCOLL
1304AC_FUNC_VPRINTF
1305AC_FUNC_FSEEKO
1306
1307dnl Windows vsnprintf doesn't support argument reordering (see PR#12932)
1308if test "x$MINGW" != "xyes"; then
1309dnl The use of both FC_FUNC_VSNPRINTF and AC_CHECK_FUNCS(vsnprintf) is
1310dnl deliberate.
1311FC_FUNC_VSNPRINTF
1312AC_CHECK_FUNCS([vsnprintf])
1313fi
1314
1315AC_CHECK_FUNCS([bind connect fileno flock ftime gethostbyname gethostname])
1316AC_CHECK_FUNCS([getpwuid inet_aton select snooze strcasecmp strcasestr])
1317AC_CHECK_FUNCS([strerror strlcat strlcpy strncasecmp strstr uname nanosleep])
1318AC_CHECK_FUNCS([usleep getline _strcoll stricoll _stricoll strcasecoll backtrace])
1319
1320dnl Possible random sources
1321AC_CHECK_HEADERS([sys/random.h])
1322AC_CHECK_HEADERS([bcrypt.h], [bcrypt_h_found=yes], [bcrypt_h_found=no])
1323if test "x$bcrypt_h_found" = "xyes" ; then
1324  dnl Cygwin would find the symbol in library despite not finding the header,
1325  dnl leading to compile time error if we set HAVE_BCRYPTGENRANDOM
1326  AC_CHECK_LIB([bcrypt], [BCryptGenRandom], [
1327    AC_DEFINE([HAVE_BCRYPTGENRANDOM], [1], [BCryptGenRandom() available])
1328    UTILITY_LIBS="${UTILITY_LIBS} -lbcrypt" ])
1329fi
1330AC_CHECK_FUNCS([getentropy clock_gettime])
1331
1332if test "x$MINGW" != "xyes" ; then
1333  dnl /dev/urandom could be found within msys2 environment, but it would not
1334  dnl be available in the final target environment when freeciv gets installed.
1335  dnl Just don't check for it in Windows.
1336  AC_CACHE_VAL([ac_cv_dev_urandom],
1337    [if test "x$cross_compiling" != "xyes" ; then
1338       AC_CHECK_FILES([/dev/urandom], [ac_cv_dev_urandom=yes], [ac_cv_dev_urandom=no])
1339     else
1340       dnl Pessimistic default when cross-compiling
1341       ac_cv_dev_urandom=no
1342     fi])
1343  if test "x${ac_cv_dev_urandom}" = "xyes" ; then
1344    AC_DEFINE([HAVE_USABLE_URANDOM], [1], [Build in /dev/urandom support])
1345  fi
1346fi
1347
1348dnl Possible "-Wmissing-declarations" and "-Werror" will prune out
1349dnl cases where we should not use _mkdir() even if it's possible to link against it
1350fc_save_CPPFLAGS="$CPPFLAGS"
1351CPPFLAGS="$CPPFLAGS -Werror $EXTRA_DEBUG_CFLAGS"
1352AC_CHECK_FUNCS([_mkdir])
1353CPPFLAGS="$fc_save_CPPFLAGS"
1354
1355AC_MSG_CHECKING(for working gettimeofday)
1356  FC_CHECK_GETTIMEOFDAY_RUNTIME(,AC_DEFINE([HAVE_GETTIMEOFDAY], [1],
1357	[Define if the gettimeofday function works and is sane.]),)
1358
1359AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>]],
1360[[struct ip_mreqn req; req.imr_ifindex = 0;]])],
1361[AC_DEFINE([HAVE_IP_MREQN], [1], [struct ip_mreqn available])])
1362
1363dnl Check for extra socket libraries.
1364dnl If the AC_CHECK_FUNCS check finds the function, we don't look any
1365dnl further.  This is rumoured to prevent choosing the wrong libs on IRIX.
1366if test $ac_cv_func_gethostbyname = no; then
1367  AC_CHECK_LIB(nsl, gethostbyname, LIBS="-lnsl $LIBS")
1368fi
1369if test $ac_cv_func_connect = no; then
1370  AC_CHECK_LIB(socket, connect, LIBS="-lsocket $LIBS")
1371fi
1372if test $ac_cv_func_bind = no; then
1373  AC_CHECK_LIB(bind, gethostbyaddr, LIBS="-lbind $LIBS")
1374fi
1375
1376dnl Windows fdopen does not work with sockets.
1377if test "x$MINGW" != "xyes"; then
1378  AC_CHECK_FUNCS(fdopen)
1379fi
1380
1381dnl We would AC_CHECK_FUNCS for socket as well, except it is complicated
1382dnl by the fact that the -lsocket is in X_EXTRA_LIBS and/or SERVER_LIBS,
1383dnl and not in LIBS.
1384
1385dnl Now check if non blocking sockets are possible
1386dnl (if fcntl or ioctl exists)
1387
1388AC_CHECK_FUNC([fcntl],
1389              [AC_DEFINE([HAVE_FCNTL], [1], [fcntl support])
1390               AC_DEFINE([NONBLOCKING_SOCKETS], [1], [nonblocking sockets support])],
1391               [AC_CHECK_FUNC([ioctl],
1392                             [AC_DEFINE([HAVE_IOCTL], [1], [ioctl support])
1393                              AC_DEFINE([NONBLOCKING_SOCKETS], [1], [nonblocking sockets support])])])
1394
1395dnl Checks if SIGPIPE is usable
1396AC_MSG_CHECKING([for SIGPIPE])
1397AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]], [[signal (SIGPIPE, SIG_IGN)]])],[AC_MSG_RESULT([yes])
1398                AC_DEFINE([HAVE_SIGPIPE], [1], [sigpipe support])],[AC_MSG_RESULT([no])])
1399
1400dnl export where the datadir is going to be installed
1401FC_EXPAND_DIR(FREECIV_DATADIR, "$datadir/freeciv")
1402
1403if test x"$MINGW" = xyes ; then
1404  DEFAULT_SAVE_PATH=".;~\\\\\\\\.freeciv\\\\\\\\saves"
1405  if test x$crosser = xyes ; then
1406    FC_CONF_PATH="../etc/freeciv"
1407    DEFAULT_DATA_PATH=".;data;~/.freeciv/$DATASUBDIR;$datadir/freeciv;../share/freeciv"
1408    DEFAULT_SCENARIO_PATH=".;data/scenarios;~/.freeciv/$DATASUBDIR/scenarios;~/.freeciv/scenarios;$datadir/freeciv/scenarios;../share/freeciv/scenarios"
1409  else
1410    FC_CONF_PATH="etc\\\\\\\\freeciv"
1411    DEFAULT_DATA_PATH=".;data;~\\\\\\\\.freeciv\\\\\\\\$DATASUBDIR;$datadir\\\\\\\\freeciv"
1412    DEFAULT_SCENARIO_PATH=".;data\\\\\\\\scenarios;~\\\\\\\\.freeciv\\\\\\\\$DATASUBDIR\\\\\\\\scenarios;~\\\\\\\\.freeciv\\\\\\\\scenarios;$datadir\\\\\\\\freeciv\\\\\\\\scenarios"
1413  fi
1414elif test x"$HAIKU" = xyes ; then
1415  FC_CONF_PATH="$sysconfdir/freeciv"
1416  DEFAULT_DATA_PATH=".:data:~/config/settings/freeciv/$DATASUBDIR:$datadir/freeciv"
1417  DEFAULT_SAVE_PATH=".:~/config/settings/freeciv/saves"
1418  DEFAULT_SCENARIO_PATH=".:data/scenarios:~/config/settings/freeciv/$DATASUBDIR/scenarios:~/config/settings/freeciv/scenarios:$datadir/freeciv/scenarios"
1419else
1420  FC_CONF_PATH="$sysconfdir/freeciv"
1421  DEFAULT_DATA_PATH=".:data:~/.freeciv/$DATASUBDIR:$datadir/freeciv"
1422  DEFAULT_SAVE_PATH=".:~/.freeciv/saves"
1423  DEFAULT_SCENARIO_PATH=".:data/scenarios:~/.freeciv/$DATASUBDIR/scenarios:~/.freeciv/scenarios:$datadir/freeciv/scenarios"
1424fi
1425CPPFLAGS="$CPPFLAGS -DFC_CONF_PATH=\"\\\"$FC_CONF_PATH\\\"\""
1426CPPFLAGS="$CPPFLAGS -DDEFAULT_DATA_PATH=\"\\\"$DEFAULT_DATA_PATH\\\"\""
1427CPPFLAGS="$CPPFLAGS -DDEFAULT_SAVE_PATH=\"\\\"$DEFAULT_SAVE_PATH\\\"\""
1428CPPFLAGS="$CPPFLAGS -DDEFAULT_SCENARIO_PATH=\"\\\"$DEFAULT_SCENARIO_PATH\\\"\""
1429
1430dnl This has to be last library
1431if test -n "$WITH_EFENCE"; then
1432  AC_CHECK_LIB(efence, malloc, [
1433  if test "x$LIBS" = "x"; then
1434    LIBS = -lefence
1435  else
1436    LIBS="$LIBS -lefence"
1437  fi])
1438fi
1439
1440AC_ARG_ENABLE([sys-lua],
1441  AS_HELP_STRING([--enable-sys-lua], [use lua from system instead of one from freeciv tree [test]]),
1442[case "${enableval}" in
1443  yes)
1444    sys_lua=true ;;
1445  no)
1446    sys_lua=false ;;
1447  test)
1448    sys_lua=test ;;
1449  *)   AC_MSG_ERROR([bad value ${enableval} for --enable-sys-lua]) ;;
1450esac], [sys_lua=test])
1451
1452dnl There's wide divergence on what the pkg-config file for Lua is called
1453dnl See http://lua-users.org/lists/lua-l/2008-09/msg00184.html
1454if test "x$sys_lua" = "xtrue" || test "x$sys_lua" = "xtest" ; then
1455  PKG_CHECK_MODULES([LUA], [lua5.3], [sys_lua=true],
1456    [PKG_CHECK_MODULES([LUA], [lua-5.3], [sys_lua=true],
1457      [PKG_CHECK_MODULES([LUA], [lua >= 5.3 lua < 5.4], [sys_lua=true],
1458[if test "x$sys_lua" = "xtrue" ; then
1459  AC_MSG_ERROR([Use of included lua disabled, and no lua found from system])
1460fi
1461feature_syslua=missing
1462sys_lua=false])])])
1463fi
1464
1465if test "x$sys_lua" != "xtrue" ; then
1466  dnl Checks needed for included lua.
1467  gl_FUNC_MKSTEMP
1468  if test "x$gl_cv_func_working_mkstemp" = xyes ; then
1469    dnl if only "guessing yes", do not try to use mkstemp, but fallback
1470    AC_DEFINE([HAVE_MKSTEMP], [1], [Have working mkstemp])
1471  fi
1472  AC_CHECK_FUNCS([popen pclose _longjmp _setjmp gmtime_r localtime_r])
1473
1474  LUA_CFLAGS="-I\$(top_srcdir)/dependencies/lua-5.3/src"
1475  LUA_LIBS="\$(top_builddir)/dependencies/lua-5.3/src/liblua.la"
1476fi
1477
1478AC_SUBST([LUA_CFLAGS])
1479AC_SUBST([LUA_LIBS])
1480AM_CONDITIONAL([SYS_LUA], [test "x$sys_lua" = "xtrue"])
1481
1482if test x$enable_fcdb = xyes ; then
1483  LUASQL_CFLAGS="-I\$(top_srcdir)/dependencies/luasql/src"
1484  LUASQL_LIBS="\$(top_builddir)/dependencies/luasql/src/libluasql_base.la"
1485  if test x$fcdb_mysql = xyes ; then
1486    LUASQL_LIBS="$LUASQL_LIBS \$(top_builddir)/dependencies/luasql/src/libluasql_mysql.la"
1487  fi
1488  if test x$fcdb_postgres = xyes ; then
1489    LUASQL_LIBS="$LUASQL_LIBS \$(top_builddir)/dependencies/luasql/src/libluasql_postgres.la"
1490  fi
1491  if test x$fcdb_sqlite3 = xyes ; then
1492    LUASQL_LIBS="$LUASQL_LIBS \$(top_builddir)/dependencies/luasql/src/libluasql_sqlite3.la"
1493  fi
1494  LUASQL_AS_DEPENDENCY="$LUASQL_LIBS"
1495  LUASQL_LIBS="$LUASQL_LIBS $FCDB_MYSQL_LIBS $FCDB_POSTGRES_LIBS $FCDB_SQLITE3_LIBS"
1496
1497  AC_SUBST([LUASQL_CFLAGS])
1498  AC_SUBST([LUASQL_LIBS])
1499  AC_SUBST([LUASQL_AS_DEPENDENCY])
1500fi
1501
1502AC_ARG_ENABLE([sys-tolua-cmd],
1503  AS_HELP_STRING([--enable-sys-tolua-cmd], [use tolua command from build system instead of one from freeciv tree [true_when_cross-compiling]]),
1504[case "${enableval}" in
1505  yes)
1506    sys_tolua_cmd=true ;;
1507  no)
1508    if test "x$cross_compiling" = "xyes" ; then
1509      AC_MSG_ERROR([Must use external build system tolua command when cross-compiling])
1510    fi
1511    sys_tolua_cmd=false ;;
1512  *)
1513    sys_tolua_cmd=${enableval} ;;
1514esac], [
1515if test "x$cross_compiling" = "xyes" ; then
1516  sys_tolua_cmd=true
1517else
1518  sys_tolua_cmd=test
1519fi])
1520
1521if test "x$sys_tolua_cmd" = "xtrue" || test "x$sys_tolua_cmd" = "xtest" ; then
1522  AC_PATH_PROG([TOLUA], [tolua], [notfound])
1523  if test "x$TOLUA" = "xnotfound" ; then
1524    if test "x$sys_tolua_cmd" = "xtest" ; then
1525      TOLUA="\$(top_builddir)/dependencies/tolua-5.2/src/bin/tolua$EXEEXT"
1526      sys_tolua_cmd=false
1527    else
1528      AC_MSG_WARN([tolua command not found])
1529      TOLUA="unavailable"
1530    fi
1531    feature_systolua_cmd=missing
1532  else
1533    sys_tolua_cmd=true
1534  fi
1535elif test "x$sys_tolua_cmd" != "xfalse" ; then
1536  TOLUA=$sys_tolua_cmd
1537else
1538  TOLUA="\$(top_builddir)/dependencies/tolua-5.2/src/bin/tolua$EXEEXT"
1539fi
1540
1541AC_SUBST([TOLUA])
1542
1543TOLUA_CFLAGS="-I\$(top_srcdir)/dependencies/tolua-5.2/include"
1544TOLUA_LIBS="\$(top_builddir)/dependencies/tolua-5.2/src/lib/libtolua.la"
1545AC_SUBST([TOLUA_CFLAGS])
1546AC_SUBST([TOLUA_LIBS])
1547
1548AM_CONDITIONAL([SYS_TOLUA_CMD], [test "x$sys_tolua_cmd" != "xfalse"])
1549
1550dnl The BeOS sys/uio.h is broken.  This kludges it out of existence.
1551dnl (This still causes lots of spurious changes to fc_config.h on BeOS.)
1552AC_CONFIG_COMMANDS([fc_default-5],[[if test x`uname -s` = xBeOS ; then
1553     if grep '#define HAVE_SYS_UIO_H 1' fc_config.h >/dev/null 2>&1 ; then
1554       echo kluging fc_config.h
1555       mv -f fc_config.h fc_config.h.tmp
1556       sed -e 's/#define HAVE_SYS_UIO_H 1/#undef HAVE_SYS_UIO_H/g' fc_config.h.tmp > fc_config.h
1557       rm fc_config.h.tmp
1558     fi
1559   fi]],[[]])
1560
1561CFLAGS="$EXTRA_DEBUG_CFLAGS $CFLAGS"
1562CXXFLAGS="$EXTRA_DEBUG_CXXFLAGS $CXXFLAGS"
1563LDFLAGS="$EXTRA_DEBUG_LDFLAGS $LDFLAGS"
1564
1565dnl Check this when -Werror is already set, if we're going to set it
1566FC_VALUE_AFTER_EXIT
1567
1568if test "x$gui_xaw" = "xyes" ; then
1569  AC_CACHE_CHECK([['const' for XawListChange()]], [ac_cv_const_for_xaw_list_change],
1570    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xaw/List.h>
1571]],
1572      [char *test_strings[[2]];
1573XawListChange(NULL, test_strings, 0, 0, False);])],
1574      [ac_cv_const_for_xaw_list_change=no],
1575      [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xaw/List.h>
1576]],
1577        [const char *test_strings[[2]];
1578XawListChange(NULL, test_strings, 0, 0, False);])],
1579        [ac_cv_const_for_xaw_list_change=yes], [ac_cv_const_for_xaw_list_change=unknown])])])
1580  if test "x${ac_cv_const_for_xaw_list_change}" = "xyes" ; then
1581    AC_DEFINE([CONST_FOR_XAW_LIST_CHANGE], [const], [[Use const for XawListChange() parameter]])
1582  else
1583    AC_DEFINE([CONST_FOR_XAW_LIST_CHANGE], [], [[Do not use const for XawListChange() parameter]])
1584  fi
1585fi
1586
1587dnl Rebuild 'configure' whenever fc_version changes, if maintainer mode enabled.
1588AC_SUBST([CONFIGURE_DEPENDENCIES], ["$CONFIGURE_DEPENDENCIES \$(top_srcdir)/fc_version"])
1589
1590dnl Make sure that fc_config.h changes when ever CPPFLAGS, CFLAGS or CXXFLAGS
1591dnl change so everything gets rebuilt. LDFLAGS is not handled here
1592dnl since change in it should not cause recompilation, only relinking.
1593dnl Note: Variables are named FC_STORE_* instead of FC_*_STORE in order to
1594dnl make them appear next to each other in fc_config.h.
1595FC_STORE_CPPFLAGS="$(echo $CPPFLAGS | $SED 's/\\/\\\\/g' | $SED 's/\"/\\\"/g')"
1596AC_DEFINE_UNQUOTED([FC_STORE_CPPFLAGS], ["$FC_STORE_CPPFLAGS"],
1597                   [These are the CPPFLAGS used in compilation])
1598FC_STORE_CFLAGS="$(echo $CFLAGS | $SED 's/\\/\\\\/g' | $SED 's/\"/\\\"/g')"
1599AC_DEFINE_UNQUOTED([FC_STORE_CFLAGS], ["$FC_STORE_CFLAGS"],
1600                   [These are the CFLAGS used in compilation])
1601FC_STORE_CXXFLAGS="$(echo $CXXFLAGS | $SED 's/\\/\\\\/g' | $SED 's/\"/\\\"/g')"
1602AC_DEFINE_UNQUOTED([FC_STORE_CXXFLAGS], ["$FC_STORE_CXXFLAGS"],
1603                   [These are the CXXFLAGS used in compilation])
1604
1605dnl If old default of AR_FLAGS is otherwise being used (because of older automake),
1606dnl replace it with one without 'u'
1607if test "x$AR_FLAGS" = "xcru" ; then
1608  AR_FLAGS="cr"
1609fi
1610
1611AC_CONFIG_FILES([Makefile
1612          data/Makefile
1613	  data/hex2t/Makefile
1614          data/hexemplio/Makefile
1615	  data/amplio2/Makefile
1616	  data/buildings/Makefile
1617	  data/flags/Makefile
1618	  data/misc/Makefile
1619	  data/cimpletoon/Makefile
1620	  data/trident/Makefile
1621	  data/isophex/Makefile
1622	  data/isotrident/Makefile
1623	  data/stdsounds/Makefile
1624          data/stdmusic/Makefile
1625          data/override/Makefile
1626	  data/default/Makefile
1627	  data/classic/Makefile
1628	  data/multiplayer/Makefile
1629	  data/experimental/Makefile
1630          data/civ2civ3/Makefile
1631	  data/civ1/Makefile
1632	  data/civ2/Makefile
1633          data/sandbox/Makefile
1634	  data/scenarios/Makefile
1635	  data/nation/Makefile
1636	  data/themes/Makefile
1637	  data/themes/gui-gtk-2.0/Makefile
1638	  data/themes/gui-gtk-2.0/Freeciv/Makefile
1639	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Makefile
1640	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Arrows/Makefile
1641	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Buttons/Makefile
1642	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Check-Radio/Makefile
1643	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Combo/Makefile
1644	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Frame-Gap/Makefile
1645	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Handles/Makefile
1646	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Lines/Makefile
1647	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/ListHeaders/Makefile
1648	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Menu-Menubar/Makefile
1649	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Others/Makefile
1650	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Panel/Makefile
1651	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/ProgressBar/Makefile
1652	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Range/Makefile
1653	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Scrollbars/Makefile
1654	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Shadows/Makefile
1655	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Spin/Makefile
1656	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Tabs/Makefile
1657	  data/themes/gui-gtk-2.0/Freeciv/gtk-2.0/Toolbar/Makefile
1658	  data/themes/gui-gtk-3.0/Makefile
1659	  data/themes/gui-gtk-3.0/Freeciv/Makefile
1660	  data/themes/gui-gtk-3.0/Freeciv/gtk-3.0/Makefile
1661	  data/themes/gui-gtk-3.22/Makefile
1662	  data/themes/gui-gtk-3.22/Freeciv/Makefile
1663	  data/themes/gui-gtk-3.22/Freeciv/gtk-3.0/Makefile
1664	  data/themes/gui-qt/Makefile
1665	  data/themes/gui-qt/icons/Makefile
1666	  data/themes/gui-qt/Classic/Makefile
1667	  data/themes/gui-qt/Necrophos/Makefile
1668	  data/themes/gui-qt/NightStalker/Makefile
1669	  data/themes/gui-qt/System/Makefile
1670	  data/themes/gui-sdl/Makefile
1671	  data/themes/gui-sdl/human/Makefile
1672	  data/themes/gui-sdl2/Makefile
1673	  data/themes/gui-sdl2/human/Makefile
1674	  data/wonders/Makefile
1675	  data/icons/Makefile
1676	  utility/Makefile
1677	  dependencies/Makefile
1678	  dependencies/lua-5.3/Makefile
1679          dependencies/lua-5.3/src/Makefile
1680	  dependencies/tolua-5.2/Makefile
1681	  dependencies/tolua-5.2/src/Makefile
1682	  dependencies/tolua-5.2/src/lib/Makefile
1683          dependencies/tolua-5.2/src/bin/Makefile
1684          dependencies/luasql/Makefile
1685          dependencies/luasql/src/Makefile
1686          dependencies/cvercmp/Makefile
1687	  common/Makefile
1688          common/aicore/Makefile
1689          common/scriptcore/Makefile
1690	  ai/Makefile
1691          ai/default/Makefile
1692          ai/classic/Makefile
1693          ai/stub/Makefile
1694          ai/threaded/Makefile
1695	  tests/Makefile
1696  	  win32/Makefile
1697	  client/Makefile
1698	  client/agents/Makefile
1699	  client/include/Makefile
1700	  client/gui-sdl/Makefile
1701          client/gui-sdl2/Makefile
1702	  client/gui-gtk-2.0/Makefile
1703	  client/gui-gtk-3.0/Makefile
1704          client/gui-gtk-3.22/Makefile
1705	  client/gui-xaw/Makefile
1706          client/gui-qt/Makefile
1707	  client/gui-stub/Makefile
1708          client/luascript/Makefile
1709	  server/Makefile
1710          server/advisors/Makefile
1711	  server/generator/Makefile
1712	  server/scripting/Makefile
1713          tools/Makefile
1714          tools/ruledit/Makefile
1715          gen_headers/Makefile
1716          translations/Makefile
1717	  translations/freeciv/Makefile.in
1718	  translations/nations/Makefile.in
1719          translations/ruledit/Makefile.in
1720	  doc/Makefile
1721	  doc/man/Makefile
1722          doc/man/freeciv.6
1723          doc/man/freeciv-client.6
1724          doc/man/freeciv-server.6
1725          doc/man/freeciv-manual.6
1726	  doc/man/freeciv-modpack.6
1727	  doc/man/freeciv-ruledit.6
1728	  doc/ca/Makefile
1729	  doc/de/Makefile
1730	  doc/fr/Makefile
1731	  doc/it/Makefile
1732	  doc/ja/Makefile
1733	  doc/nl/Makefile
1734	  doc/sv/Makefile
1735          bootstrap/Makefile
1736	  data/Freeciv
1737          lua/Makefile
1738	  client/org.freeciv.gtk3.desktop:bootstrap/org.freeciv.gtk3.desktop.in
1739	  client/org.freeciv.gtk322.desktop:bootstrap/org.freeciv.gtk322.desktop.in
1740          client/org.freeciv.gtk2.desktop:bootstrap/org.freeciv.gtk2.desktop.in
1741          client/org.freeciv.sdl.desktop:bootstrap/org.freeciv.sdl.desktop.in
1742          client/org.freeciv.sdl2.desktop:bootstrap/org.freeciv.sdl2.desktop.in
1743          client/org.freeciv.qt.desktop:bootstrap/org.freeciv.qt.desktop.in
1744	  server/org.freeciv.server.desktop:bootstrap/org.freeciv.server.desktop.in
1745	  tools/org.freeciv.mp.gtk3.desktop:bootstrap/org.freeciv.mp.gtk3.desktop.in
1746	  tools/org.freeciv.mp.gtk2.desktop:bootstrap/org.freeciv.mp.gtk2.desktop.in
1747	  tools/org.freeciv.mp.qt.desktop:bootstrap/org.freeciv.mp.qt.desktop.in
1748	  tools/ruledit/org.freeciv.ruledit.desktop:bootstrap/org.freeciv.ruledit.desktop.in
1749          client/freeciv-gtk2.appdata.xml:bootstrap/freeciv-gtk2.appdata.xml.in
1750          client/freeciv-gtk3.appdata.xml:bootstrap/freeciv-gtk3.appdata.xml.in
1751          client/freeciv-gtk3.22.appdata.xml:bootstrap/freeciv-gtk3.22.appdata.xml.in
1752          client/freeciv-sdl.appdata.xml:bootstrap/freeciv-sdl.appdata.xml.in
1753          client/freeciv-sdl2.appdata.xml:bootstrap/freeciv-sdl2.appdata.xml.in
1754          client/freeciv-qt.appdata.xml:bootstrap/freeciv-qt.appdata.xml.in
1755          server/freeciv-server.appdata.xml:bootstrap/freeciv-server.appdata.xml.in
1756          tools/freeciv-mp-gtk2.appdata.xml:bootstrap/freeciv-mp-gtk2.appdata.xml.in
1757          tools/freeciv-mp-gtk3.appdata.xml:bootstrap/freeciv-mp-gtk3.appdata.xml.in
1758          tools/freeciv-mp-qt.appdata.xml:bootstrap/freeciv-mp-qt.appdata.xml.in
1759          tools/ruledit/freeciv-ruledit.appdata.xml:bootstrap/freeciv-ruledit.appdata.xml.in])
1760AC_CONFIG_FILES([fcgui:bootstrap/fcgui.in], [chmod +x fcgui])
1761AC_CONFIG_FILES([fcser:bootstrap/fcser.in], [chmod +x fcser])
1762if test "x$ruledit" = "xyes" ; then
1763  AC_CONFIG_FILES([fcruledit:bootstrap/fcruledit.in], [chmod +x fcruledit])
1764fi
1765
1766AC_OUTPUT
1767
1768AC_MSG_NOTICE([
1769****************** Configuration Summary ******************
1770
1771  == General build options ==
1772  Shared libraries:      $enable_shared
1773  Debugging support:     $enable_debug
1774  Profiling support:     $enable_gprof
1775  IPv6 support:          $enable_ipv6
1776  Map image toolkits:    $enable_mapimg
1777    ppm:                   built-in
1778    MagickWand:            $mapimg_magickwand
1779
1780  == Client ==
1781  Build freeciv client:  $client
1782
1783  Maintained client frontends:
1784    Gtk-3.0:  $gui_gtk3
1785    Gtk-2.0:  $gui_gtk2
1786    Gtk-3.22: $gui_gtk3_22
1787    SDL:      $gui_sdl
1788    QT:       $gui_qt
1789    Stub:     $gui_stub
1790
1791  In-development client frontends:
1792  (these are not yet ready for general use)
1793    SDL2:     $gui_sdl2
1794
1795  Not maintained client frontends:
1796    Xaw:      $gui_xaw
1797
1798  == Server ==
1799  Build freeciv server:  $server
1800    AI modules support:    $enable_aimodules
1801    Database support:      $enable_fcdb
1802      mysql:                 $fcdb_mysql
1803      postgres:              $fcdb_postgres
1804      sqlite3:               $fcdb_sqlite3
1805
1806  == Tools ==
1807  Modpack installers:   $fcmp_list
1808  Ruleset editor:        $ruledit
1809  Manual generator:      $fcmanual
1810])
1811
1812FC_MISSING_FEATURES
1813