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