forked from DOMjudge/domjudge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
374 lines (328 loc) · 13 KB
/
configure.ac
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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# Process this file with autoconf to produce a configure script.
AC_INIT([DOMjudge],
m4_esyscmd([sed -n '1s/^.*version //p' README | tr -d '\n']),
[domjudge-devel@lists.A-Eskwadraat.nl])
AC_PREREQ([2.64])
AC_CONFIG_HEADERS([etc/config.h])
AC_CONFIG_SRCDIR([Makefile.global])
# Helper...
AC_DEFUN([AX_WITH_COMMENT], [
AC_ARG_WITH([ax_comment_$1],[$2],[],[])
])
AC_SUBST(FHS_ENABLED,no)
AC_ARG_ENABLE(fhs,AS_HELP_STRING([--enable-fhs],
[use FHS directories (default: no), see below under "Optional
Packages" for path configuration when FHS is disabled.]),
[if test "x$enableval" != xno ; then AC_SUBST(FHS_ENABLED,yes) fi])
if test "x$prefix" = xNONE; then
if test "x$FHS_ENABLED" = xyes ; then
prefix=$ac_default_prefix
else
prefix="/opt/domjudge"
fi
fi
if test -z "$PACKAGE_VERSION"; then
AC_MSG_ERROR([could not find version on first line of README file.])
fi
AC_SUBST(DOMJUDGE_VERSION, $PACKAGE_VERSION)
AC_DEFINE_UNQUOTED(DOMJUDGE_VERSION, "$PACKAGE_VERSION",
[DOMjudge version number (alias for PACKAGE_VERSION)])
# Set default {C,CXX,LD}FLAGS. This might screw up portability, but
# adds important security. Only set these flags when none are supplied
# by the user.
for flag in CFLAGS CXXFLAGS LDFLAGS ; do
AC_MSG_CHECKING([whether configure should try to set $flag])
if test x`eval echo '${'$flag'+set}'` = xset ; then res=no ; else res=yes ; fi
eval enable_${flag}_setting=$res
AC_MSG_RESULT($res)
done
DEF_CXFLAGS="-g -O2"
DEF_LDFLAGS=""
AX_APPEND_COMPILE_FLAGS(-Wall, DEF_CXFLAGS)
AX_APPEND_COMPILE_FLAGS(-fstack-protector, DEF_CXFLAGS)
AX_APPEND_COMPILE_FLAGS(-fPIE, DEF_CXFLAGS)
AX_APPEND_COMPILE_FLAGS(-D_FORTIFY_SOURCE=2, DEF_CXFLAGS)
AX_APPEND_LINK_FLAGS([-fPIE -pie], DEF_LDFLAGS)
AX_APPEND_LINK_FLAGS([-Wl,-z,relro], DEF_LDFLAGS)
AX_APPEND_LINK_FLAGS([-Wl,-z,now], DEF_LDFLAGS)
test "x$enable_CFLAGS_setting" = xyes && AC_SUBST(CFLAGS, $DEF_CXFLAGS)
test "x$enable_CXXFLAGS_setting" = xyes && AC_SUBST(CXXFLAGS, $DEF_CXFLAGS)
test "x$enable_LDFLAGS_setting" = xyes && AC_SUBST(LDFLAGS, $DEF_LDFLAGS)
# {{{ File ownership for e.g. password files.
AX_WITH_COMMENT(0,[])
AX_WITH_COMMENT(1,[Fine tuning of file ownership:])
AC_MSG_CHECKING([domjudge-user])
AC_ARG_WITH([domjudge-user], [AS_HELP_STRING([--with-domjudge-user=USER],
[User that owns password files (default: current user).])], [], [])
if test "x$with_domjudge_user" = x; then
AC_SUBST(DOMJUDGE_USER,$USER)
AC_MSG_RESULT([$DOMJUDGE_USER (default: current user)])
else
AC_SUBST(DOMJUDGE_USER,$with_domjudge_user)
AC_MSG_RESULT([$DOMJUDGE_USER])
fi
AC_MSG_CHECKING([webserver-group])
AC_ARG_WITH([webserver-group], [AS_HELP_STRING([--with-webserver-group=GROUP],
[Webserver group for password files (default: try to detect).])], [], [])
if test "x$with_webserver_group" = x; then
# Try a number of group names and choose first one found
found=0
for g in www-data apache httpd ; do
if getent group $g >/dev/null 2>&1 ; then
found=1
break
fi
done
if test $found -ne 0 ; then
AC_SUBST(WEBSERVER_GROUP,"$g")
AC_MSG_RESULT([$WEBSERVER_GROUP (detected)])
else
AC_MSG_ERROR([webserver group could not be detected, use --with-webserver-group=GROUP)])
fi
else
AC_SUBST(WEBSERVER_GROUP,$with_webserver_group)
AC_MSG_RESULT([$WEBSERVER_GROUP])
fi
# }}}
# {{{ runguard
AC_MSG_CHECKING([runuser])
AC_ARG_WITH([runuser], [AS_HELP_STRING([--with-runuser=USER],
[Unprivileged user under which to run submissions (default: domjudge-run).])], [], [])
if test "x$with_runuser" = x; then
AC_SUBST(RUNUSER,"domjudge-run")
AC_MSG_RESULT($RUNUSER (default))
else
AC_SUBST(RUNUSER,$with_runuser)
AC_MSG_RESULT($RUNUSER)
fi
# Check for using Linux cgroups for memory control
AC_CHECK_LIB(cgroup, cgroup_init, AC_SUBST(LIBCGROUP,[-lcgroup]))
if test "x$LIBCGROUP" != x; then
use_cgroups=yes
else
use_cgroups=no
fi
AC_ARG_ENABLE(cgroups,AS_HELP_STRING([--enable-cgroups],
[Use Linux cgroups for memory control (default: if supported).
This requires Linux kernel >= 3.2.0 and libcgroup.]), [], [])
if test "x$enable_cgroups" = xno; then
use_cgroups=no
elif test "x$enable_cgroups" != x; then
use_cgroups=yes
fi
# Finally define an export variable that can be substituted into
# etc/runguard-config.h.in:
if test "x$use_cgroups" = xyes; then
AC_SUBST(USE_CGROUPS,1)
else
AC_SUBST(USE_CGROUPS,0)
fi
# }}}
# {{{ FHS directory structure
# These are defaults that can still be overridden below!
if test "x$FHS_ENABLED" = xyes ; then
AC_SUBST(domserver_root, '')
AC_SUBST(domserver_bindir, $bindir)
AC_SUBST(domserver_etcdir, $sysconfdir/${PACKAGE_TARNAME})
AC_SUBST(domserver_wwwdir, $datadir/${PACKAGE_TARNAME}/www)
AC_SUBST(domserver_sqldir, $datadir/${PACKAGE_TARNAME}/sql)
AC_SUBST(domserver_libdir, $libdir/${PACKAGE_TARNAME})
AC_SUBST(domserver_libextdir, $libdir/${PACKAGE_TARNAME}/ext)
AC_SUBST(domserver_libwwwdir, $libdir/${PACKAGE_TARNAME}/www)
AC_SUBST(domserver_libsubmitdir,$libdir/${PACKAGE_TARNAME}/submit)
AC_SUBST(domserver_logdir, $localstatedir/log/${PACKAGE_TARNAME})
AC_SUBST(domserver_rundir, $localstatedir/run/${PACKAGE_TARNAME})
AC_SUBST(domserver_tmpdir, /tmp)
AC_SUBST(domserver_submitdir, $localstatedir/lib/${PACKAGE_TARNAME}/submissions)
AC_SUBST(judgehost_root, '')
AC_SUBST(judgehost_bindir, $bindir)
AC_SUBST(judgehost_etcdir, $sysconfdir/${PACKAGE_TARNAME})
AC_SUBST(judgehost_libdir, $libdir/${PACKAGE_TARNAME})
AC_SUBST(judgehost_libextdir, $libdir/${PACKAGE_TARNAME}/ext)
AC_SUBST(judgehost_libjudgedir, $libdir/${PACKAGE_TARNAME}/judge)
AC_SUBST(judgehost_logdir, $localstatedir/log/${PACKAGE_TARNAME})
AC_SUBST(judgehost_rundir, $localstatedir/run/${PACKAGE_TARNAME})
AC_SUBST(judgehost_tmpdir, /tmp)
AC_SUBST(judgehost_judgedir, $localstatedir/lib/${PACKAGE_TARNAME}/judgings)
AC_SUBST(judgehost_chrootdir, /chroot/${PACKAGE_TARNAME})
AC_SUBST(judgehost_cgroupdir, /cgroup)
AC_SUBST(domjudge_docdir, $docdir)
fi
# }}}
# {{{ non-FHS directory structure (the default)
# This is a dirty hack to allow non-standard pathname configuration
# within the autoconf framework.
AC_DEFUN([AX_PATH], [
AC_ARG_WITH($1,[ --with-$1=DIR (default: $2)],
[AC_SUBST($1, $withval)],
[if test "x$FHS_ENABLED" != xyes ; then AC_SUBST($1, $2) fi])
])
AX_WITH_COMMENT(2,[ ])
AX_WITH_COMMENT(3,[Fine tuning of installation root paths when FHS is disabled (the default):])
AX_PATH(domserver_root, [$prefix/domserver])
AX_PATH(judgehost_root, [$prefix/judgehost])
AX_PATH(domjudge_docdir, [$prefix/doc])
AX_WITH_COMMENT(4,[ ])
AX_WITH_COMMENT(5,[More fine tuning of all installation (sub)directories:])
AX_PATH(domserver_bindir, [$domserver_root/bin])
AX_PATH(domserver_etcdir, [$domserver_root/etc])
AX_PATH(domserver_wwwdir, [$domserver_root/www])
AX_PATH(domserver_sqldir, [$domserver_root/sql])
AX_PATH(domserver_libdir, [$domserver_root/lib])
AX_PATH(domserver_libextdir, [$domserver_root/lib/ext])
AX_PATH(domserver_libwwwdir, [$domserver_root/lib/www])
AX_PATH(domserver_libsubmitdir, [$domserver_root/lib/submit])
AX_PATH(domserver_logdir, [$domserver_root/log])
AX_PATH(domserver_rundir, [$domserver_root/run])
AX_PATH(domserver_tmpdir, [$domserver_root/tmp])
AX_PATH(domserver_submitdir, [$domserver_root/submissions])
AX_WITH_COMMENT(6,[ ])
AX_PATH(judgehost_bindir, [$judgehost_root/bin])
AX_PATH(judgehost_etcdir, [$judgehost_root/etc])
AX_PATH(judgehost_libdir, [$judgehost_root/lib])
AX_PATH(judgehost_libextdir, [$judgehost_root/lib/ext])
AX_PATH(judgehost_libjudgedir, [$judgehost_root/lib/judge])
AX_PATH(judgehost_logdir, [$judgehost_root/log])
AX_PATH(judgehost_rundir, [$judgehost_root/run])
AX_PATH(judgehost_tmpdir, [$judgehost_root/tmp])
AX_PATH(judgehost_judgedir, [$judgehost_root/judgings])
AX_PATH(judgehost_chrootdir, [/chroot/domjudge])
AX_PATH(judgehost_cgroupdir, [/cgroup])
AX_WITH_COMMENT(7,[ ])
# }}}
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CXXCPP
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P
# Check for including optional libmagic.
AC_CHECK_LIB(magic,magic_open,AC_SUBST(LIBMAGIC,[-lmagic]))
# {{{ submitclient
AC_ARG_ENABLE(submitclient,AS_HELP_STRING([--disable-submitclient],
[enable submit client program (default: yes).
This requires JSONcpp and cURL libraries and optionally
libmagic for detecting submission of binary files.]))
if test "x$enable_submitclient" != "xno"; then
AC_SUBST(SUBMITCLIENT_ENABLED,[yes])
# Check for libcURL and JSONcpp when submit is enabled.
AX_LIB_CURL([7.9.7],[],[
AC_MSG_ERROR([libcURL not found (required for submit client)])
])
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $CURL_CFLAGS"
AC_CHECK_HEADERS([curl/curl.h],[],[
AC_MSG_ERROR([libcURL headers not found (required for submit client)])
])
CPPFLAGS="$save_CPPFLAGS"
# The 'curl-config --static-libs' option is accepted since 7.17.1
AC_SUBST(CURL_STATIC,"")
if test "x$enable_static_linking" = "xyes"; then
AX_COMPARE_VERSION([$curl_version],[ge],[7.17.1],[
AC_SUBST(CURL_STATIC,`curl-config --static-libs`)])
fi
# Check for JSONcpp library to decode language/extensions list from
# REST API (this also requires libcURL below).
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([jsoncpp/json/json.h],AC_SUBST(LIBJSONCPP,[-ljsoncpp]),[
AC_MSG_ERROR([JSONcpp headers not found (required for submit client)])
])
AC_LANG_POP([C++])
fi
# }}}
# Check option to link statically against "special" libraries for
# submit client.
AC_ARG_ENABLE(static-linking,AS_HELP_STRING([--enable-static-linking],
[enable static linking against libcurl, libmagic, libjsoncpp for 'submit'
(default: no).]))
if test "x$enable_static_linking" = "xyes"; then
AC_SUBST(STATIC_LINK_START,[-Wl,-Bstatic])
AC_SUBST(STATIC_LINK_END, [-Wl,-Bdynamic])
fi
# See 'man feature_test_macros' under Linux:
# Expose POSIX.1-2001 base specification and SUSv2 features.
# We try to conform to POSIX, so ideally we shouldn't need to include
# other features, but there are still individual files that require
# other specifications.
AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE, 200809L, [Include POSIX.1-2008 base specification])
AC_DEFINE_UNQUOTED(_XOPEN_SOURCE, 500, [Include SUSv2 (UNIX 98) extensions])
# Checks for header files.
AC_HEADER_STDBOOL
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/param.h sys/time.h syslog.h termios.h unistd.h magic.h libcgroup.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
# Checks for library functions.
dnl FIXME: need to use the results...
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRTOD
AC_REPLACE_FUNCS([atexit dup2 getcwd gettimeofday memset mkdir realpath setenv \
socket strchr strdup strerror strncasecmp strrchr strstr strtol],
[],[AC_MSG_ERROR([required C function is missing.])])
AC_CONFIG_FILES([paths.mk])
AC_OUTPUT
# summary {{{
if test "x$QUIET" = x ; then
echo ""
echo "Summary:"
echo " * project.............: $PACKAGE_NAME $PACKAGE_VERSION"
echo " * prefix..............: $prefix"
echo " * CPPFLAGS............: $CPPFLAGS"
echo " * CFLAGS..............: $CFLAGS"
echo " * CXXFLAGS............: $CXXFLAGS"
echo " * LDFLAGS.............: $LDFLAGS"
echo ""
echo " * default user........: $DOMJUDGE_USER"
echo " * runguard user.......: $RUNUSER"
echo " * webserver group.....: $WEBSERVER_GROUP"
echo ""
echo " * use Linux cgroups...: $use_cgroups"
echo ""
if test "x$SUBMITCLIENT_ENABLED" = xyes ; then
echo " * submitclient........: enabled, cURL version: $curl_version"
else
echo " * submitclient........: disabled"
fi
echo ""
echo " * documentation.......: $domjudge_docdir"
echo ""
echo " * domserver...........: $domserver_root"
echo " - bin..............: $domserver_bindir"
echo " - etc..............: $domserver_etcdir"
echo " - lib..............: $domserver_libdir"
echo " - libext...........: $domserver_libextdir"
echo " - libwww...........: $domserver_libwwwdir"
echo " - libsubmit........: $domserver_libsubmitdir"
echo " - log..............: $domserver_logdir"
echo " - run..............: $domserver_rundir"
echo " - sql..............: $domserver_sqldir"
echo " - submit...........: $domserver_submitdir"
echo " - tmp..............: $domserver_tmpdir"
echo " - www..............: $domserver_wwwdir"
echo ""
echo " * judgehost...........: $judgehost_root"
echo " - bin..............: $judgehost_bindir"
echo " - etc..............: $judgehost_etcdir"
echo " - lib..............: $judgehost_libdir"
echo " - libext...........: $judgehost_libextdir"
echo " - libjudge.........: $judgehost_libjudgedir"
echo " - log..............: $judgehost_logdir"
echo " - run..............: $judgehost_rundir"
echo " - tmp..............: $judgehost_tmpdir"
echo " - judge............: $judgehost_judgedir"
echo " - chroot...........: $judgehost_chrootdir"
echo " - cgroup...........: $judgehost_cgroupdir"
echo ""
echo "Run 'make' without arguments to get a list of (build) targets."
echo ""
fi # !QUIET
# }}}
# vim: fdm=marker