]> git.pond.sub.org Git - empserver/blob - configure.ac
Update copyright notice
[empserver] / configure.ac
1 #
2 #   Empire - A multi-player, client/server Internet based war game.
3 #   Copyright (C) 1986-2018, 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-2016
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 C89 and
36 # POSIX, and when something breaks on some oddball machine, see
37 # whether it's 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
50 ### Checks for programs
51 AC_PROG_AWK
52 AC_PROG_INSTALL
53 AC_PROG_RANLIB
54 AC_PROG_CC
55 AM_PROG_CC_C_O
56 # Private automake macro, tsk, tsk, tsk...
57 _AM_DEPENDENCIES(CC)
58
59 AC_ARG_VAR(NROFF, [nroff command])
60 AC_CHECK_PROG(NROFF, groff, [GROFF_NO_SGR= groff -Tascii -U], nroff)
61
62 # not really a check for a program, but close enough
63 if test -d $srcdir/.git
64 then revctrl=git
65 else revctrl=
66 fi
67 if test "$revctrl" && test -r $srcdir/.tarball-version
68 then AC_MSG_ERROR([$srcdir/.tarball-version must not exist])
69 fi
70 AC_SUBST(revctrl,$revctrl)
71
72 # Not a program, but need to check this early
73 MY_WINDOWS_API
74
75
76 ### Checks for libraries
77 AX_PTHREAD
78 LIBS_util="$LIBS"
79 LIBS="$LIBS_SOCKETS $LIBS"
80 AX_LIB_SOCKET_NSL
81 LIBS_server="$LIBS"
82 MY_WITH_READLINE
83
84
85 ### Checks for header files
86
87
88 ### Checks for typedefs, structures, and compiler characteristics
89
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"],
95 [cflags_test=""])
96 MY_APPEND_COMPILE_FLAGS([-Wall -Wextra dnl
97 dnl -Wcast-align dnl
98 dnl -Wconversion dnl
99 -Wdeclaration-after-statement dnl
100 dnl -Wformat-nonliteral dnl
101 -Wformat-security dnl
102 -Winit-self dnl
103 -Wlogical-op dnl
104 -Wmissing-prototypes dnl
105 -Wnested-externs dnl
106 -Wold-style-definition dnl
107 -Wpacked dnl
108 -Wpointer-arith dnl
109 -Wredundant-decls dnl
110 dnl -Wshadow dnl
111 -Wstrict-prototypes dnl
112 dnl too prone to false positives: -Wsuggest-attribute=format dnl
113 dnl -Wswitch-default dnl
114 -Wundef dnl
115 -Wno-unused-parameter dnl
116 ], [], [$cflags_test])
117
118 # Our carg() conflicts with libm's TODO clean that up
119 MY_APPEND_COMPILE_FLAGS([-fno-builtin-carg -Wno-incompatible-library-redeclaration])
120
121 # No multiple definitions of uninitialized global variables
122 MY_APPEND_COMPILE_FLAGS([-fno-common])
123
124 # Reign in overzealous optimizers
125 #
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.
132 #
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:
136 #
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.
141 #
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.
145 #
146 MY_APPEND_COMPILE_FLAGS([dnl
147 -fno-strict-aliasing dnl
148 -fno-strict-overflow])
149
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], [], [],
158     [AC_LANG_SOURCE([[
159 int
160 main(int argc, char *argv[])
161 {
162     char arr[64], *dst = arr, *src = argv[0];
163     while ((*dst++ = *src++)) ;
164 }
165     ]])])
166
167
168 ### Checks for library functions
169
170 AC_CHECK_FUNCS(getaddrinfo getpass)
171 MY_FUNC_MAKECONTEXT
172
173
174 ### Site configuration
175
176 # Can't be bothered to make MAXNOC configurable right now.
177 AC_DEFINE([MAXNOC], [99],
178           [The maximum number of countries])
179
180 AC_ARG_VAR([EMPIREHOST], [Default host (client only) [127.0.0.1]])
181 test "$EMPIREHOST" || EMPIREHOST=127.0.0.1
182
183 AC_ARG_VAR([EMPIREPORT], [Default port (client and server) [6665]])
184 test "$EMPIREPORT" || EMPIREPORT=6665
185
186 AC_ARG_WITH([pthread],
187             AS_HELP_STRING([--with-pthread],
188                            [use POSIX threads]))
189
190 # Select thread package
191 empthread=
192 if test "$with_pthread" != no; then
193     if test "$ax_pthread_ok" = yes; then
194         empthread=POSIX
195     fi
196 fi
197 if test -z "$with_pthread" || test "$with_pthread" = no; then
198     if test "$ac_cv_func_makecontext" = yes; then
199         empthread=LWP
200     fi
201     if test $Windows_API = yes; then
202         empthread=Windows
203     fi
204 fi
205 if test -z "$empthread"; then
206     AC_MSG_ERROR([No usable thread package found])
207 fi
208 AC_SUBST(empthread)
209 case $empthread in
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]) ;;
213 esac
214
215 MY_WITH_TERMINFO
216 LIBS_client="$LIBS"
217
218
219 ### Output
220
221 LIBS="$LIBS_util"
222 AC_SUBST(LIBS_client)
223 AC_SUBST(LIBS_server)
224
225 AC_CONFIG_FILES([GNUmakefile])
226 AC_CONFIG_COMMANDS([stamp-h],
227         [case $revctrl in
228         git)
229             mkdir -p `cd $srcdir && git ls-files \
230                 | sed -n 's,/@<:@^/@:>@*$,,gp' | uniq`
231             ;;
232         *)
233             mkdir -p `sed s/.*=// <$srcdir/sources.mk | tr ' ' '\012' \
234                 | sed -n '/\//s,/@<:@^/@:>@*$,,gp'| uniq`
235         esac
236         mkdir -p info.html info.nr lib
237         touch stamp-h],
238         [revctrl=$revctrl])
239 AC_OUTPUT
240
241 AC_MSG_NOTICE([])
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])