+m4_ifdef([GOBJECT_INTROSPECTION_CHECK], [
+GOBJECT_INTROSPECTION_CHECK([1.31.1])
+], [
+ AM_CONDITIONAL([HAVE_INTROSPECTION], [false])
+ enable_introspection=no])
+
+AC_PATH_TOOL(OBJCOPY, objcopy)
+AC_PATH_TOOL(STRINGS, strings)
+AC_PATH_TOOL(GPERF, gperf)
+if test -z "$GPERF" ; then
+ AC_MSG_ERROR([*** gperf not found])
+fi
+
+CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
+ -pipe \
+ -Wall \
+ -Wextra \
+ -Wno-inline \
+ -Wundef \
+ "-Wformat=2 -Wformat-security -Wformat-nonliteral" \
+ -Wlogical-op \
+ -Wsign-compare \
+ -Wmissing-include-dirs \
+ -Wold-style-definition \
+ -Wpointer-arith \
+ -Winit-self \
+ -Wdeclaration-after-statement \
+ -Wfloat-equal \
+ -Wmissing-prototypes \
+ -Wstrict-prototypes \
+ -Wredundant-decls \
+ -Wmissing-declarations \
+ -Wmissing-noreturn \
+ -Wshadow \
+ -Wendif-labels \
+ -Wcast-align \
+ -Wstrict-aliasing=2 \
+ -Wwrite-strings \
+ -Wno-long-long \
+ -Wno-overlength-strings \
+ -Wno-unused-parameter \
+ -Wno-missing-field-initializers \
+ -Wno-unused-result \
+ -Werror=overflow \
+ -ffast-math \
+ -fno-common \
+ -fdiagnostics-show-option \
+ -fno-strict-aliasing \
+ -fvisibility=hidden \
+ -ffunction-sections \
+ -fdata-sections \
+ -fstack-protector \
+ --param=ssp-buffer-size=4])
+AC_SUBST([OUR_CFLAGS], $with_cflags)
+
+AS_CASE([$CFLAGS], [*-O[[12345g\ ]]*], [
+ CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
+ -Wp,-D_FORTIFY_SOURCE=2])], [
+ python_extra_cflags=-Wp,-U_FORTIFY_SOURCE
+ AC_MSG_RESULT([skipping -D_FORTIFY_SOURCE, optimization not enabled])])
+AC_SUBST([OUR_CPPFLAGS], $with_cppflags)
+
+CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
+ -Wl,--as-needed \
+ -Wl,--gc-sections \
+ -Wl,-z,relro \
+ -Wl,-z,now])
+AC_SUBST([OUR_LDFLAGS], $with_ldflags)
+
+# ------------------------------------------------------------------------------
+# we use python to build the man page index, and for systemd-python
+have_python=no
+have_python_devel=no
+
+AC_ARG_WITH([python],
+ [AS_HELP_STRING([--without-python], [Disable building the man page index and systemd-python (default: test)])])
+
+AS_IF([test "x$with_python" != "xno"], [
+ AM_PATH_PYTHON(,, [:])
+ AS_IF([test "$PYTHON" != :], [have_python=yes])
+])
+AM_CONDITIONAL([HAVE_PYTHON], [test "x$have_python" = "xyes"])
+AS_IF([test "x$PYTHON_BINARY" = "x"],
+ [AS_IF([test "x$have_python" = "xyes"],
+ [PYTHON_BINARY="$(which "$PYTHON")"],
+ [PYTHON_BINARY=/usr/bin/python])])
+AC_ARG_VAR(PYTHON_BINARY, [Python binary used to launch installed scripts])
+
+AS_IF([test "x$with_python" != "xno"], [
+ AC_PATH_PROG(PYTHON_CONFIG, python${PYTHON_VERSION}-config)
+ AS_IF([test -n "$PYTHON_CONFIG"], [
+ have_python_devel=yes
+ PYTHON_CFLAGS="$($PYTHON_CONFIG --cflags) $python_extra_cflags"
+ PYTHON_LIBS="$($PYTHON_CONFIG --ldflags)"
+ AC_SUBST(PYTHON_CFLAGS)
+ AC_SUBST(PYTHON_LIBS)
+ AC_PATH_PROGS(SPHINX_BUILD, sphinx-build-${PYTHON_VERSION} sphinx-build)
+ ])
+])
+AM_CONDITIONAL([HAVE_PYTHON_DEVEL], [test "$have_python_devel" = "yes"])
+
+# ------------------------------------------------------------------------------
+
+AC_SEARCH_LIBS([mq_open], [rt], [], [AC_MSG_ERROR([*** POSIX RT library not found])])
+AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader library not found])])
+
+save_LIBS="$LIBS"
+LIBS=
+AC_SEARCH_LIBS([cap_init], [cap], [], [AC_MSG_ERROR([*** POSIX caps library not found])])
+AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
+CAP_LIBS="$LIBS"
+LIBS="$save_LIBS"
+AC_SUBST(CAP_LIBS)
+
+AC_CHECK_FUNCS([fanotify_init fanotify_mark])
+AC_CHECK_FUNCS([__secure_getenv secure_getenv])
+AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at], [], [], [[#include <sys/types.h>
+#include <unistd.h>
+#include <sys/mount.h>
+#include <fcntl.h>]])
+
+# This makes sure pkg.m4 is available.
+m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
+
+PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.3.2])
+
+# ------------------------------------------------------------------------------
+have_kmod=no
+AC_ARG_ENABLE(kmod, AS_HELP_STRING([--disable-kmod], [disable loadable modules support]))
+if test "x$enable_kmod" != "xno"; then
+ PKG_CHECK_MODULES(KMOD, [ libkmod >= 5 ],
+ [AC_DEFINE(HAVE_KMOD, 1, [Define if kmod is available]) have_kmod=yes], have_kmod=no)
+ if test "x$have_kmod" = xno -a "x$enable_kmod" = xyes; then
+ AC_MSG_ERROR([*** kmod support requested but libraries not found])
+ fi
+fi
+AM_CONDITIONAL(HAVE_KMOD, [test "$have_kmod" = "yes"])
+
+# ------------------------------------------------------------------------------
+have_blkid=no
+AC_ARG_ENABLE(blkid, AS_HELP_STRING([--disable-blkid], [disable blkid support]))
+if test "x$enable_blkid" != "xno"; then
+ PKG_CHECK_MODULES(BLKID, [ blkid >= 2.20 ],
+ [AC_DEFINE(HAVE_BLKID, 1, [Define if blkid is available]) have_blkid=yes], have_blkid=no)
+ if test "x$have_blkid" = xno -a "x$enable_blkid" = xyes; then
+ AC_MSG_ERROR([*** blkid support requested but libraries not found])
+ fi
+fi
+AM_CONDITIONAL(HAVE_BLKID, [test "$have_blkid" = "yes"])
+
+# ------------------------------------------------------------------------------
+have_ima=yes
+AC_ARG_ENABLE([ima], AS_HELP_STRING([--disable-ima],[Disable optional IMA support]),
+ [case "${enableval}" in
+ yes) have_ima=yes ;;
+ no) have_ima=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-ima) ;;
+ esac],
+ [have_ima=yes])
+
+if test "x${have_ima}" != xno ; then
+ AC_DEFINE(HAVE_IMA, 1, [Define if IMA is available])
+fi
+
+# ------------------------------------------------------------------------------
+have_chkconfig=yes
+AC_ARG_ENABLE([chkconfig], AS_HELP_STRING([--disable-chkconfig],[Disable optional chkconfig support]),
+ [case "${enableval}" in
+ yes) have_chkconfig=yes ;;
+ no) have_chkconfig=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-chkconfig) ;;
+ esac],
+ [AC_PATH_PROG(CHKCONFIG, chkconfig)
+ if test -z "$CHKCONFIG"; then
+ have_chkconfig=no
+ else
+ have_chkconfig=yes
+ fi])
+
+if test "x${have_chkconfig}" != xno ; then
+ AC_DEFINE(HAVE_CHKCONFIG, 1, [Define if CHKCONFIG is available])
+fi
+
+# ------------------------------------------------------------------------------
+have_selinux=no
+AC_ARG_ENABLE(selinux, AS_HELP_STRING([--disable-selinux], [Disable optional SELINUX support]))
+if test "x$enable_selinux" != "xno"; then
+ PKG_CHECK_MODULES([SELINUX], [libselinux >= 2.1.9],
+ [AC_DEFINE(HAVE_SELINUX, 1, [Define if SELinux is available]) have_selinux=yes], have_selinux=no)
+ if test "x$have_selinux" = xno -a "x$enable_selinux" = xyes; then
+ AC_MSG_ERROR([*** SELinux support requested but libraries not found])
+ fi
+fi
+AM_CONDITIONAL(HAVE_SELINUX, [test "$have_selinux" = "yes"])
+if test "x${have_selinux}" != xno ; then
+ SUSHELL=/sbin/sushell
+else
+ SUSHELL=/bin/sh
+fi
+AC_SUBST(SUSHELL)
+
+# ------------------------------------------------------------------------------
+have_xz=no
+AC_ARG_ENABLE(xz, AS_HELP_STRING([--disable-xz], [Disable optional XZ support]))
+if test "x$enable_xz" != "xno"; then
+ PKG_CHECK_MODULES(XZ, [ liblzma ],
+ [AC_DEFINE(HAVE_XZ, 1, [Define if XZ is available]) have_xz=yes], have_xz=no)
+ if test "x$have_xz" = xno -a "x$enable_xz" = xyes; then
+ AC_MSG_ERROR([*** Xz support requested but libraries not found])
+ fi
+fi
+AM_CONDITIONAL(HAVE_XZ, [test "$have_xz" = "yes"])
+
+# ------------------------------------------------------------------------------
+AC_ARG_ENABLE([tcpwrap],
+ AS_HELP_STRING([--disable-tcpwrap],[Disable optional TCP wrappers support]),
+ [case "${enableval}" in
+ yes) have_tcpwrap=yes ;;
+ no) have_tcpwrap=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-tcpwrap) ;;
+ esac],
+ [have_tcpwrap=auto])
+
+if test "x${have_tcpwrap}" != xno ; then
+ ACX_LIBWRAP
+ if test "x${LIBWRAP_LIBS}" = x ; then
+ if test "x$have_tcpwrap" = xyes ; then
+ AC_MSG_ERROR([*** TCP wrappers support not found.])
+ fi
+ have_tcpwrap=no
+ else
+ have_tcpwrap=yes
+ fi
+else
+ LIBWRAP_LIBS=
+fi
+AC_SUBST(LIBWRAP_LIBS)
+
+# ------------------------------------------------------------------------------
+AC_ARG_ENABLE([pam],
+ AS_HELP_STRING([--disable-pam],[Disable optional PAM support]),
+ [case "${enableval}" in
+ yes) have_pam=yes ;;
+ no) have_pam=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-pam) ;;
+ esac],
+ [have_pam=auto])
+
+if test "x${have_pam}" != xno ; then
+ AC_CHECK_HEADERS(
+ [security/pam_modules.h security/pam_modutil.h security/pam_ext.h],
+ [have_pam=yes],
+ [if test "x$have_pam" = xyes ; then
+ AC_MSG_ERROR([*** PAM headers not found.])
+ fi])
+
+ AC_CHECK_LIB(
+ [pam],
+ [pam_syslog],
+ [have_pam=yes],
+ [if test "x$have_pam" = xyes ; then
+ AC_MSG_ERROR([*** libpam not found.])
+ fi])
+
+ if test "x$have_pam" = xyes ; then
+ PAM_LIBS="-lpam -lpam_misc"
+ AC_DEFINE(HAVE_PAM, 1, [PAM available])
+ else
+ have_pam=no
+ fi
+else
+ PAM_LIBS=
+fi
+AC_SUBST(PAM_LIBS)
+AM_CONDITIONAL([HAVE_PAM], [test "x$have_pam" != xno])
+
+# ------------------------------------------------------------------------------
+AC_ARG_ENABLE([acl],
+ AS_HELP_STRING([--disable-acl],[Disable optional ACL support]),
+ [case "${enableval}" in
+ yes) have_acl=yes ;;
+ no) have_acl=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-acl) ;;
+ esac],
+ [have_acl=auto])
+
+if test "x${have_acl}" != xno ; then
+ AC_CHECK_HEADERS(
+ [sys/acl.h acl/libacl.h],
+ [have_acl=yes],
+ [if test "x$have_acl" = xyes ; then
+ AC_MSG_ERROR([*** ACL headers not found.])
+ fi])
+
+ AC_CHECK_LIB(
+ [acl],
+ [acl_get_file],
+ [have_acl=yes],
+ [if test "x$have_acl" = xyes ; then
+ AC_MSG_ERROR([*** libacl not found.])
+ fi])