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