2 # Empire - A multi-player, client/server Internet based war game.
3 # Copyright (C) 1986-2017, 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-2016
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 C89 and
36 # POSIX, and when something breaks on some oddball machine, see
37 # whether it's worth fixing.
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])
50 ### Checks for programs
56 # Private automake macro, tsk, tsk, tsk...
59 AC_ARG_VAR(NROFF, [nroff command])
60 AC_CHECK_PROG(NROFF, groff, [GROFF_NO_SGR= groff -Tascii -U], nroff)
62 # not really a check for a program, but close enough
63 if test -d $srcdir/.git
67 if test "$revctrl" && test -r $srcdir/.tarball-version
68 then AC_MSG_ERROR([$srcdir/.tarball-version must not exist])
70 AC_SUBST(revctrl,$revctrl)
72 # Not a program, but need to check this early
76 ### Checks for libraries
79 LIBS="$LIBS_SOCKETS $LIBS"
85 ### Checks for header files
88 ### Checks for typedefs, structures, and compiler characteristics
90 # Enable useful warnings
91 # Some of them are commented out because the code needs cleanup first
92 # Clang needs to be tested with -Werror=unknown-warning-option
93 AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],
94 [cflags_test="-Werror=unknown-warning-option"],
96 MY_APPEND_COMPILE_FLAGS([-Wall -Wextra dnl
99 -Wdeclaration-after-statement dnl
100 dnl -Wformat-nonliteral dnl
101 -Wformat-security dnl
104 -Wmissing-prototypes dnl
106 -Wold-style-definition dnl
109 -Wredundant-decls dnl
111 -Wstrict-prototypes dnl
112 dnl too prone to false positives: -Wsuggest-attribute=format dnl
113 dnl -Wswitch-default dnl
115 -Wno-unused-parameter dnl
116 ], [], [$cflags_test])
118 # Our carg() conflicts with libm's TODO clean that up
119 MY_APPEND_COMPILE_FLAGS([-fno-builtin-carg -Wno-incompatible-library-redeclaration])
121 # No multiple definitions of uninitialized global variables
122 MY_APPEND_COMPILE_FLAGS([-fno-common])
124 # Reign in overzealous optimizers
126 # Contemporary compilers can squeeze out some extra performance by
127 # assuming the program never executes code that has undefined behavior
128 # according to the C standard. Unfortunately, this can break
129 # programs. Pointing out that these programs are non-conforming is as
130 # correct as it is unhelpful, at least as long as the compiler is
131 # unable to diagnose the non-conformingness.
133 # Since keeping our programs working is a lot more important to us
134 # than running them as fast as possible, forbid some assumptions that
135 # are known to break real-world programs:
137 # * Aliasing: perfectly clean programs don't engage in type-punning,
138 # and perfectly conforming programs do it only in full accordance
139 # with the standard's (subtle!) aliasing rules. Neither kind of
140 # perfection is realistic for us, therefore -fno-strict-aliasing.
142 # * Signed integer overflow: perfectly clean programs won't ever do
143 # signed integer arithmetic that overflows. This is an imperfect
144 # program, therefore -fno-strict-overflow.
146 MY_APPEND_COMPILE_FLAGS([dnl
147 -fno-strict-aliasing dnl
148 -fno-strict-overflow])
150 # Emit extra code to check for buffer overflows
151 # Could fall back to -fstack-protector when -fstack-protector-strong
152 # isnt't supported, for users of older compilers. Doesn't seem worth
153 # the trouble, though.
154 # Some ports of the GNU toolchain reportedly support it in the
155 # compiler, but not libc. Use a test program that makes the compiler
156 # emit the extra stack checking code, and test it compiles and links.
157 AX_APPEND_LINK_FLAGS([-fstack-protector-strong], [], [],
160 main(int argc, char *argv[])
162 char arr[64], *dst = arr, *src = argv[0];
163 while ((*dst++ = *src++)) ;
168 ### Checks for library functions
170 AC_CHECK_FUNCS(getaddrinfo getpass)
174 ### Site configuration
176 # Can't be bothered to make MAXNOC configurable right now.
177 AC_DEFINE([MAXNOC], [99],
178 [The maximum number of countries])
180 AC_ARG_VAR([EMPIREHOST], [Default host (client only) [127.0.0.1]])
181 test "$EMPIREHOST" || EMPIREHOST=127.0.0.1
183 AC_ARG_VAR([EMPIREPORT], [Default port (client and server) [6665]])
184 test "$EMPIREPORT" || EMPIREPORT=6665
186 AC_ARG_WITH([pthread],
187 AS_HELP_STRING([--with-pthread],
188 [use POSIX threads]))
190 # Select thread package
192 if test "$with_pthread" != no; then
193 if test "$ax_pthread_ok" = yes; then
197 if test -z "$with_pthread" || test "$with_pthread" = no; then
198 if test "$ac_cv_func_makecontext" = yes; then
201 if test $Windows_API = yes; then
205 if test -z "$empthread"; then
206 AC_MSG_ERROR([No usable thread package found])
210 LWP) AC_DEFINE([EMPTH_LWP], 1, [Define to use LWP threads]) ;;
211 POSIX) AC_DEFINE([EMPTH_POSIX], 1, [Define to use POSIX threads]) ;;
212 Windows) AC_DEFINE([EMPTH_W32], 1, [Define to use Windows threads]) ;;
222 AC_SUBST(LIBS_client)
223 AC_SUBST(LIBS_server)
225 AC_CONFIG_FILES([GNUmakefile])
226 AC_CONFIG_COMMANDS([stamp-h],
229 mkdir -p `cd $srcdir && git ls-files \
230 | sed -n 's,/@<:@^/@:>@*$,,gp' | uniq`
233 mkdir -p `sed s/.*=// <$srcdir/sources.mk | tr ' ' '\012' \
234 | sed -n '/\//s,/@<:@^/@:>@*$,,gp'| uniq`
236 mkdir -p info.html info.nr lib
242 AC_MSG_NOTICE([-= Configuration summary =-])
243 AC_MSG_NOTICE([Thread package: $empthread])
244 AC_MSG_NOTICE([ readline: $with_readline])
245 AC_MSG_NOTICE([ terminfo: $with_terminfo])
246 AC_MSG_NOTICE([ EMPIREHOST: $EMPIREHOST])
247 AC_MSG_NOTICE([ EMPIREPORT: $EMPIREPORT])