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