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