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