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