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