2 # Empire - A multi-player, client/server Internet based war game.
3 # Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 # Ken Stevens, Steve McClure, Markus Armbruster
6 # Empire is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # See files README, COPYING and CREDITS in the root of the source
22 # tree for related information and legal notices. It is expected
23 # that future projects/authors will amend these files as needed.
27 # configure.ac: Autoconf input file
29 # Known contributors to this file:
30 # Markus Armbruster, 2005-2020
32 # Process this file with autoconf to produce a configure script.
34 # Autoconf makes checking for and programming around assorted ancient
35 # crap relatively painless. But why bother? Just rely on POSIX, and
36 # when something breaks on some oddball machine, see whether it's
40 AC_INIT([Wolfpack Empire],
41 m4_esyscmd([build-aux/git-version-gen .tarball-version]),
42 [wolfpack@wolfpackempire.com], [empire],
43 [http://www.wolfpackempire.com/])
44 AC_CONFIG_SRCDIR([include/combat.h])
45 AC_CONFIG_AUX_DIR([build-aux])
46 AC_CONFIG_MACRO_DIR([m4])
47 AC_CONFIG_HEADERS([config.h])
49 ### Checks for programs
56 # Private automake macro, tsk, tsk, tsk...
58 AC_DEFINE([_XOPEN_SOURCE], [600],
59 [Request POSIX-1.2001 with XSI Extension])
60 # Note: this is after AC_PROG_CC_STDC, because Solaris cc fails with
61 # _XOPEN_SOURCE unless switched to C99, which breaks AC_PROG_CC_STDC.
63 AC_ARG_VAR(NROFF, [nroff command])
64 AC_CHECK_PROG(NROFF, groff, [GROFF_NO_SGR= groff -Tascii -U], nroff)
66 # not really a check for a program, but close enough
67 if test -d $srcdir/.git
71 if test "$revctrl" && test -r $srcdir/.tarball-version
72 then AC_MSG_ERROR([$srcdir/.tarball-version must not exist])
74 AC_SUBST(revctrl,$revctrl)
76 # Not a program, but need to check this early
80 ### Checks for libraries
83 LIBS="$LIBS_SOCKETS $LIBS"
91 ### Checks for header files
94 ### Checks for typedefs, structures, and compiler characteristics
99 # Enable useful warnings
100 # Some of them are commented out because the code needs cleanup first
101 # Clang needs to be tested with -Werror=unknown-warning-option
102 AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],
103 [cflags_test="-Werror=unknown-warning-option"],
105 MY_APPEND_COMPILE_FLAGS([-Wall -Wextra dnl
108 -Wdeclaration-after-statement dnl
109 dnl -Wformat-nonliteral dnl
110 -Wformat-security dnl
113 -Wmissing-prototypes dnl
115 -Wold-style-definition dnl
118 -Wredundant-decls dnl
120 -Wstrict-prototypes dnl
121 dnl too prone to false positives: -Wsuggest-attribute=format dnl
122 dnl -Wswitch-default dnl
124 -Wno-unused-parameter dnl
125 ], [], [$cflags_test])
127 # Our carg() conflicts with libm's TODO clean that up
128 MY_APPEND_COMPILE_FLAGS([-fno-builtin-carg -Wno-incompatible-library-redeclaration])
130 # No multiple definitions of uninitialized global variables
131 MY_APPEND_COMPILE_FLAGS([-fno-common])
133 # Reign in overzealous optimizers
135 # Contemporary compilers can squeeze out some extra performance by
136 # assuming the program never executes code that has undefined behavior
137 # according to the C standard. Unfortunately, this can break
138 # programs. Pointing out that these programs are non-conforming is as
139 # correct as it is unhelpful, at least as long as the compiler is
140 # unable to diagnose the non-conformingness.
142 # Since keeping our programs working is a lot more important to us
143 # than running them as fast as possible, forbid some assumptions that
144 # are known to break real-world programs:
146 # * Aliasing: perfectly clean programs don't engage in type-punning,
147 # and perfectly conforming programs do it only in full accordance
148 # with the standard's (subtle!) aliasing rules. Neither kind of
149 # perfection is realistic for us, therefore -fno-strict-aliasing.
151 # * Signed integer overflow: perfectly clean programs won't ever do
152 # signed integer arithmetic that overflows. This is an imperfect
153 # program, therefore -fno-strict-overflow.
155 MY_APPEND_COMPILE_FLAGS([dnl
156 -fno-strict-aliasing dnl
157 -fno-strict-overflow])
159 # Emit extra code to check for buffer overflows
160 # Could fall back to -fstack-protector when -fstack-protector-strong
161 # isnt't supported, for users of older compilers. Doesn't seem worth
162 # the trouble, though.
163 # Some ports of the GNU toolchain reportedly support it in the
164 # compiler, but not libc. Use a test program that makes the compiler
165 # emit the extra stack checking code, and test it compiles and links.
166 AX_APPEND_LINK_FLAGS([-fstack-protector-strong], [], [],
169 main(int argc, char *argv[])
171 char arr[64], *dst = arr, *src = argv[0];
172 while ((*dst++ = *src++)) ;
179 ### Checks for library functions
181 AC_CHECK_FUNCS(getaddrinfo)
182 MY_WORKING_IN6_IS_ADDR_V4MAPPED
186 ### Site configuration
188 # Can't be bothered to make MAXNOC configurable right now.
189 AC_DEFINE([MAXNOC], [99],
190 [The maximum number of countries])
192 AC_ARG_VAR([EMPIREHOST], [Default host (client only) [127.0.0.1]])
193 test "$EMPIREHOST" || EMPIREHOST=127.0.0.1
195 AC_ARG_VAR([EMPIREPORT], [Default port (client and server) [6665]])
196 test "$EMPIREPORT" || EMPIREPORT=6665
198 AC_ARG_WITH([pthread],
199 AS_HELP_STRING([--with-pthread],
200 [use POSIX threads]))
202 # Select thread package
204 if test "$with_pthread" != no; then
205 if test "$ax_pthread_ok" = yes; then
209 if test -z "$with_pthread" || test "$with_pthread" = no; then
210 if test "$ac_cv_func_makecontext" = yes; then
213 if test $Windows_API = yes; then
217 if test -z "$empthread"; then
218 AC_MSG_ERROR([No usable thread package found])
222 LWP) AC_DEFINE([EMPTH_LWP], 1, [Define to use LWP threads]) ;;
223 POSIX) AC_DEFINE([EMPTH_POSIX], 1, [Define to use POSIX threads]) ;;
224 Windows) AC_DEFINE([EMPTH_W32], 1, [Define to use Windows threads]) ;;
231 AC_SUBST(LIBS_client)
232 AC_SUBST(LIBS_server)
234 AC_CONFIG_FILES([GNUmakefile])
235 AC_CONFIG_COMMANDS([stamp-h],
238 mkdir -p `cd $srcdir && git ls-files \
239 | sed -n 's,/@<:@^/@:>@*$,,gp' | uniq`
242 mkdir -p `sed s/.*=// <$srcdir/sources.mk | tr ' ' '\012' \
243 | sed -n '/\//s,/@<:@^/@:>@*$,,gp'| uniq`
245 mkdir -p info.html info.nr lib
251 AC_MSG_NOTICE([-= Configuration summary =-])
252 AC_MSG_NOTICE([Thread package: $empthread])
253 AC_MSG_NOTICE([ readline: $with_readline])
254 AC_MSG_NOTICE([ terminfo: $with_terminfo])
255 AC_MSG_NOTICE([ EMPIREHOST: $EMPIREHOST])
256 AC_MSG_NOTICE([ EMPIREPORT: $EMPIREPORT])