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