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