chiark / gitweb /
Prep v231.2: basic/stdio-util.h must include parse-printf-format.h instead of printf.h
[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         [231.1],
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 # Find running cgroup controller
115 with_cgroupctrl=
116 AS_IF(  [test -f /proc/self/cgroup], [
117         # If the init system is a cgroup controler, it will be position 1.
118         # Secondary controllers, like cgmanager, do not work.
119         with_cgroupctrl=`grep "^1:name=" /proc/self/cgroup | cut -d ':' -f 2`
120         AS_IF(  [test -z "$with_cgroupctrl"], [
121                 # Try to be our own cgroup controller
122                 with_cgroupctrl="name=elogind"
123         ])
124 ])
125 AS_IF(  [test -z "$with_cgroupctrl"],
126         AC_MSG_ERROR([No running cgroup controller found]))
127
128
129 # ------------------------------------------------------------------------------
130 address_sanitizer_cflags=
131 address_sanitizer_cppflags=
132 address_sanitizer_ldflags=
133 AC_ARG_ENABLE(address-sanitizer, AS_HELP_STRING([--enable-address-sanitizer], [enable -fsanitize=address]))
134 AS_IF([test "x$enable_address_sanitizer" = "xyes"], [
135             CC_CHECK_FLAG_APPEND([with_as_cflags], [CFLAGS], [-fsanitize=address])
136             AS_IF([test -z "$with_as_cflags"],
137                   [AC_MSG_ERROR([*** -fsanitize=address is not supported])])
138             address_sanitizer_cflags="$with_as_cflags -fno-omit-frame-pointer -DVALGRIND=1"
139             address_sanitizer_cppflags="-DVALGRIND=1"
140             address_sanitizer_ldflags="-Wc,-fsanitize=address"
141       ])
142
143 undefined_sanitizer_cflags=
144 undefined_sanitizer_cppflags=
145 undefined_sanitizer_ldflags=
146 AC_ARG_ENABLE(undefined-sanitizer, AS_HELP_STRING([--enable-undefined-sanitizer], [enable -fsanitize=undefined]))
147 AS_IF([test "x$enable_undefined_sanitizer" = "xyes"], [
148             CC_CHECK_FLAG_APPEND([with_us_cflags], [CFLAGS], [-fsanitize=undefined])
149             AS_IF([test -z "$with_us_cflags"],
150                   [AC_MSG_ERROR([*** -fsanitize=undefined is not supported])])
151             undefined_sanitizer_cflags="$with_us_cflags -fno-omit-frame-pointer -DVALGRIND=1"
152             undefined_sanitizer_cppflags="-DVALGRIND=1"
153             undefined_sanitizer_ldflags="-Wc,-fsanitize=undefined"
154       ])
155
156 sanitizer_cflags="$address_sanitizer_cflags $undefined_sanitizer_cflags"
157 sanitizer_cppflags="$address_sanitizer_cppflags $undefined_sanitizer_cppflags"
158 sanitizer_ldflags="$address_sanitizer_ldflags $undefined_sanitizer_ldflags"
159
160 CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
161         -pipe \
162         -Wall \
163         -Wextra \
164         -Wundef \
165         "-Wformat=2 -Wformat-security -Wformat-nonliteral" \
166         -Wlogical-op \
167         -Wmissing-include-dirs \
168         -Wold-style-definition \
169         -Wpointer-arith \
170         -Winit-self \
171         -Wdeclaration-after-statement \
172         -Wfloat-equal \
173         -Wsuggest-attribute=noreturn \
174         -Werror=missing-prototypes \
175         -Werror=implicit-function-declaration \
176         -Werror=missing-declarations \
177         -Werror=return-type \
178         -Wstrict-prototypes \
179         -Wredundant-decls \
180         -Wmissing-noreturn \
181         -Wshadow \
182         -Wendif-labels \
183         -Wstrict-aliasing=2 \
184         -Wwrite-strings \
185         -Wno-unused-parameter \
186         -Wno-missing-field-initializers \
187         -Wno-unused-result \
188         -Wno-format-signedness \
189         -Werror=overflow \
190         -Wdate-time \
191         -Wnested-externs \
192         -ffast-math \
193         -fno-common \
194         -fdiagnostics-show-option \
195         -fno-strict-aliasing \
196         -fvisibility=hidden \
197         -fstack-protector \
198         -fstack-protector-strong \
199         -fPIE \
200         --param=ssp-buffer-size=4])
201
202 CC_CHECK_FLAG_APPEND([with_cflags], [CFLAGS], [-Werror=shadow], [
203 #include <time.h>
204 #include <inttypes.h>
205 typedef uint64_t usec_t;
206 usec_t now(clockid_t clock);
207 int main(void) {
208         struct timespec now;
209         return 0;
210 }
211 ])
212
213 AS_CASE([$CC], [*clang*],
214         [CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
215                -Wno-typedef-redefinition \
216                -Wno-gnu-variable-sized-type-not-at-end \
217         ])])
218
219
220 # ------------------------------------------------------------------------------
221 # On some distributions -flto, even if available, leads to linking errors.
222 # We therefore make it optional
223 have_lto=no
224 AC_ARG_ENABLE([lto],
225         [AS_HELP_STRING([--disable-lto], [Disable link time optimization (default: test)])])
226
227 AS_IF([test "x$enable_lto" != "xno"], [
228         AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
229                 [have_lto=yes],
230                 [AC_MSG_RESULT([skipping -flto, optimization not enabled])])
231         AS_IF([test "$have_lto" != "no"],
232                 [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [-flto])]
233         )
234         AC_SUBST([OUR_CFLAGS], "$with_cflags $sanitizer_cflags")
235 ])
236
237 # ------------------------------------------------------------------------------
238 AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
239         [CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
240                -Wp,-D_FORTIFY_SOURCE=2])],
241         [AC_MSG_RESULT([skipping -D_FORTIFY_SOURCE, optimization not enabled])])
242 AC_SUBST([OUR_CPPFLAGS], "$with_cppflags $sanitizer_cppflags")
243
244 AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
245         [CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
246                -Wl,--gc-sections])],
247         [AC_MSG_RESULT([skipping --gc-sections, optimization not enabled])])
248 AC_SUBST([OUR_CFLAGS], "$with_ldflags $sanitizer_cflags")
249
250 AS_CASE([$CFLAGS], [*-O[[12345sz\ ]]*],
251         [CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
252                -ffunction-sections -fdata-sections])],
253         [AC_MSG_RESULT([skipping -ffunction/data-section, optimization not enabled])])
254 AC_SUBST([OUR_CFLAGS], "$with_cflags $sanitizer_cflags")
255
256 CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
257         -Wl,--as-needed \
258         -Wl,--no-undefined \
259         -Wl,-z,relro \
260         -Wl,-z,now \
261         -pie \
262         -Wl,-fuse-ld=gold])
263 AC_SUBST([OUR_LDFLAGS], "$with_ldflags $sanitizer_ldflags")
264
265 AC_CHECK_SIZEOF(pid_t)
266 AC_CHECK_SIZEOF(uid_t)
267 AC_CHECK_SIZEOF(gid_t)
268 AC_CHECK_SIZEOF(time_t)
269 AC_CHECK_SIZEOF(dev_t)
270 AC_CHECK_SIZEOF(ino_t)
271 AC_CHECK_SIZEOF(rlim_t,,[
272        #include <sys/time.h>
273        #include <sys/resource.h>
274 ])
275
276 GPERF_TEST="$(echo foo,bar | ${GPERF} -L ANSI-C)"
277 save_CFLAGS="$CFLAGS"
278 CFLAGS="$CFLAGS -Wno-error"
279 AC_COMPILE_IFELSE(
280         [AC_LANG_PROGRAM([
281                 #include <string.h>
282                 const char * in_word_set(const char *, size_t);
283                 $GPERF_TEST]
284         )],
285         [GPERF_LEN_TYPE=size_t],
286         [AC_COMPILE_IFELSE(
287                 [AC_LANG_PROGRAM([
288                         #include <string.h>
289                         const char * in_word_set(const char *, unsigned);
290                         $GPERF_TEST]
291                 )],
292                 [GPERF_LEN_TYPE=unsigned],
293                 [AC_MSG_ERROR([** unable to determine gperf len type])]
294         )]
295 )
296 CFLAGS="$save_CFLAGS"
297
298 AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], [$GPERF_LEN_TYPE], [gperf len type])
299
300 # ------------------------------------------------------------------------------
301 # we use python to build the man page index
302 have_python=no
303 AC_ARG_WITH([python],
304         [AS_HELP_STRING([--without-python], [Disable building the man page index and systemd-python (default: test)])])
305
306 have_lxml=no
307 AS_IF([test "x$with_python" != "xno"], [
308         AM_PATH_PYTHON(,, [:])
309         AS_IF([test "x$PYTHON" != "x:"], [
310                 AC_MSG_CHECKING([for python lxml module])
311                 AS_IF(["$PYTHON" -c 'import lxml' 2>/dev/null], [have_lxml=yes])
312                 AC_MSG_RESULT([$have_lxml])
313                 AS_IF([test "x$have_lxml" = "xyes"], [have_python=yes],
314                       [AC_MSG_WARN([*** python support requires python-lxml module installed])])
315         ])
316 ])
317 AS_IF([test "$have_python" != "yes"], [
318       AS_IF([test "$with_python" = "yes"],
319             [AC_MSG_ERROR([*** python support requested but python support not found])])
320       AS_IF([test "$with_python" != "no"],
321             [AC_MSG_WARN([*** python support not found, some documentation cannot be built])])
322 ])
323 AM_CONDITIONAL([HAVE_PYTHON], [test "x$have_python" = "xyes"])
324
325 # ------------------------------------------------------------------------------
326
327 AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
328 AC_CHECK_HEADERS([linux/memfd.h], [], [])
329
330 AC_CHECK_HEADERS([printf.h], [have_printf_h=yes], [have_printf_h=no])
331 AS_IF([test x$have_printf_h = xyes], [
332         AC_DEFINE(HAVE_PRINTF_H, 1, [Define if printf.h was found])
333 ])
334
335
336
337 # unconditionally pull-in librt with old glibc versions
338 dnl AC_SEARCH_LIBS([clock_gettime], [rt], [], [])
339 dnl AC_SEARCH_LIBS([mq_unlink], [rt], [], [])
340
341 save_LIBS="$LIBS"
342 LIBS=
343 AC_SEARCH_LIBS([cap_init], [cap], [], [AC_MSG_ERROR([*** POSIX caps library not found])])
344 CAP_LIBS="$LIBS"
345 AC_SUBST(CAP_LIBS)
346
347 AC_CHECK_FUNCS([__secure_getenv secure_getenv])
348 AC_CHECK_DECLS([
349         memfd_create,
350         gettid,
351         pivot_root,
352         name_to_handle_at,
353         setns,
354         getrandom,
355         renameat2,
356         kcmp,
357         keyctl,
358         LO_FLAGS_PARTSCAN,
359         copy_file_range],
360                 [], [], [[
361 #include <sys/types.h>
362 #include <unistd.h>
363 #include <sys/mount.h>
364 #include <fcntl.h>
365 #include <sched.h>
366 #include <linux/loop.h>
367 #include <linux/random.h>
368 ]])
369
370 AC_CHECK_TYPES([char16_t, char32_t, key_serial_t],
371                [], [], [[
372 #include <uchar.h>
373 ]])
374
375 AC_CHECK_DECLS([IFLA_INET6_ADDR_GEN_MODE,
376                 IN6_ADDR_GEN_MODE_STABLE_PRIVACY,
377                 IFLA_VRF_TABLE,
378                 IFLA_MACVLAN_FLAGS,
379                 IFLA_IPVLAN_MODE,
380                 IFLA_VTI_REMOTE,
381                 IFLA_PHYS_PORT_ID,
382                 IFLA_BOND_AD_INFO,
383                 IFLA_VLAN_PROTOCOL,
384                 IFLA_VXLAN_REMCSUM_NOPARTIAL,
385                 IFLA_IPTUN_ENCAP_DPORT,
386                 IFLA_GRE_ENCAP_DPORT,
387                 IFLA_BRIDGE_VLAN_INFO,
388                 IFLA_BRPORT_PROXYARP,
389                 IFLA_BRPORT_LEARNING_SYNC,
390                 IFLA_BR_VLAN_DEFAULT_PVID,
391                 NDA_IFINDEX,
392                 IFA_FLAGS],
393 [], [], [[
394 #include <inttypes.h>
395 #include <netinet/in.h>
396 #include <netinet/ether.h>
397 #include <linux/rtnetlink.h>
398 #include <net/if.h>
399 #include <linux/ip.h>
400 #include <linux/if_tunnel.h>
401 #include <linux/if_link.h>
402 #include <linux/if_bridge.h>
403 #include <linux/if_addr.h>
404 #include <linux/neighbour.h>
405 ]])
406
407 # This makes sure pkg.m4 is available.
408 m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
409
410
411 # ------------------------------------------------------------------------------
412 PKG_CHECK_MODULES(UDEV, [libudev])
413 dnl
414 AC_ARG_WITH([udevrulesdir],
415             AS_HELP_STRING([--with-udevrulesdir=DIR], [Directory for udev rules files]),
416             [],
417             [with_udevrulesdir=$($PKG_CONFIG --variable=udevdir udev)/rules.d])
418 AC_SUBST([udevrulesdir], [$with_udevrulesdir])
419
420 AC_ARG_WITH([udevbindir],
421             AS_HELP_STRING([--with-udevbindir=DIR], [Directory for udev binary files]),
422             [],
423             [with_udevbindir=$($PKG_CONFIG --variable=udevdir udev)])
424 AC_SUBST([udevbindir], [$with_udevbindir])
425
426 # ------------------------------------------------------------------------------
427 have_utmp=yes
428 AC_ARG_ENABLE([utmp], AS_HELP_STRING([--disable-utmp], [disable utmp/wtmp log handling]),
429         AS_CASE("x${enableval}",
430                 [xyes], [have_utmp=yes],
431                 [xno],  [have_utmp=no],
432                 AC_MSG_ERROR(bad value ${enableval} for --enable-utmp)))
433 AS_IF([test "x$have_utmp" = "xyes"], [AC_DEFINE(HAVE_UTMP, 1, [Define if utmp/wtmp support is enabled])])
434 AM_CONDITIONAL([HAVE_UTMP], [test "x$have_utmp" = "xyes"])
435
436 # ------------------------------------------------------------------------------
437 have_coverage=no
438 AC_ARG_ENABLE(coverage, AS_HELP_STRING([--enable-coverage], [enable test coverage]))
439 if test "x$enable_coverage" = "xyes" ; then
440         AC_CHECK_PROG(lcov_found, [lcov], [yes], [no])
441         if test "x$lcov_found" = xno ; then
442                 AC_MSG_ERROR([*** lcov support requested but the program was not found])
443         else
444                 lcov_version_major="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 1`"
445                 lcov_version_minor="`lcov --version | cut -d ' ' -f 4 | cut -d '.' -f 2`"
446                 if test "$lcov_version_major" -eq 1 -a "$lcov_version_minor" -lt 10; then
447                         AC_MSG_ERROR([*** lcov version is too old. 1.10 required])
448                 else
449                         have_coverage=yes
450                         CC_CHECK_FLAGS_APPEND([with_coverage_cflags], [CFLAGS], [\
451                         -fprofile-arcs \
452                         -ftest-coverage])
453                         AC_SUBST([OUR_CFLAGS], "$with_cflags $with_coverage_cflags")
454                 fi
455         fi
456 fi
457 AM_CONDITIONAL(ENABLE_COVERAGE, [test "$have_coverage" = "yes"])
458
459 # ------------------------------------------------------------------------------
460 have_selinux=no
461 AC_ARG_ENABLE(selinux, AS_HELP_STRING([--disable-selinux], [Disable optional SELINUX support]))
462 if test "x$enable_selinux" != "xno"; then
463         PKG_CHECK_MODULES([SELINUX], [libselinux >= 2.1.9],
464                 [AC_DEFINE(HAVE_SELINUX, 1, [Define if SELinux is available])
465                  have_selinux=yes
466                  M4_DEFINES="$M4_DEFINES -DHAVE_SELINUX"],
467                 [have_selinux=no])
468         if test "x$have_selinux" = xno -a "x$enable_selinux" = xyes; then
469                 AC_MSG_ERROR([*** SELinux support requested but libraries not found])
470         fi
471 fi
472 AM_CONDITIONAL(HAVE_SELINUX, [test "$have_selinux" = "yes"])
473
474 # ------------------------------------------------------------------------------
475 AC_ARG_WITH([kill-user-processes],
476         [AS_HELP_STRING([--without-kill-user-processes], [Set elogind's KillUserProcesses=no by default])])
477 AS_IF([test "$with_kill_user_processes" != "no"],
478        [kill_user_processes=true
479         KILL_USER_PROCESSES=yes],
480        [kill_user_processes=false
481         KILL_USER_PROCESSES=no])
482 AC_DEFINE_UNQUOTED(KILL_USER_PROCESSES, [$kill_user_processes], [Default KillUserProcesses setting])
483 AC_SUBST(KILL_USER_PROCESSES)
484
485 # ------------------------------------------------------------------------------
486 AC_ARG_ENABLE([pam],
487         AS_HELP_STRING([--disable-pam],[Disable optional PAM support]),
488                 [case "${enableval}" in
489                         yes) have_pam=yes ;;
490                         no) have_pam=no ;;
491                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-pam) ;;
492                 esac],
493                 [have_pam=auto])
494
495 if test "x${have_pam}" != xno ; then
496         AC_CHECK_HEADERS(
497                 [security/pam_modules.h security/pam_modutil.h security/pam_ext.h],
498                 [have_pam=yes],
499                 [if test "x$have_pam" = xyes ; then
500                         AC_MSG_ERROR([*** PAM headers not found.])
501                 fi])
502
503         AC_CHECK_LIB(
504                 [pam],
505                 [pam_syslog],
506                 [have_pam=yes],
507                 [if test "x$have_pam" = xyes ; then
508                         AC_MSG_ERROR([*** libpam not found.])
509                 fi])
510
511         if test "x$have_pam" = xyes ; then
512                 PAM_LIBS="-lpam -lpam_misc"
513                 AC_DEFINE(HAVE_PAM, 1, [PAM available])
514                 M4_DEFINES="$M4_DEFINES -DHAVE_PAM"
515         else
516                 have_pam=no
517         fi
518 else
519         PAM_LIBS=
520 fi
521 AC_SUBST(PAM_LIBS)
522 AM_CONDITIONAL([HAVE_PAM], [test "x$have_pam" != xno])
523
524 # ------------------------------------------------------------------------------
525 AC_ARG_ENABLE([acl],
526         AS_HELP_STRING([--disable-acl],[Disable optional ACL support]),
527                 [case "${enableval}" in
528                         yes) have_acl=yes ;;
529                         no) have_acl=no ;;
530                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-acl) ;;
531                 esac],
532                 [have_acl=auto])
533
534 if test "x${have_acl}" != xno ; then
535         AC_CHECK_HEADERS(
536                 [sys/acl.h acl/libacl.h],
537                 [have_acl=yes],
538                 [if test "x$have_acl" = xyes ; then
539                         AC_MSG_ERROR([*** ACL headers not found.])
540                 fi])
541
542         AC_CHECK_LIB(
543                 [acl],
544                 [acl_get_file],
545                 [have_acl=yes],
546                 [if test "x$have_acl" = xyes ; then
547                         AC_MSG_ERROR([*** libacl not found.])
548                 fi])
549
550         if test "x$have_acl" = xyes ; then
551                 ACL_LIBS="-lacl"
552                 AC_DEFINE(HAVE_ACL, 1, [ACL available])
553                 M4_DEFINES="$M4_DEFINES -DHAVE_ACL"
554         else
555                 have_acl=no
556         fi
557 else
558         ACL_LIBS=
559 fi
560 AC_SUBST(ACL_LIBS)
561 AM_CONDITIONAL([HAVE_ACL], [test "x$have_acl" != xno])
562
563 # ------------------------------------------------------------------------------
564 AC_ARG_ENABLE([smack], AS_HELP_STRING([--disable-smack],[Disable optional SMACK support]),
565                 [case "${enableval}" in
566                         yes) have_smack=yes ;;
567                         no) have_smack=no ;;
568                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-smack) ;;
569                 esac],
570                 [have_smack=auto])
571
572 if test "x${have_smack}" != xno; then
573         AC_DEFINE(HAVE_SMACK, 1, [Define if SMACK is available])
574         M4_DEFINES="$M4_DEFINES -DHAVE_SMACK"
575         have_smack=yes
576 fi
577
578 AM_CONDITIONAL([HAVE_SMACK], [test "x$have_smack" = "xyes"])
579
580 have_smack_run_label=no
581 AC_ARG_WITH(smack-run-label,
582 AS_HELP_STRING([--with-smack-run-label=STRING],
583         [run systemd --system itself with a specific SMACK label]),
584         [AC_DEFINE_UNQUOTED(SMACK_RUN_LABEL, ["$withval"], [Run systemd itself with SMACK label]) have_smack_run_label=yes],
585         [])
586
587 if test "x${have_smack_run_label}" = xyes; then
588         M4_DEFINES="$M4_DEFINES -DHAVE_SMACK_RUN_LABEL"
589 fi
590
591 AC_ARG_WITH(smack-default-process-label,
592 AS_HELP_STRING([--with-smack-default-process-label=STRING],
593         [default SMACK label for executed processes]),
594         [AC_DEFINE_UNQUOTED(SMACK_DEFAULT_PROCESS_LABEL, ["$withval"], [Default SMACK label for executed processes])],
595         [])
596
597 # ------------------------------------------------------------------------------
598 AC_ARG_WITH(system-uid-max,
599         AS_HELP_STRING([--with-system-uid-max=UID]
600                 [Maximum UID for system users]),
601         [SYSTEM_UID_MAX="$withval"],
602         [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`"])
603
604 AC_DEFINE_UNQUOTED(SYSTEM_UID_MAX, [$SYSTEM_UID_MAX], [Maximum System UID])
605 AC_SUBST(SYSTEM_UID_MAX)
606
607 # ------------------------------------------------------------------------------
608 AC_ARG_WITH(system-gid-max,
609         AS_HELP_STRING([--with-system-gid-max=GID]
610                 [Maximum GID for system groups]),
611         [SYSTEM_GID_MAX="$withval"],
612         [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`"])
613
614 AC_DEFINE_UNQUOTED(SYSTEM_GID_MAX, [$SYSTEM_GID_MAX], [Maximum System GID])
615 AC_SUBST(SYSTEM_GID_MAX)
616
617 # ------------------------------------------------------------------------------
618 have_polkit=no
619 AC_ARG_ENABLE(polkit, AS_HELP_STRING([--disable-polkit], [disable PolicyKit support]))
620 if test "x$enable_polkit" != "xno"; then
621         AC_DEFINE(ENABLE_POLKIT, 1, [Define if PolicyKit support is to be enabled])
622         have_polkit=yes
623 fi
624 AM_CONDITIONAL(ENABLE_POLKIT, [test "x$have_polkit" = "xyes"])
625
626 # ------------------------------------------------------------------------------
627 have_kdbus=no
628 AC_ARG_ENABLE(kdbus, AS_HELP_STRING([--disable-kdbus], [do not connect to kdbus by default]))
629 if test "x$enable_kdbus" != "xno"; then
630         AC_DEFINE(ENABLE_KDBUS, 1, [Define if kdbus is to be connected to by default])
631         have_kdbus=yes
632         M4_DEFINES="$M4_DEFINES -DENABLE_KDBUS"
633 fi
634 AM_CONDITIONAL(ENABLE_KDBUS, [test "$have_kdbus" = "yes"])
635
636 # ------------------------------------------------------------------------------
637 AC_CHECK_HEADERS_ONCE([valgrind/memcheck.h valgrind/valgrind.h])
638
639 # ------------------------------------------------------------------------------
640 have_manpages=no
641 AC_ARG_ENABLE(manpages, AS_HELP_STRING([--disable-manpages], [disable manpages]))
642 AC_PATH_PROG([XSLTPROC], [xsltproc])
643 AS_IF([test "x$enable_manpages" != xno], [have_manpages=yes])
644 AM_CONDITIONAL(ENABLE_MANPAGES, [test "x$have_manpages" = "xyes"])
645
646 # ------------------------------------------------------------------------------
647 AC_SUBST(M4_DEFINES)
648
649 AC_ARG_WITH([dbuspolicydir],
650         AS_HELP_STRING([--with-dbuspolicydir=DIR], [D-Bus policy directory]),
651         [],
652         [with_dbuspolicydir=${sysconfdir}/dbus-1/system.d])
653 AX_NORMALIZE_PATH([with_dbuspolicydir])
654
655 AC_ARG_WITH([dbussystemservicedir],
656         AS_HELP_STRING([--with-dbussystemservicedir=DIR], [D-Bus system service directory]),
657         [],
658         [with_dbussystemservicedir=${datadir}/dbus-1/system-services])
659 AX_NORMALIZE_PATH([with_dbussystemservicedir])
660
661 AC_ARG_WITH([bashcompletiondir],
662         AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
663         [],
664         [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
665                 with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
666         ] , [
667                 with_bashcompletiondir=${datadir}/bash-completion/completions
668         ])])
669 AM_CONDITIONAL(ENABLE_BASH_COMPLETION, [test "$with_bashcompletiondir" != "no"])
670 AX_NORMALIZE_PATH([with_bashcompletiondir])
671
672 AC_ARG_WITH([zshcompletiondir],
673         AS_HELP_STRING([--with-zshcompletiondir=DIR], [Zsh completions directory]),
674         [], [with_zshcompletiondir=${datadir}/zsh/site-functions])
675 AM_CONDITIONAL(ENABLE_ZSH_COMPLETION, [test "$with_zshcompletiondir" != "no"])
676 AX_NORMALIZE_PATH([with_zshcompletiondir])
677
678 AC_ARG_WITH([rootprefix],
679         AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]),
680         [], [with_rootprefix=${ac_default_prefix}])
681 # --with-rootprefix= (empty) should default to "/" but AX_NORMALIZE_PATH
682 # defaults those to ".", solve that here for now until we can find a suitable
683 # fix for AX_NORMALIZE_PATH upstream at autoconf-archive.
684 # See: https://github.com/systemd/systemd/issues/54
685 if test "x${with_rootprefix}" = "x"; then
686         with_rootprefix="/"
687 fi
688 AX_NORMALIZE_PATH([with_rootprefix])
689
690 AC_ARG_WITH([rootlibdir],
691         AS_HELP_STRING([--with-rootlibdir=DIR], [Root directory for libraries necessary for boot]),
692         [],
693         [with_rootlibdir=${libdir}])
694 AX_NORMALIZE_PATH([with_rootlibdir])
695
696 AC_ARG_WITH([pamlibdir],
697         AS_HELP_STRING([--with-pamlibdir=DIR], [Directory for PAM modules]),
698         [],
699         [with_pamlibdir=${with_rootlibdir}/security])
700 AX_NORMALIZE_PATH([with_pamlibdir])
701
702 AC_ARG_WITH([pamconfdir],
703         AS_HELP_STRING([--with-pamconfdir=DIR], [Directory for PAM configuration]),
704         [],
705         [with_pamconfdir=${sysconfdir}/pam.d])
706 AX_NORMALIZE_PATH([with_pamconfdir])
707
708 AC_ARG_ENABLE([split-usr],
709         AS_HELP_STRING([--enable-split-usr], [Assume that /bin, /sbin aren\'t symlinks into /usr]),
710         [],
711         [AS_IF([test "x${ac_default_prefix}" != "x${with_rootprefix}"], [
712                 enable_split_usr=yes
713         ], [
714                 enable_split_usr=no
715         ])])
716
717 AS_IF([test "x${enable_split_usr}" = "xyes"], [
718         AC_DEFINE(HAVE_SPLIT_USR, 1, [Define if /bin, /sbin aren't symlinks into /usr])
719 ])
720 AM_CONDITIONAL(ENABLE_SPLIT_USR, [test "x${enable_split_usr}" = "xyes"])
721
722 # work around intltool-update issues during 'make distcheck'
723 AS_IF([test "x$0" != "x./configure"], [
724         AC_SUBST([INTLTOOL_UPDATE], [/usr/bin/env true])
725 ])
726
727 AC_ARG_ENABLE(tests,
728         [AC_HELP_STRING([--disable-tests], [disable tests])],
729         enable_tests=$enableval, enable_tests=yes)
730 AM_CONDITIONAL(ENABLE_TESTS, [test x$enable_tests = xyes])
731
732 AC_ARG_ENABLE(debug,
733         [AC_HELP_STRING([--enable-debug@<:@=LIST@:>@], [enable extra debugging (elogind,hashmap,mmap-cache)])],
734         [if test "x$enableval" = "xyes"; then
735                 enableval="elogind,hashmap,mmap-cache"
736         fi
737         saved_ifs="$IFS"
738         IFS="$IFS$PATH_SEPARATOR,"
739         for name in $enableval; do
740                 case $name in
741                 elogind)
742                         enable_debug_elogind=yes
743                         ;;
744                 hashmap)
745                         enable_debug_hashmap=yes
746                         ;;
747                 mmap-cache)
748                         enable_debug_mmap_cache=yes
749                         ;;
750                 esac
751         done
752         IFS="$saved_ifs"],[])
753
754 enable_debug=""
755 AS_IF([test x$enable_debug_elogind = xyes], [
756         AC_DEFINE(ENABLE_DEBUG_ELOGIND, 1, [Define if elogind debugging is to be enabled])
757         enable_debug="elogind $enable_debug"
758 ])
759 AS_IF([test x$enable_debug_hashmap = xyes], [
760         AC_DEFINE(ENABLE_DEBUG_HASHMAP, 1, [Define if hashmap debugging is to be enabled])
761         enable_debug="hashmap $enable_debug"
762 ])
763 AS_IF([test x$enable_debug_mmap_cache = xyes], [
764         AC_DEFINE(ENABLE_DEBUG_MMAP_CACHE, 1, [Define if mmap cache debugging is to be enabled])
765         enable_debug="mmap-cache $enable_debug"
766 ])
767 test -z "$enable_debug" && enable_debug="none"
768
769 AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])
770 AC_SUBST([dbussystemservicedir], [$with_dbussystemservicedir])
771 AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
772 AC_SUBST([zshcompletiondir], [$with_zshcompletiondir])
773 AC_SUBST([pamlibdir], [$with_pamlibdir])
774 AC_SUBST([pamconfdir], [$with_pamconfdir])
775 AC_SUBST([rootprefix], [$with_rootprefix])
776 AC_SUBST([rootlibdir], [$with_rootlibdir])
777 AC_SUBST([cgroup_controller], [$with_cgroupctrl])
778
779 AC_CONFIG_FILES([
780         Makefile
781         po/Makefile.in
782 ])
783
784 AC_OUTPUT
785 AC_MSG_RESULT([
786         $PACKAGE_NAME $VERSION
787
788         PAM:                     ${have_pam}
789         SELinux:                 ${have_selinux}
790         SMACK:                   ${have_smack}
791         ACL:                     ${have_acl}
792         KillUserProcesses default: ${KILL_USER_PROCESSES}
793         polkit:                  ${have_polkit}
794         kdbus:                   ${have_kdbus}
795         Python:                  ${have_python}
796         man pages:               ${have_manpages}
797         test coverage:           ${have_coverage}
798         Split /usr:              ${enable_split_usr}
799         utmp/wtmp support:       ${have_utmp}
800         Link time optimization:  ${have_lto}
801         extra debugging:         ${enable_debug}
802         cgroup controller:       ${with_cgroupctrl}
803
804         prefix:                  ${prefix}
805         rootprefix:              ${with_rootprefix}
806         sysconf dir:             ${sysconfdir}
807         datarootdir:             ${datarootdir}
808         includedir:              ${includedir}
809         lib dir:                 ${libdir}
810         rootlib dir:             ${with_rootlibdir}
811         PAM modules dir:         ${with_pamlibdir}
812         PAM configuration dir:   ${with_pamconfdir}
813         D-Bus policy dir:        ${with_dbuspolicydir}
814         D-Bus system dir:        ${with_dbussystemservicedir}
815         Bash completions dir:    ${with_bashcompletiondir}
816         Zsh completions dir:     ${with_zshcompletiondir}
817         Maximum System UID:      ${SYSTEM_UID_MAX}
818         Maximum System GID:      ${SYSTEM_GID_MAX}
819
820         CFLAGS:                  ${OUR_CFLAGS} ${CFLAGS}
821         CPPFLAGS:                ${OUR_CPPFLAGS} ${CPPFLAGS}
822         LDFLAGS:                 ${OUR_LDFLAGS} ${LDFLAGS}
823 ])