1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
# Check whether make supports sinclude
# Manuel Moos, 2005
AC_DEFUN([AC_SINCLUDE],
[
AC_MSG_CHECKING(whether ${MAKE-make} understands [sinc[]lude])
echo "sinc[]lude" mf2 > mf1
echo "test:;" > mf2
if ${MAKE-make} -f mf1 test > /dev/null 2>&1; then
silent_inc=sin[]clude
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
AC_MSG_CHECKING(whether ${MAKE-make} understands -include)
echo "-incl[]ude" mf2 > mf1
echo "test:;" > mf2
if ${MAKE-make} -f mf1 test > /dev/null 2>&1; then
silent_inc=-inc[]lude
AC_MSG_RESULT(yes)
else
silent_inc=inc[]lude
AC_MSG_RESULT(no)
fi
fi
AC_SUBST(silent_inc)
rm -f mf1 mf2
]
)
# helper for AC_SUBST_UNIVERSAL, does not call AC_SUBST.
# useful to enhance regular autoconf variables (like @prefix@)
# to universal variables.
AC_DEFUN([AC_SUBST_UNIVERSAL_RAW],
[
ac_aa_universal_variables="${ac_aa_universal_variables} $1"
export [$1]
])
# Adds a universal variable. If the argument is foobar, then
# you'll get a @foobar@ replacement for the batch files and
# other .in files, a foobar variable in all makefiles and a
# FOOBAR preprocessor macro in C files that include
# tUniversalVariables.h.
# The value is always the value of the shell variable foobar
# at the time of the AC_OUTPUT call.
AC_DEFUN([AC_SUBST_UNIVERSAL],
[
AC_SUBST_UNIVERSAL_RAW([$1])
AC_SUBST([$1])
]
)
# applies the registered path variables. Needs to be called after
# all AC_SUBST_UNIVERSAL calls and before AC_OUTPUT.
AC_DEFUN([AC_USE_SUBST_UNIVERSAL],
[
#echo uvs=${ac_aa_universal_variables}
# put the path names into a file
AC_CONFIG_COMMANDS(universal_variables,[
# clear files
for f in src/tUniversalVariables.h.in.new universal_variables universal_variable_substitutions universal_variable_values.in universal_variable_values_makefile.new universal_variable_values_makefile_sed.new; do
echo -n "" > $f
done
# prepare value inserting makefile:
# the part reading
# ${top_builddir}/universal_variable_values: ${top_builddir}/universal_variable_values_makefile Makefile
# @echo Generating universal_variable_values...
# it generates the file universal_variable_values, a shell script with our
# universal variables set. It's currently unused.
echo \${top_builddir}/universal_variable_values: \${top_builddir}/universal_variable_values_makefile Makefile > universal_variable_values_makefile.new
echo " @echo Generating universal_variable_values..." >> universal_variable_values_makefile.new
echo " @echo \# values of universal variables at compile time > \${top_builddir}/universal_variable_values" >> universal_variable_values_makefile.new
# ghe part reading
#${top_builddir}/universal_variable_values_sed: ${top_builddir}/universal_variable_values_makefile Makefile
# @echo Generating universal_variable_values_sed...
# it gnerates the file universal_variable_values_sed, a sed script replacing
# @foo@ with the build time value of ${foo} for every universal varialbe
# foo.
echo \${top_builddir}/universal_variable_values_sed: \${top_builddir}/universal_variable_values_makefile Makefile > universal_variable_values_makefile_sed.new
echo " @echo Generating universal_variable_values_sed..." >> universal_variable_values_makefile_sed.new
echo " @echo \# unversal variable values at compile time > \${top_builddir}/universal_variable_values_sed" >> universal_variable_values_makefile_sed.new
for variable in ${ac_aa_universal_variables}; do
# echo Adding universal variable ${variable}...
# make variable uppercase (do it the hard way, some systems don't have \U)
variable_u=`echo ${variable} | sed -e 's/a/A/g' -e 's/b/B/g' -e 's/c/C/g' -e 's/d/D/g' -e 's/e/E/g' -e 's/f/F/g' -e 's/g/G/g' -e 's/h/H/g' -e 's/i/I/g' -e 's/j/J/g' -e 's/k/K/g' -e 's/l/L/g' -e 's/m/M/g' -e 's/n/N/g' -e 's/o/O/g' -e 's/p/P/g' -e 's/q/Q/g' -e 's/r/R/g' -e 's/s/S/g' -e 's/t/T/g' -e 's/u/U/g' -e 's/v/V/g' -e 's/w/W/g' -e 's/x/X/g' -e 's/y/Y/g' -e 's/z/Z/g'`
# add C macro to prototype file (later modified by the makefile
# to contain the possibly modified variable values)
echo -e "#ifndef ${variable_u}\n #define ${variable_u} \"@${variable}@\"\n#endif" >> src/tUniversalVariables.h.in.new
# generate prototype for file containing the actual values of the variables
# echo ${variable}=@${variable}@ >> universal_variable_values.in
# generate makefile for file containing the variable values at compile time
# shell script part
echo " @echo ${variable}=\${${variable}} >> \${top_builddir}/universal_variable_values" >> universal_variable_values_makefile.new
# sed script part
echo " @echo s,@${variable}@,\${${variable}},g >> \${top_builddir}/universal_variable_values_sed" >> universal_variable_values_makefile_sed.new
# generate file with substitutions @foobar@ -> ${foobar}
echo s,@${variable}@,\$\{${variable}\},g >> universal_variable_substitutions
done
# concatenate the two makefiles to one
echo "" >> universal_variable_values_makefile.new
cat universal_variable_values_makefile_sed.new >> universal_variable_values_makefile.new
rm -f universal_variable_values_makefile_sed.new
# replace files if they were changed changed
for f in src/tUniversalVariables.h.in universal_variable_values_makefile; do
diff $f $f.new > /dev/null 2>&1 || echo "updating $f"; mv $f.new $f
rm -f $f.new
done
# make a list of all universal variables (currently unused)
echo ${ac_aa_universal_variables} > universal_variables
]
,
ac_aa_universal_variables="${ac_aa_universal_variables}")
])
# Adds a directory configuration item to be configured via configure,
# make variables or environment variables while the game is run.
# argument: the name of the path variable.
AC_DEFUN([AC_AA_PATH_NOSUFFIX_RAW],
[
ac_aa_pathvars="${ac_aa_pathvars} $1"
AC_SUBST_UNIVERSAL_RAW($1)
])
# Adds a directory configuration item to be configured via configure,
# make variables or environment variables while the game is run.
# argument: the name of the path variable.
# If you add foodir, you also get foodir_suffix and aa_foodir.
# foodir_suffix is what we append to foodir (usually /armagetronad or /games/armagetronad),
# and aa_foodir is the complete composed path.
AC_DEFUN([AC_AA_PATH_RAW],
[
AC_AA_PATH_NOSUFFIX_RAW($1)
AC_SUBST_UNIVERSAL($1_suffix)
AC_SUBST_UNIVERSAL(aa_$1)
aa_$1=\${$1}\${$1_suffix}\${progdir_suffix}
])
# Fallback function if accustomdir is not included
# Arguments:
# 1. the name of the directory configuration variable
# 2. the default value
# 3. a description of the purpose of the directory
# 4. human-form of the default value
AC_DEFUN([AC_ARG_DIR],
[
AC_ARG_WITH([$1],AC_HELP_STRING([--with-$1=DIR],[directory used for $3 (default: $4)]),[$1=${enableval}],[$1=$2
$1_enabled=no])
]
)
# Adds a directory configuration item to be configured via configure,
# make variables or environment variables while the game is run.
# also adds a command line argument to --configure.
# Arguments:
# 1. the name of the directory configuration variable
# 2. the default value
# 3. a description of the purpose of the directory
# 4. human-form of the default value
AC_DEFUN([AC_AA_PATHOPT],
[
AC_ARG_DIR([$1],[$2],[$3],[$4])
AC_SUBST([$1])
]
)
AC_DEFUN([AC_AA_PATH_WITH],
[
AC_ARG_WITH([$1],AC_HELP_STRING([--with-$1=DIR],[$3 (default: $1)]),[$1=${enableval}],[$1=$2
$1_enabled=no])
AC_AA_PATH_RAW([$1])
AC_SUBST([$1])
]
)
AC_DEFUN([AC_AA_PATH_NOSUFFIX],
[
AC_AA_PATHOPT([$1],[$2],[$3],[$4])
AC_AA_PATH_NOSUFFIX_RAW([$1])
]
)
AC_DEFUN([AC_AA_PATH],
[
AC_AA_PATHOPT([$1],[$2],[$3],[$4])
AC_AA_PATH_RAW([$1])
]
)
# applies the registered path variables
AC_DEFUN([AC_AA_REPLACEPATHS],
[
#echo ap=${ac_aa_pathvars}
# put the path names into a file
AC_CONFIG_COMMANDS(pathsubstitution,[
echo -n "" > batch/relocate.in
# generate path relocation sed script: replaces @foo_reloc@ with the
# output of `relocate @foo@`, where @foo@ itself is replaced during
# build time.
# the resulting script is then embedded into sysinstall where it is
# called at installation time and processes all scripts.
for path in ${ac_aa_pathvars}; do
#echo Adding path ${path}...
for variable in ${path} aa_${path}; do
echo " -e \\\"s,@${variable}_reloc@,\`relocate_root @${variable}@\`,g\\\"\\" >> batch/relocate.in
done
done
# generate list
echo ${ac_aa_pathvars} > extrapaths
]
,
ac_aa_pathvars="${ac_aa_pathvars}")
])
# prepares a standard AA path: defines a suitable suffix (containing /games
# if the original path doesn't do so already and /armagetronad)
AC_DEFUN([AC_AA_PATH_PREPARE],
[
# default suffix: /armagetronad(-dedicated)
test -z "${$1_suffix}" && $1_suffix=/${progname}
if test "x${enable_games}" = "xyes"; then
echo "${$1}${$1_suffix}" | grep "/games" > /dev/null || $1_suffix=/games${$1_suffix}
fi
])
# like AC_AA_PATH_PREPARE, but also checks if the path value is part of a
# prefix or not; if not, binreloc is disabled. The second argument is the
# prefix to expect.
AC_DEFUN([AC_AA_PATH_PREPARE_BINRELOC],
[
AC_AA_PATH_PREPARE($1)
test -z "${binreloc_auto}" && binreloc_auto=auto
if test "x${binreloc_auto}" = "xauto" && echo ${$1} | grep -v "^$2" > /dev/null; then
AC_MSG_WARN([Path $1(=${$1}) does not begin with the right prefix(=$2),
disabling relocation support. You can try to enforce it with --enable-binreloc,
but you are on your own then.])
binreloc_auto=no
fi
])
# Check for binary relocation support
# Hongli Lai
# http://autopackage.org/
# MODIFICATION FOR AA: changed enable_binreloc_=auto to enable_binreloc=${binreloc_auto} so we can automatically disable it
AC_DEFUN([AM_BINRELOC],
[
AC_ARG_ENABLE(binreloc,
[ --enable-binreloc compile with binary relocation support
(default=enable when available)],
enable_binreloc=$enableval,enable_binreloc=${binreloc_auto})
AC_ARG_ENABLE(binreloc-threads,
[ --enable-binreloc-threads compile binary relocation with threads support
(default=yes)],
enable_binreloc_threads=$enableval,enable_binreloc_threads=yes)
BINRELOC_CFLAGS=
BINRELOC_LIBS=
if test "x$enable_binreloc" = "xauto"; then
AC_CHECK_FILE([/proc/self/maps])
AC_CACHE_CHECK([whether everything is installed to the same prefix],
[br_cv_valid_prefixes], [
if test "$bindir" = '${exec_prefix}/bin' -a "$sbindir" = '${exec_prefix}/sbin' -a \
"$datadir" = '${prefix}/share' -a "$libdir" = '${exec_prefix}/lib' -a \
"$libexecdir" = '${exec_prefix}/libexec' -a "$sysconfdir" = '${prefix}/etc'
then
br_cv_valid_prefixes=yes
else
br_cv_valid_prefixes=no
fi
])
fi
AC_CACHE_CHECK([whether binary relocation support should be enabled],
[br_cv_binreloc],
[if test "x$enable_binreloc" = "xyes"; then
br_cv_binreloc=yes
elif test "x$enable_binreloc" = "xauto"; then
if test dnl "x$br_cv_valid_prefixes" = "xyes" -a \
"x$ac_cv_file__proc_self_maps" = "xyes"; then
br_cv_binreloc=yes
else
br_cv_binreloc=no
fi
else
br_cv_binreloc=no
fi])
if test "x$br_cv_binreloc" = "xyes"; then
BINRELOC_CFLAGS="-DENABLE_BINRELOC"
AC_DEFINE(ENABLE_BINRELOC,,[Use binary relocation?])
if test "x$enable_binreloc_threads" = "xyes"; then
AC_CHECK_LIB([pthread], [pthread_getspecific])
fi
AC_CACHE_CHECK([whether binary relocation should use threads],
[br_cv_binreloc_threads],
[if test "x$enable_binreloc_threads" = "xyes"; then
if test "x$ac_cv_lib_pthread_pthread_getspecific" = "xyes"; then
br_cv_binreloc_threads=yes
else
br_cv_binreloc_threads=no
fi
else
br_cv_binreloc_threads=no
fi])
if test "x$br_cv_binreloc_threads" = "xyes"; then
BINRELOC_LIBS="-lpthread"
AC_DEFINE(BR_PTHREAD,1,[Include pthread support for binary relocation?])
else
BINRELOC_CFLAGS="$BINRELOC_CFLAGS -DBR_PTHREADS=0"
AC_DEFINE(BR_PTHREAD,0,[Include pthread support for binary relocation?])
fi
fi
AC_SUBST(BINRELOC_CFLAGS)
AC_SUBST(BINRELOC_LIBS)
])
|