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