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