]> git.pond.sub.org Git - empserver/blob - configure.ac
1885981a7ffb862652d8b3fa33e792b2448e5fae
[empserver] / configure.ac
1 #
2 #   Empire - A multi-player, client/server Internet based war game.
3 #   Copyright (C) 1986-2020, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 #                 Ken Stevens, Steve McClure, Markus Armbruster
5 #
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.
10 #
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.
15 #
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/>.
18 #
19 #   ---
20 #
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.
24 #
25 #   ---
26 #
27 #   configure.ac: Autoconf input file
28 #
29 #   Known contributors to this file:
30 #      Markus Armbruster, 2005-2020
31 #
32 # Process this file with autoconf to produce a configure script.
33
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
37 # worth fixing.
38
39 AC_PREREQ(2.69)
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])
48
49 ### Checks for programs
50 AC_PROG_AWK
51 AC_PROG_INSTALL
52 AC_PROG_RANLIB
53
54 AC_PROG_CC_STDC
55 AM_PROG_CC_C_O
56 # Private automake macro, tsk, tsk, tsk...
57 _AM_DEPENDENCIES(CC)
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.
62
63 AC_ARG_VAR(NROFF, [nroff command])
64 AC_CHECK_PROG(NROFF, groff, [GROFF_NO_SGR= groff -Tascii -U], nroff)
65
66 # not really a check for a program, but close enough
67 if test -d $srcdir/.git
68 then revctrl=git
69 else revctrl=
70 fi
71 if test "$revctrl" && test -r $srcdir/.tarball-version
72 then AC_MSG_ERROR([$srcdir/.tarball-version must not exist])
73 fi
74 AC_SUBST(revctrl,$revctrl)
75
76 # Not a program, but need to check this early
77 MY_WINDOWS_API
78
79
80 ### Checks for libraries
81 AX_PTHREAD
82 LIBS_util="$LIBS"
83 LIBS="$LIBS_SOCKETS $LIBS"
84 AX_LIB_SOCKET_NSL
85 LIBS_server="$LIBS"
86 MY_WITH_READLINE
87
88
89 ### Checks for header files
90
91
92 ### Checks for typedefs, structures, and compiler characteristics
93
94 # Enable useful warnings
95 # Some of them are commented out because the code needs cleanup first
96 # Clang needs to be tested with -Werror=unknown-warning-option
97 AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],
98 [cflags_test="-Werror=unknown-warning-option"],
99 [cflags_test=""])
100 MY_APPEND_COMPILE_FLAGS([-Wall -Wextra dnl
101 dnl -Wcast-align dnl
102 dnl -Wconversion dnl
103 -Wdeclaration-after-statement dnl
104 dnl -Wformat-nonliteral dnl
105 -Wformat-security dnl
106 -Winit-self dnl
107 -Wlogical-op dnl
108 -Wmissing-prototypes dnl
109 -Wnested-externs dnl
110 -Wold-style-definition dnl
111 -Wpacked dnl
112 -Wpointer-arith dnl
113 -Wredundant-decls dnl
114 dnl -Wshadow dnl
115 -Wstrict-prototypes dnl
116 dnl too prone to false positives: -Wsuggest-attribute=format dnl
117 dnl -Wswitch-default dnl
118 -Wundef dnl
119 -Wno-unused-parameter dnl
120 ], [], [$cflags_test])
121
122 # Our carg() conflicts with libm's TODO clean that up
123 MY_APPEND_COMPILE_FLAGS([-fno-builtin-carg -Wno-incompatible-library-redeclaration])
124
125 # No multiple definitions of uninitialized global variables
126 MY_APPEND_COMPILE_FLAGS([-fno-common])
127
128 # Reign in overzealous optimizers
129 #
130 # Contemporary compilers can squeeze out some extra performance by
131 # assuming the program never executes code that has undefined behavior
132 # according to the C standard.  Unfortunately, this can break
133 # programs.  Pointing out that these programs are non-conforming is as
134 # correct as it is unhelpful, at least as long as the compiler is
135 # unable to diagnose the non-conformingness.
136 #
137 # Since keeping our programs working is a lot more important to us
138 # than running them as fast as possible, forbid some assumptions that
139 # are known to break real-world programs:
140 #
141 # * Aliasing: perfectly clean programs don't engage in type-punning,
142 #   and perfectly conforming programs do it only in full accordance
143 #   with the standard's (subtle!) aliasing rules.  Neither kind of
144 #   perfection is realistic for us, therefore -fno-strict-aliasing.
145 #
146 # * Signed integer overflow: perfectly clean programs won't ever do
147 #   signed integer arithmetic that overflows.  This is an imperfect
148 #   program, therefore -fno-strict-overflow.
149 #
150 MY_APPEND_COMPILE_FLAGS([dnl
151 -fno-strict-aliasing dnl
152 -fno-strict-overflow])
153
154 # Emit extra code to check for buffer overflows
155 # Could fall back to -fstack-protector when -fstack-protector-strong
156 # isnt't supported, for users of older compilers.  Doesn't seem worth
157 # the trouble, though.
158 # Some ports of the GNU toolchain reportedly support it in the
159 # compiler, but not libc.  Use a test program that makes the compiler
160 # emit the extra stack checking code, and test it compiles and links.
161 AX_APPEND_LINK_FLAGS([-fstack-protector-strong], [], [],
162     [AC_LANG_SOURCE([[
163 int
164 main(int argc, char *argv[])
165 {
166     char arr[64], *dst = arr, *src = argv[0];
167     while ((*dst++ = *src++)) ;
168 }
169     ]])])
170
171
172 ### Checks for library functions
173
174 AC_CHECK_FUNCS(getaddrinfo)
175 MY_WORKING_IN6_IS_ADDR_V4MAPPED
176 MY_FUNC_MAKECONTEXT
177
178
179 ### Site configuration
180
181 # Can't be bothered to make MAXNOC configurable right now.
182 AC_DEFINE([MAXNOC], [99],
183           [The maximum number of countries])
184
185 AC_ARG_VAR([EMPIREHOST], [Default host (client only) [127.0.0.1]])
186 test "$EMPIREHOST" || EMPIREHOST=127.0.0.1
187
188 AC_ARG_VAR([EMPIREPORT], [Default port (client and server) [6665]])
189 test "$EMPIREPORT" || EMPIREPORT=6665
190
191 AC_ARG_WITH([pthread],
192             AS_HELP_STRING([--with-pthread],
193                            [use POSIX threads]))
194
195 # Select thread package
196 empthread=
197 if test "$with_pthread" != no; then
198     if test "$ax_pthread_ok" = yes; then
199         empthread=POSIX
200     fi
201 fi
202 if test -z "$with_pthread" || test "$with_pthread" = no; then
203     if test "$ac_cv_func_makecontext" = yes; then
204         empthread=LWP
205     fi
206     if test $Windows_API = yes; then
207         empthread=Windows
208     fi
209 fi
210 if test -z "$empthread"; then
211     AC_MSG_ERROR([No usable thread package found])
212 fi
213 AC_SUBST(empthread)
214 case $empthread in
215 LWP)    AC_DEFINE([EMPTH_LWP], 1, [Define to use LWP threads]) ;;
216 POSIX)  AC_DEFINE([EMPTH_POSIX], 1, [Define to use POSIX threads]) ;;
217 Windows) AC_DEFINE([EMPTH_W32], 1, [Define to use Windows threads]) ;;
218 esac
219
220 MY_WITH_TERMINFO
221 LIBS_client="$LIBS"
222
223
224 ### Output
225
226 LIBS="$LIBS_util"
227 AC_SUBST(LIBS_client)
228 AC_SUBST(LIBS_server)
229
230 AC_CONFIG_FILES([GNUmakefile])
231 AC_CONFIG_COMMANDS([stamp-h],
232         [case $revctrl in
233         git)
234             mkdir -p `cd $srcdir && git ls-files \
235                 | sed -n 's,/@<:@^/@:>@*$,,gp' | uniq`
236             ;;
237         *)
238             mkdir -p `sed s/.*=// <$srcdir/sources.mk | tr ' ' '\012' \
239                 | sed -n '/\//s,/@<:@^/@:>@*$,,gp'| uniq`
240         esac
241         mkdir -p info.html info.nr lib
242         touch stamp-h],
243         [revctrl=$revctrl])
244 AC_OUTPUT
245
246 AC_MSG_NOTICE([])
247 AC_MSG_NOTICE([-= Configuration summary =-])
248 AC_MSG_NOTICE([Thread package: $empthread])
249 AC_MSG_NOTICE([      readline: $with_readline])
250 AC_MSG_NOTICE([      terminfo: $with_terminfo])
251 AC_MSG_NOTICE([    EMPIREHOST: $EMPIREHOST])
252 AC_MSG_NOTICE([    EMPIREPORT: $EMPIREPORT])