chiark / gitweb /
fs-util: change chase_symlinks() behaviour in regards to escaping the root dir
[elogind.git] / configure.ac
1 #
2 #  This file is part of elogind.
3 #
4 #  Copyright 2010-2012 Lennart Poettering
5 #  Copyright 2010-2012 Kay Sievers
6 #
7 #  elogind is free software; you can redistribute it and/or modify it
8 #  under the terms of the GNU Lesser General Public License as published by
9 #  the Free Software Foundation; either version 2.1 of the License, or
10 #  (at your option) any later version.
11 #
12 #  elogind is distributed in the hope that it will be useful, but
13 #  WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 #  Lesser General Public License for more details.
16 #
17 #  You should have received a copy of the GNU Lesser General Public License
18 #  along with systemd; If not, see <http://www.gnu.org/licenses/>.
19
20 AC_PREREQ([2.64])
21
22 AC_INIT([elogind],
23         [232.2],
24         [https://github.com/elogind/elogind/issues],
25         [elogind],
26         [https://github.com/elogind/elogind])
27
28 AC_CONFIG_SRCDIR([src/login/logind.c])
29 AC_CONFIG_MACRO_DIR([m4])
30 AC_CONFIG_HEADERS([config.h])
31 AC_CONFIG_AUX_DIR([build-aux])
32
33 AC_USE_SYSTEM_EXTENSIONS
34 AC_SYS_LARGEFILE
35 AC_PREFIX_DEFAULT([/usr])
36 AM_MAINTAINER_MODE([enable])
37 AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax no-dist-gzip dist-xz subdir-objects parallel-tests])
38 AM_SILENT_RULES([yes])
39 AC_CANONICAL_HOST
40 AC_DEFINE_UNQUOTED([CANONICAL_HOST], "$host", [Canonical host string.])
41
42 AC_PROG_CC_C99
43
44 AX_COMPILER_VENDOR
45 AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
46       AC_CHECK_TOOLS([AR], [gcc-ar ar], [:])
47       AC_CHECK_TOOLS([NM], [gcc-nm nm], [:])
48       AC_CHECK_TOOLS([RANLIB], [gcc-ranlib ranlib], [:])
49 ])
50
51 LT_PREREQ(2.2)
52 LT_INIT([disable-static])
53
54 AS_IF([test "x$enable_static" = "xyes"], [AC_MSG_ERROR([--enable-static is not supported by elogind])])
55 AS_IF([test "x$enable_largefile" = "xno"], [AC_MSG_ERROR([--disable-largefile is not supported by elogind])])
56
57 SET_ARCH(X86_64, x86_64*)
58 SET_ARCH(IA32, i*86*)
59 SET_ARCH(MIPS, mips*)
60 SET_ARCH(AARCH64, aarch64*)
61
62 # i18n stuff for the PolicyKit policy files, check whether intltool can be found, disable NLS otherwise
63 AC_CHECK_PROG(intltool_found, [intltool-merge], [yes], [no])
64 AS_IF([test x"$intltool_found" != xyes],
65       [AS_IF([test x"$enable_nls" = xyes],
66              [AC_MSG_ERROR([--enable-nls requested but intltool not found])],
67              [AS_IF([test x"$enable_nls" != xno],
68                     [AC_MSG_WARN([*** Disabling NLS support because intltool was not found])
69                      enable_nls=no])
70              ])
71       ])
72
73 AM_NLS
74 AS_IF([test x"$enable_nls" != xno -o "x$enable_polkit" != xno], [
75     # intltoolize greps for '^(AC|IT)_PROG_INTLTOOL', so it needs to be on its own line
76 IT_PROG_INTLTOOL([0.40.0])
77 ])
78
79 AS_IF([test -z "$INTLTOOL_POLICY_RULE"], [
80     # If intltool is not available, provide a dummy rule to fail generation of %.policy files with a meaningful error message
81     INTLTOOL_POLICY_RULE='%.policy: %.policy.in ; @echo "  ITMRG   " $@ && echo "*** intltool support required to build target $@" && false'
82     AC_SUBST(INTLTOOL_POLICY_RULE)
83 ])
84
85 GETTEXT_PACKAGE=elogind
86 AC_SUBST(GETTEXT_PACKAGE)
87 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [elogind])
88
89 AC_PROG_MKDIR_P
90 AC_PROG_LN_S
91 AC_PROG_SED
92 AC_PROG_GREP
93 AC_PROG_AWK
94
95 AC_PATH_PROG([M4], [m4])
96 AC_PATH_PROG([XSLTPROC], [xsltproc])
97
98 AC_PATH_PROG([HALT], [halt], [halt])
99 AC_PATH_PROG([REBOOT], [reboot], [reboot])
100 AC_PATH_PROG([KEXEC], [kexec], [/usr/sbin/kexec], [$PATH:/usr/sbin:/sbin])
101
102 AS_IF([! ln --relative --help > /dev/null 2>&1], [AC_MSG_ERROR([*** ln doesn't support --relative ***])])
103
104 M4_DEFINES=
105
106 AC_CHECK_TOOL(OBJCOPY, objcopy)
107 AC_CHECK_TOOL(GPERF, gperf)
108 if test -z "$GPERF" ; then
109         AC_MSG_ERROR([*** gperf not found])
110 fi
111
112
113 # ------------------------------------------------------------------------------
114 # Let users set the cgroup controller to use, in case the target controller
115 # isn't currently running the show.
116 # Example: Gentoo Linux, user wants to switch from systemd to openrc+elogind,
117 #          and emerges elogind before having booted the machine with openrc.
118 #          See: https://github.com/elogind/elogind/issues/18
119 with_cgroupctrl=
120 AC_ARG_WITH([cgroup-controller],
121             AS_HELP_STRING([--with-cgroup-controller=name],
122             [Set the name of the cgroup controller to use.
123              Use this when the autodetection fails, or you plan to use your system with a different controller than the one in place now.
124              The value 'auto' (default) detects the running controller.
125              The values 'none' and 'elogind' will cause elogind to be its own (very limited) controller.
126              When elogind shall be its own controller, there *MUST NOT* be any other controller running!
127              Another popular controller would be 'openrc'.]),
128             [with_cgroupctrl=$withval],
129             [with_cgroupctrl=auto])
130
131 # ------------------------------------------------------------------------------
132 # Find running cgroup controller, if none was set
133 AS_IF(  [test "x$with_cgroupctrl" = "xauto"], [
134         AS_IF([test -f /proc/self/cgroup], [
135                 # If the init system is a cgroup controler, it will be position 1.
136                 # Secondary controllers, like cgmanager, do not work.
137                 with_cgroupctrl=`grep "^1:name=" /proc/self/cgroup | \
138                         sed -n 's/.*=//p' | sed -e 's/:.*$//'`
139                 AS_IF(  [test -z "$with_cgroupctrl"], [
140                         # Try to be our own cgroup controller
141                         with_cgroupctrl="elogind"
142                         ])
143         ], [
144                 # 'auto' but no cgroup fs is a problem.
145                 with_cgroupctrl=""
146         ])
147 ])
148
149 # If the user specified 'none', switch to 'elogind'.
150 # 'none' is allowed, as this means "there is no controller now"
151 AS_IF(  [test "x$with_cgroupctrl" = "xnone"], [with_cgroupctrl=elogind])
152
153 # If this was not possible, /proc/self/cgroup not mounted yet, and 'auto'
154 # chosen, error out.
155 AS_IF(  [test -z "$with_cgroupctrl"],
156         AC_MSG_ERROR([No running cgroup controller found]))
157
158 # ------------------------------------------------------------------------------
159 address_sanitizer_cflags=
160 address_sanitizer_cppflags=
161 address_sanitizer_ldflags=
162 AC_ARG_ENABLE(address-sanitizer, AS_HELP_STRING([--enable-address-sanitizer], [enable -fsanitize=address]))
163 AS_IF([test "x$enable_address_sanitizer" = "xyes"], [
164             CC_CHECK_FLAG_APPEND([with_as_cflags], [CFLAGS], [-fsanitize=address])
165             AS_IF([test -z "$with_as_cflags"],
166                   [AC_MSG_ERROR([*** -fsanitize=address is not supported])])
167             address_sanitizer_cflags="$with_as_cflags -fno-omit-frame-pointer -DVALGRIND=1"
168             address_sanitizer_cppflags="-DVALGRIND=1"
169             address_sanitizer_ldflags="-Wc,-fsanitize=address"
170       ])
171
172 undefined_sanitizer_cflags=
173 undefined_sanitizer_cppflags=
174 undefined_sanitizer_ldflags=
175 AC_ARG_ENABLE(undefined-sanitizer, AS_HELP_STRING([--enable-undefined-sanitizer], [enable -fsanitize=undefined]))
176 AS_IF([test "x$enable_undefined_sanitizer" = "xyes"], [
177             CC_CHECK_FLAG_APPEND([with_us_cflags], [CFLAGS], [-fsanitize=undefined])
178             AS_IF([test -z "$with_us_cflags"],
179                   [AC_MSG_ERROR([*** -fsanitize=undefined is not supported])])
180             undefined_sanitizer_cflags="$with_us_cflags -fno-omit-frame-pointer -DVALGRIND=1"
181             undefined_sanitizer_cppflags="-DVALGRIND=1"
182             undefined_sanitizer_ldflags="-Wc,-fsanitize=undefined"
183       ])
184
185 sanitizer_cflags="$address_sanitizer_cflags $undefined_sanitizer_cflags"
186 sanitizer_cppflags="$address_sanitizer_cppflags $undefined_sanitizer_cppflags"
187 sanitizer_ldflags="$address_sanitizer_ldflags $undefined_sanitizer_ldflags"
188
189 CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
190         -pipe \
191         -Wall \
192         -Wextra \
193         -Wundef \
194         "-Wformat=2 -Wformat-security -Wformat-nonliteral" \
195         -Wlogical-op \
196         -Wmissing-include-dirs \
197         -Wold-style-definition \
198         -Wpointer-arith \
199         -Winit-self \
200         -Wdeclaration-after-statement \
201         -Wfloat-equal \
202         -Wsuggest-attribute=noreturn \
203         -Werror=missing-prototypes \
204         -Werror=implicit-function-declaration \
205         -Werror=missing-declarations \
206         -Werror=return-type \
207         -Wstrict-prototypes \
208         -Wredundant-decls \
209         -Wmissing-noreturn \
210         -Wshadow \
211         -Wendif-labels \
212         -Wstrict-aliasing=2 \
213         -Wwrite-strings \
214         -Wno-unused-parameter \
215         -Wno-missing-field-initializers \
216         -Wno-unused-result \
217         -Wno-format-signedness \
218         -Werror=overflow \
219         -Wdate-time \
220         -Wnested-externs \
221         -ffast-math \
222         -fno-common \
223         -fdiagnostics-show-option \
224         -fno-strict-aliasing \
225         -fvisibility=hidden \
226         -fstack-protector \
227         -fstack-protector-strong \
228         -fPIE \
229         --param=ssp-buffer-size=4])
230
231 CC_CHECK_FLAG_APPEND([with_cflags], [CFLAGS], [-Werror=shadow], [
232 #include <time.h>
233 #include <inttypes.h>
234 typedef uint64_t usec_t;
235 usec_t now(clockid_t clock);
236 int main(void) {
237         struct timespec now;
238         return 0;
239 }
240 ])
241
242 AS_CASE([$CC], [*clang*],
243         [CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
244                -Wno-typedef-redefinition \
245                -Wno-gnu-variable-sized-type-not-at-end \
246         ])])
247
248 AC_ARG_ENABLE([lto], [AS_HELP_STRING([--disable-lto], [disable -flto])],
249                      [], [enable_lto=yes])
250 AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
251         [AS_IF([test "x$enable_lto" = "xyes"],
252                [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [-flto])],
253                [AC_MSG_RESULT([disabling -flto as requested])])],
254         [AC_MSG_RESULT([skipping -flto, optimization not enabled])])
255 AC_SUBST([OUR_CFLAGS], "$with_cflags $sanitizer_cflags")
256
257 # ------------------------------------------------------------------------------
258 AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
259         [CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
260                -Wp,-D_FORTIFY_SOURCE=2])],
261         [AC_MSG_RESULT([skipping -D_FORTIFY_SOURCE, optimization not enabled])])
262 AC_SUBST([OUR_CPPFLAGS], "$with_cppflags $sanitizer_cppflags")
263
264 AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
265         [CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
266                -Wl,--gc-sections])],
267         [AC_MSG_RESULT([skipping --gc-sections, optimization not enabled])])
268 AC_SUBST([OUR_CFLAGS], "$with_ldflags $sanitizer_cflags")
269
270 AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
271         [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
272                -ffunction-sections -fdata-sections])],
273         [AC_MSG_RESULT([skipping -ffunction/data-section, optimization not enabled])])
274 AC_SUBST([OUR_CFLAGS], "$with_cflags $sanitizer_cflags")
275
276 CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
277         -Wl,--as-needed \
278         -Wl,--no-undefined \
279         -Wl,-z,relro \
280         -Wl,-z,now \
281         -pie \
282         -Wl,-fuse-ld=gold])
283 AC_SUBST([OUR_LDFLAGS], "$with_ldflags $sanitizer_ldflags")
284
285 AC_CHECK_SIZEOF(pid_t)
286 AC_CHECK_SIZEOF(uid_t)
287 AC_CHECK_SIZEOF(gid_t)
288 AC_CHECK_SIZEOF(time_t)
289 AC_CHECK_SIZEOF(dev_t)
290 AC_CHECK_SIZEOF(ino_t)
291 AC_CHECK_SIZEOF(rlim_t,,[
292        #include <sys/time.h>
293        #include <sys/resource.h>
294 ])
295
296 GPERF_TEST="$(echo foo,bar | ${GPERF} -L ANSI-C)"
297 save_CFLAGS="$CFLAGS"
298 CFLAGS="$CFLAGS -Wno-error"
299 AC_COMPILE_IFELSE(
300         [AC_LANG_PROGRAM([
301                 #include <string.h>
302                 const char * in_word_set(const char *, size_t);
303                 $GPERF_TEST]
304         )],
305         [GPERF_LEN_TYPE=size_t],
306         [AC_COMPILE_IFELSE(
307                 [AC_LANG_PROGRAM([
308                         #include <string.h>
309                         const char * in_word_set(const char *, unsigned);
310                         $GPERF_TEST]
311                 )],
312                 [GPERF_LEN_TYPE=unsigned],
313                 [AC_MSG_ERROR([** unable to determine gperf len type])]
314         )]
315 )
316 CFLAGS="$save_CFLAGS"
317
318 AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], [$GPERF_LEN_TYPE], [gperf len type])
319
320 # ------------------------------------------------------------------------------
321 # we use python to build the man page index
322 have_python=no
323 AC_ARG_WITH([python],
324         [AS_HELP_STRING([--without-python], [Disable building the man page index and systemd-python (default: test)])])
325
326 have_lxml=no
327 AS_IF([test "x$with_python" != "xno"], [
328         AM_PATH_PYTHON(,, [:])
329         AS_IF([test "x$PYTHON" != "x:"], [
330                 AC_MSG_CHECKING([for python lxml module])
331                 AS_IF(["$PYTHON" -c 'import lxml' 2>/dev/null], [have_lxml=yes])
332                 AC_MSG_RESULT([$have_lxml])
333                 AS_IF([test "x$have_lxml" = "xyes"], [have_python=yes],
334                       [AC_MSG_WARN([*** python support requires python-lxml module installed])])
335         ])
336 ])
337 AS_IF([test "$have_python" != "yes"], [
338       AS_IF([test "$with_python" = "yes"],
339             [AC_MSG_ERROR([*** python support requested but python support not found])])
340       AS_IF([test "$with_python" != "no"],
341             [AC_MSG_WARN([*** python support not found, some documentation cannot be built])])
342 ])
343 AM_CONDITIONAL([HAVE_PYTHON], [test "x$have_python" = "xyes"])
344
345 # ------------------------------------------------------------------------------
346
347 AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
348 AC_CHECK_HEADERS([linux/memfd.h], [], [])
349
350 AC_CHECK_HEADERS([printf.h], [have_printf_h=yes], [have_printf_h=no])
351 AS_IF([test x$have_printf_h = xyes], [
352         AC_DEFINE(HAVE_PRINTF_H, 1, [Define if printf.h was found])
353 ])
354
355
356
357 # unconditionally pull-in librt with old glibc versions
358 dnl AC_SEARCH_LIBS([clock_gettime], [rt], [], [])
359 dnl AC_SEARCH_LIBS([mq_unlink], [rt], [], [])
360
361 save_LIBS="$LIBS"
362 LIBS=
363 AC_SEARCH_LIBS([cap_init], [cap], [], [AC_MSG_ERROR([*** POSIX caps library not found])])
364 CAP_LIBS="$LIBS"
365 AC_SUBST(CAP_LIBS)
366
367 AC_CHECK_FUNCS([__secure_getenv secure_getenv])
368 AC_CHECK_DECLS([
369         memfd_create,
370         gettid,
371         pivot_root,
372         name_to_handle_at,
373         setns,
374         getrandom,
375         renameat2,
376         kcmp,
377         keyctl,
378         LO_FLAGS_PARTSCAN,
379         copy_file_range],
380                 [], [], [[
381 #include <sys/types.h>
382 #include <unistd.h>
383 #include <sys/mount.h>
384 #include <fcntl.h>
385 #include <sched.h>
386 #include <linux/loop.h>
387 #include <linux/random.h>
388 ]])
389
390 AC_CHECK_TYPES([char16_t, char32_t, key_serial_t],
391                [], [], [[
392 #include <uchar.h>
393 ]])
394
395 AC_CHECK_DECLS([IFLA_INET6_ADDR_GEN_MODE,
396                 IN6_ADDR_GEN_MODE_STABLE_PRIVACY,
397                 IFLA_VRF_TABLE,
398                 IFLA_MACVLAN_FLAGS,
399                 IFLA_IPVLAN_MODE,
400                 IFLA_VTI_REMOTE,
401                 IFLA_PHYS_PORT_ID,
402                 IFLA_BOND_AD_INFO,
403                 IFLA_VLAN_PROTOCOL,
404                 IFLA_VXLAN_REMCSUM_NOPARTIAL,
405                 IFLA_IPTUN_ENCAP_DPORT,
406                 IFLA_GRE_ENCAP_DPORT,
407                 IFLA_BRIDGE_VLAN_INFO,
408                 IFLA_BRPORT_PROXYARP,
409                 IFLA_BRPORT_LEARNING_SYNC,
410                 IFLA_BR_VLAN_DEFAULT_PVID,
411                 NDA_IFINDEX,
412                 IFA_FLAGS],
413 [], [], [[
414 #include <inttypes.h>
415 #include <netinet/in.h>
416 #include <netinet/ether.h>
417 #include <linux/rtnetlink.h>
418 #include <net/if.h>
419 #include <linux/ip.h>
420 #include <linux/if_tunnel.h>
421 #include <linux/if_link.h>
422 #include <linux/if_bridge.h>
423 #include <linux/if_addr.h>
424 #include <linux/neighbour.h>
425 ]])
426
427 # This makes sure pkg.m4 is available.
428 m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
429
430
431 # ------------------------------------------------------------------------------
432 PKG_CHECK_MODULES(UDEV, [libudev])
433 dnl
434 AC_ARG_WITH([udevrulesdir],
435             AS_HELP_STRING([--with-udevrulesdir=DIR], [Directory for udev rules files]),
436             [],
437             [with_udevrulesdir=$($PKG_CONFIG --variable=udevdir udev)/rules.d])
438 AC_SUBST([udevrulesdir], [$with_udevrulesdir])
439
440 AC_ARG_WITH([udevbindir],
441             AS_HELP_STRING([--with-udevbindir=DIR], [Directory for udev binary files]),
442             [],
443             [with_udevbindir=$($PKG_CONFIG --variable=udevdir udev)])
444 AC_SUBST([udevbindir], [$with_udevbindir])
445
446 # ------------------------------------------------------------------------------
447 have_utmp=yes
448 AC_ARG_ENABLE([utmp], AS_HELP_STRING([--disable-utmp], [disable utmp/wtmp log handling]),
449         AS_CASE("x${enableval}",
450                 [xyes], [have_utmp=yes],
451                 [xno],  [have_utmp=no],
452                 AC_MSG_ERROR(bad value ${enableval} for --enable-utmp)))
453 AS_IF([test "x$have_utmp" = "xyes"], [AC_DEFINE(HAVE_UTMP, 1, [Define if utmp/wtmp support is enabled])])
454 AM_CONDITIONAL([HAVE_UTMP], [test "x$have_utmp" = "xyes"])
455
456 # ------------------------------------------------------------------------------
457 have_coverage=no
458 AC_ARG_ENABLE(coverage, AS_HELP_STRING([--enable-coverage], [enable test coverage]))
459 if test "x$enable_coverage" = "xyes" ; then
460         AC_CHECK_PROG(lcov_found, [lcov], [yes], [no])
461         if test "x$lcov_found" = xno ; then
462                 AC_MSG_ERROR([*** lcov support requested but the program was not found])
463         else
464                 lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
465                 lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
466                 if test "$lcov_version_major" -eq 1 -a "$lcov_version_minor" -lt 10; then
467                         AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
468                 else
469                         have_coverage=yes
470                         CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
471                         -fprofile-arcs \
472                         -ftest-coverage])
473                         AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
474                 fi
475         fi
476 fi
477 AM_CONDITIONAL(ENABLE_COVERAGE, [test "$have_coverage" = "yes"])
478
479 # ------------------------------------------------------------------------------
480 have_selinux=no
481 AC_ARG_ENABLE(selinux, AS_HELP_STRING([--disable-selinux], [Disable optional SELINUX support]))
482 if test "x$enable_selinux" != "xno"; then
483         PKG_CHECK_MODULES([SELINUX], [libselinux >= 2.1.9],
484                 [AC_DEFINE(HAVE_SELINUX, 1, [Define if SELinux is available])
485                  have_selinux=yes
486                  M4_DEFINES="$M4_DEFINES -DHAVE_SELINUX"],
487                 [have_selinux=no])
488         if test "x$have_selinux" = xno -a "x$enable_selinux" = xyes; then
489                 AC_MSG_ERROR([*** SELinux support requested but libraries not found])
490         fi
491 fi
492 AM_CONDITIONAL(HAVE_SELINUX, [test "$have_selinux" = "yes"])
493
494 # ------------------------------------------------------------------------------
495 AC_ARG_WITH([kill-user-processes],
496         [AS_HELP_STRING([--without-kill-user-processes], [Set elogind's KillUserProcesses=no by default])])
497 AS_IF([test "$with_kill_user_processes" != "no"],
498        [kill_user_processes=true
499         KILL_USER_PROCESSES=yes],
500        [kill_user_processes=false
501         KILL_USER_PROCESSES=no])
502 AC_DEFINE_UNQUOTED(KILL_USER_PROCESSES, [$kill_user_processes], [Default KillUserProcesses setting])
503 AC_SUBST(KILL_USER_PROCESSES)
504
505 # ------------------------------------------------------------------------------
506 AC_ARG_ENABLE([pam],
507         AS_HELP_STRING([--disable-pam],[Disable optional PAM support]),
508                 [case "${enableval}" in
509                         yes) have_pam=yes ;;
510                         no) have_pam=no ;;
511                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-pam) ;;
512                 esac],
513                 [have_pam=auto])
514
515 if test "x${have_pam}" != xno ; then
516         AC_CHECK_HEADERS(
517                 [security/pam_modules.h security/pam_modutil.h security/pam_ext.h],
518                 [have_pam=yes],
519                 [if test "x$have_pam" = xyes ; then
520                         AC_MSG_ERROR([*** PAM headers not found.])
521                 fi])
522
523         AC_CHECK_LIB(
524                 [pam],
525                 [pam_syslog],
526                 [have_pam=yes],
527                 [if test "x$have_pam" = xyes ; then
528                         AC_MSG_ERROR([*** libpam not found.])
529                 fi])
530
531         if test "x$have_pam" = xyes ; then
532                 PAM_LIBS="-lpam -lpam_misc"
533                 AC_DEFINE(HAVE_PAM, 1, [PAM available])
534                 M4_DEFINES="$M4_DEFINES -DHAVE_PAM"
535         else
536                 have_pam=no
537         fi
538 else
539         PAM_LIBS=
540 fi
541 AC_SUBST(PAM_LIBS)
542 AM_CONDITIONAL([HAVE_PAM], [test "x$have_pam" != xno])
543
544 # ------------------------------------------------------------------------------
545 AC_ARG_ENABLE([acl],
546         AS_HELP_STRING([--disable-acl],[Disable optional ACL support]),
547                 [case "${enableval}" in
548                         yes) have_acl=yes ;;
549                         no) have_acl=no ;;
550                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-acl) ;;
551                 esac],
552                 [have_acl=auto])
553
554 if test "x${have_acl}" != xno ; then
555         AC_CHECK_HEADERS(
556                 [sys/acl.h acl/libacl.h],
557                 [have_acl=yes],
558                 [if test "x$have_acl" = xyes ; then
559                         AC_MSG_ERROR([*** ACL headers not found.])
560                 fi])
561
562         AC_CHECK_LIB(
563                 [acl],
564                 [acl_get_file],
565                 [have_acl=yes],
566                 [if test "x$have_acl" = xyes ; then
567                         AC_MSG_ERROR([*** libacl not found.])
568                 fi])
569
570         if test "x$have_acl" = xyes ; then
571                 ACL_LIBS="-lacl"
572                 AC_DEFINE(HAVE_ACL, 1, [ACL available])
573                 M4_DEFINES="$M4_DEFINES -DHAVE_ACL"
574         else
575                 have_acl=no
576         fi
577 else
578         ACL_LIBS=
579 fi
580 AC_SUBST(ACL_LIBS)
581 AM_CONDITIONAL([HAVE_ACL], [test "x$have_acl" != xno])
582
583 # ------------------------------------------------------------------------------
584 AC_ARG_ENABLE([smack], AS_HELP_STRING([--disable-smack],[Disable optional SMACK support]),
585                 [case "${enableval}" in
586                         yes) have_smack=yes ;;
587                         no) have_smack=no ;;
588                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-smack) ;;
589                 esac],
590                 [have_smack=auto])
591
592 if test "x${have_smack}" != xno; then
593         AC_DEFINE(HAVE_SMACK, 1, [Define if SMACK is available])
594         M4_DEFINES="$M4_DEFINES -DHAVE_SMACK"
595         have_smack=yes
596 fi
597
598 AM_CONDITIONAL([HAVE_SMACK], [test "x$have_smack" = "xyes"])
599
600 have_smack_run_label=no
601 AC_ARG_WITH(smack-run-label,
602 AS_HELP_STRING([--with-smack-run-label=STRING],
603         [run systemd --system itself with a specific SMACK label]),
604         [AC_DEFINE_UNQUOTED(SMACK_RUN_LABEL, ["$withval"], [Run systemd itself with SMACK label]) have_smack_run_label=yes],
605         [])
606
607 if test "x${have_smack_run_label}" = xyes; then
608         M4_DEFINES="$M4_DEFINES -DHAVE_SMACK_RUN_LABEL"
609 fi
610
611 AC_ARG_WITH(smack-default-process-label,
612 AS_HELP_STRING([--with-smack-default-process-label=STRING],
613         [default SMACK label for executed processes]),
614         [AC_DEFINE_UNQUOTED(SMACK_DEFAULT_PROCESS_LABEL, ["$withval"], [Default SMACK label for executed processes])],
615         [])
616
617 # ------------------------------------------------------------------------------
618 AC_ARG_WITH(system-uid-max,
619         AS_HELP_STRING([--with-system-uid-max=UID]
620                 [Maximum UID for system users]),
621         [SYSTEM_UID_MAX="$withval"],
622         [SYSTEM_UID_MAX="`awk 'BEGIN { uid=999 } /^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }' /etc/login.defs 2>/dev/null || echo 999`"])
623
624 AC_DEFINE_UNQUOTED(SYSTEM_UID_MAX, [$SYSTEM_UID_MAX], [Maximum System UID])
625 AC_SUBST(SYSTEM_UID_MAX)
626
627 # ------------------------------------------------------------------------------
628 AC_ARG_WITH(system-gid-max,
629         AS_HELP_STRING([--with-system-gid-max=GID]
630                 [Maximum GID for system groups]),
631         [SYSTEM_GID_MAX="$withval"],
632         [SYSTEM_GID_MAX="`awk 'BEGIN { gid=999 } /^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }' /etc/login.defs 2>/dev/null || echo 999`"])
633
634 AC_DEFINE_UNQUOTED(SYSTEM_GID_MAX, [$SYSTEM_GID_MAX], [Maximum System GID])
635 AC_SUBST(SYSTEM_GID_MAX)
636
637 # ------------------------------------------------------------------------------
638 have_polkit=no
639 AC_ARG_ENABLE(polkit, AS_HELP_STRING([--disable-polkit], [disable PolicyKit support]))
640 if test "x$enable_polkit" != "xno"; then
641         AC_DEFINE(ENABLE_POLKIT, 1, [Define if PolicyKit support is to be enabled])
642         have_polkit=yes
643 fi
644 AM_CONDITIONAL(ENABLE_POLKIT, [test "x$have_polkit" = "xyes"])
645
646 # ------------------------------------------------------------------------------
647 AC_CHECK_HEADERS_ONCE([valgrind/memcheck.h valgrind/valgrind.h])
648
649 # ------------------------------------------------------------------------------
650 have_manpages=no
651 AC_ARG_ENABLE(manpages, AS_HELP_STRING([--disable-manpages], [disable manpages]))
652 AC_PATH_PROG([XSLTPROC], [xsltproc])
653 AS_IF([test "x$enable_manpages" != xno], [have_manpages=yes])
654 AM_CONDITIONAL(ENABLE_MANPAGES, [test "x$have_manpages" = "xyes"])
655
656 # ------------------------------------------------------------------------------
657 AC_SUBST(M4_DEFINES)
658
659 AC_ARG_WITH([dbuspolicydir],
660         AS_HELP_STRING([--with-dbuspolicydir=DIR], [D-Bus policy directory]),
661         [],
662         [with_dbuspolicydir=${sysconfdir}/dbus-1/system.d])
663 AX_NORMALIZE_PATH([with_dbuspolicydir])
664
665 AC_ARG_WITH([dbussystemservicedir],
666         AS_HELP_STRING([--with-dbussystemservicedir=DIR], [D-Bus system service directory]),
667         [],
668         [with_dbussystemservicedir=${datadir}/dbus-1/system-services])
669 AX_NORMALIZE_PATH([with_dbussystemservicedir])
670
671 AC_ARG_WITH([bashcompletiondir],
672         AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
673         [],
674         [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
675                 with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
676         ] , [
677                 with_bashcompletiondir=${datadir}/bash-completion/completions
678         ])])
679 AM_CONDITIONAL(ENABLE_BASH_COMPLETION, [test "$with_bashcompletiondir" != "no"])
680 AX_NORMALIZE_PATH([with_bashcompletiondir])
681
682 AC_ARG_WITH([zshcompletiondir],
683         AS_HELP_STRING([--with-zshcompletiondir=DIR], [Zsh completions directory]),
684         [], [with_zshcompletiondir=${datadir}/zsh/site-functions])
685 AM_CONDITIONAL(ENABLE_ZSH_COMPLETION, [test "$with_zshcompletiondir" != "no"])
686 AX_NORMALIZE_PATH([with_zshcompletiondir])
687
688 AC_ARG_WITH([rootprefix],
689         AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]),
690         [], [with_rootprefix=${ac_default_prefix}])
691 # --with-rootprefix= (empty) should default to "/" but AX_NORMALIZE_PATH
692 # defaults those to ".", solve that here for now until we can find a suitable
693 # fix for AX_NORMALIZE_PATH upstream at autoconf-archive.
694 # See: https://github.com/systemd/systemd/issues/54
695 if test "x${with_rootprefix}" = "x"; then
696         with_rootprefix="/"
697 fi
698 AX_NORMALIZE_PATH([with_rootprefix])
699
700 AC_ARG_WITH([rootlibdir],
701         AS_HELP_STRING([--with-rootlibdir=DIR], [Root directory for libraries necessary for boot]),
702         [],
703         [with_rootlibdir=${libdir}])
704 AX_NORMALIZE_PATH([with_rootlibdir])
705
706 AC_ARG_WITH([pamlibdir],
707         AS_HELP_STRING([--with-pamlibdir=DIR], [Directory for PAM modules]),
708         [],
709         [with_pamlibdir=${with_rootlibdir}/security])
710 AX_NORMALIZE_PATH([with_pamlibdir])
711
712 AC_ARG_WITH([pamconfdir],
713         AS_HELP_STRING([--with-pamconfdir=DIR], [Directory for PAM configuration (pass no to disable installing)]),
714         [],
715         [with_pamconfdir=${sysconfdir}/pam.d])
716 AM_CONDITIONAL(ENABLE_PAM_CONFIG, [test "$with_pamconfdir" != "no"])
717 AX_NORMALIZE_PATH([with_pamconfdir])
718
719 AC_ARG_ENABLE([split-usr],
720         AS_HELP_STRING([--enable-split-usr], [Assume that /bin, /sbin aren\'t symlinks into /usr]),
721         [],
722         [AS_IF([test "x${ac_default_prefix}" != "x${with_rootprefix}"], [
723                 enable_split_usr=yes
724         ], [
725                 enable_split_usr=no
726         ])])
727
728 AS_IF([test "x${enable_split_usr}" = "xyes"], [
729         AC_DEFINE(HAVE_SPLIT_USR, 1, [Define if /bin, /sbin aren't symlinks into /usr])
730 ])
731 AM_CONDITIONAL(ENABLE_SPLIT_USR, [test "x${enable_split_usr}" = "xyes"])
732
733 # work around intltool-update issues during 'make distcheck'
734 AS_IF([test "x$0" != "x./configure"], [
735         AC_SUBST([INTLTOOL_UPDATE], [/usr/bin/env true])
736 ])
737
738 AC_ARG_ENABLE(tests,
739         [AC_HELP_STRING([--disable-tests], [disable tests])],
740         enable_tests=$enableval, enable_tests=yes)
741 AM_CONDITIONAL(ENABLE_TESTS, [test x$enable_tests = xyes])
742
743 AC_ARG_ENABLE(debug,
744         [AC_HELP_STRING([--enable-debug@<:@=LIST@:>@], [enable extra debugging (elogind,hashmap,mmap-cache)])],
745         [if test "x$enableval" = "xyes"; then
746                 enableval="elogind,hashmap,mmap-cache"
747         fi
748         saved_ifs="$IFS"
749         IFS="$IFS$PATH_SEPARATOR,"
750         for name in $enableval; do
751                 case $name in
752                 elogind)
753                         enable_debug_elogind=yes
754                         ;;
755                 hashmap)
756                         enable_debug_hashmap=yes
757                         ;;
758                 mmap-cache)
759                         enable_debug_mmap_cache=yes
760                         ;;
761                 esac
762         done
763         IFS="$saved_ifs"],[])
764
765 enable_debug=""
766 AS_IF([test x$enable_debug_elogind = xyes], [
767         AC_DEFINE(ENABLE_DEBUG_ELOGIND, 1, [Define if elogind debugging is to be enabled])
768         enable_debug="elogind $enable_debug"
769 ])
770 AS_IF([test x$enable_debug_hashmap = xyes], [
771         AC_DEFINE(ENABLE_DEBUG_HASHMAP, 1, [Define if hashmap debugging is to be enabled])
772         enable_debug="hashmap $enable_debug"
773 ])
774 AS_IF([test x$enable_debug_mmap_cache = xyes], [
775         AC_DEFINE(ENABLE_DEBUG_MMAP_CACHE, 1, [Define if mmap cache debugging is to be enabled])
776         enable_debug="mmap-cache $enable_debug"
777 ])
778 test -z "$enable_debug" && enable_debug="none"
779
780 AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])
781 AC_SUBST([dbussystemservicedir], [$with_dbussystemservicedir])
782 AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
783 AC_SUBST([zshcompletiondir], [$with_zshcompletiondir])
784 AC_SUBST([pamlibdir], [$with_pamlibdir])
785 AC_SUBST([pamconfdir], [$with_pamconfdir])
786 AC_SUBST([rootprefix], [$with_rootprefix])
787 AC_SUBST([rootlibdir], [$with_rootlibdir])
788 AC_SUBST([cgroup_controller], [$with_cgroupctrl])
789
790 AC_CONFIG_FILES([
791         Makefile
792         po/Makefile.in
793 ])
794
795 AC_OUTPUT
796 AC_MSG_RESULT([
797         $PACKAGE_NAME $VERSION
798
799         PAM:                     ${have_pam}
800         SELinux:                 ${have_selinux}
801         SMACK:                   ${have_smack}
802         ACL:                     ${have_acl}
803         KillUserProcesses default: ${KILL_USER_PROCESSES}
804         polkit:                  ${have_polkit}
805         Python:                  ${have_python}
806         man pages:               ${have_manpages}
807         test coverage:           ${have_coverage}
808         Split /usr:              ${enable_split_usr}
809         utmp/wtmp support:       ${have_utmp}
810         extra debugging:         ${enable_debug}
811         cgroup controller:       ${with_cgroupctrl}
812
813         prefix:                  ${prefix}
814         rootprefix:              ${with_rootprefix}
815         sysconf dir:             ${sysconfdir}
816         datarootdir:             ${datarootdir}
817         includedir:              ${includedir}
818         lib dir:                 ${libdir}
819         rootlib dir:             ${with_rootlibdir}
820         PAM modules dir:         ${with_pamlibdir}
821         PAM configuration dir:   ${with_pamconfdir}
822         D-Bus policy dir:        ${with_dbuspolicydir}
823         D-Bus system dir:        ${with_dbussystemservicedir}
824         Bash completions dir:    ${with_bashcompletiondir}
825         Zsh completions dir:     ${with_zshcompletiondir}
826         Maximum System UID:      ${SYSTEM_UID_MAX}
827         Maximum System GID:      ${SYSTEM_GID_MAX}
828
829         CFLAGS:                  ${OUR_CFLAGS} ${CFLAGS}
830         CPPFLAGS:                ${OUR_CPPFLAGS} ${CPPFLAGS}
831         LDFLAGS:                 ${OUR_LDFLAGS} ${LDFLAGS}
832 ])