diff options
author | Eric Koegel <eric.koegel@gmail.com> | 2017-05-14 05:17:31 +0300 |
---|---|---|
committer | Eric Koegel <eric.koegel@gmail.com> | 2017-05-21 01:59:53 +0300 |
commit | 7b2d543880263c4c7f1fc09a9959a254efe0d1c4 (patch) | |
tree | 9278c6b2cf65c3563502dda6057c21ad01a36d64 | |
parent | 4fed37113499fe999bf0c0f171e57215305aba27 (diff) | |
download | ConsoleKit2-7b2d543880263c4c7f1fc09a9959a254efe0d1c4.tar.gz |
chore: simplify configure.ac
Pull in the m4 macros from the xfce4-dev-tools so
we have ways to simplify and shorten the configure.ac
file.
-rw-r--r-- | configure.ac | 254 | ||||
-rw-r--r-- | libck-connector/Makefile.am | 1 | ||||
-rw-r--r-- | m4/xdt-depends.m4 | 336 | ||||
-rw-r--r-- | m4/xdt-features.m4 | 219 | ||||
-rw-r--r-- | pam-ck-connector/Makefile.am | 1 | ||||
-rw-r--r-- | src/Makefile.am | 43 | ||||
-rw-r--r-- | tools/Makefile.am | 51 |
7 files changed, 699 insertions, 206 deletions
diff --git a/configure.ac b/configure.ac index b17801a..ac41934 100644 --- a/configure.ac +++ b/configure.ac @@ -1,16 +1,18 @@ AC_COPYRIGHT([Copyright 2014-2017 The ConsoleKit2 Team]) -AC_PREREQ([2.50]) +AC_PREREQ([2.60]) AC_INIT([ConsoleKit2], [1.1.1], [https://github.com/ConsoleKit2/ConsoleKit2/issues], - [ConsoleKit2]) + [ConsoleKit2], + [https://github.com/ConsoleKit2/ConsoleKit2]) VERSION_MAJOR=1 VERSION_MINOR=1 VERSION_REVISION=1 -COPYRIGHT_YEARS="2014 2017" + +COPYRIGHT_YEARS="2014 - 2017" AC_CONFIG_HEADERS([config.h]) AC_CONFIG_AUX_DIR([autotools]) @@ -19,7 +21,7 @@ AC_CONFIG_SRCDIR([src/ck-manager.c]) AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar no-dist-gzip]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -AM_MAINTAINER_MODE +AM_MAINTAINER_MODE([enable]) # for O_NOFOLLOW support AC_USE_SYSTEM_EXTENSIONS @@ -38,6 +40,7 @@ AC_PATH_X AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_SSIZE_T +AC_TYPE_UID_T AC_SUBST(VERSION) @@ -52,11 +55,13 @@ AM_GNU_GETTEXT([external]) AM_NLS # Dependencies - -DBUS_REQUIRED_VERSION=0.82 -GLIB_REQUIRED_VERSION=2.40 -X11_REQUIRED_VERSION=1.0.0 -POLKIT_REQUIRED_VERSION=0.92 +m4_define([glib_minimum_version], [2.40]) +m4_define([dbus_minimum_version], [0.82]) +m4_define([x11_minimum_version], [1.0.0]) +m4_define([polkit_minimum_version], [0.92]) +m4_define([cgmanager_minimum_version], [0.0.0]) +m4_define([libevdev_minimum_version], [0.2]) +m4_define([selinux_minimum_version], [1.0]) AC_CHECK_HEADERS([unistd.h paths.h sys/vt.h sys/consio.h fcntl.h limits.h \ sys/ioctl.h sys/param.h sys/socket.h syslog.h kvm.h \ @@ -76,60 +81,38 @@ AC_CHECK_FILE(/sys/class/tty/tty0/active, [AC_DEFINE([HAVE_SYS_VT_SIGNAL], [1], [System has a means of signaling VT changes])], []) -AC_TYPE_UID_T -PKG_CHECK_MODULES(CONSOLE_KIT, - dbus-1 >= $DBUS_REQUIRED_VERSION - gobject-2.0 >= $GLIB_REQUIRED_VERSION - gthread-2.0 >= $GLIB_REQUIRED_VERSION - gio-unix-2.0 >= $GLIB_REQUIRED_VERSION -) - -PKG_CHECK_MODULES([XLIB], [x11]) - -have_polkit=no -AC_ARG_ENABLE([polkit], - AS_HELP_STRING([--enable-polkit], [Enable PolicyKit support @<:@default=auto@:>@]), - [enable_polkit=$enableval], - [enable_polkit=auto]) -AS_IF([test "x$enable_polkit" != "xno"], [ - PKG_CHECK_MODULES([POLKIT], [polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION], [have_polkit=yes], [have_polkit=no]) - if test "x$enable_polkit" = "xyes" -a "x$have_polkit" = "xno"; then - AC_MSG_ERROR([PolicyKit support explicitly requested but dependencies not found]) - fi -]) -AS_IF([test "x$have_polkit" = "xyes"], [ - AC_DEFINE([HAVE_POLKIT], [], [Define if we have polkit]) -]) -AM_CONDITIONAL([HAVE_POLKIT], [test "x$have_polkit" = "xyes"]) -AC_SUBST(HAVE_POLKIT) +XDT_CHECK_PACKAGE([LIBDBUS], [dbus-1], [dbus_minimum_version]) +XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [glib_minimum_version]) +XDT_CHECK_PACKAGE([GIO], [gio-2.0], [glib_minimum_version]) +XDT_CHECK_PACKAGE([GIO_UNIX], [gio-unix-2.0], [glib_minimum_version]) + + +AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_40, [Ignore post 2.40 deprecations]) +AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_40, [Prevent post 2.40 APIs]) -PKG_CHECK_MODULES(LIBDBUS, - dbus-1 >= $DBUS_REQUIRED_VERSION -) -PKG_CHECK_MODULES(TOOLS, - x11 >= $X11_REQUIRED_VERSION - glib-2.0 >= $GLIB_REQUIRED_VERSION -) -PKG_CHECK_MODULES(HISTORY, - glib-2.0 >= $GLIB_REQUIRED_VERSION -) +# Check for X11 installed +XDT_CHECK_LIBX11_REQUIRE() + +# Check for Polkit/PolicyKit +XDT_CHECK_OPTIONAL_PACKAGE([POLKIT], [polkit-gobject-1], [polkit_minimum_version], + [polkit], [Enable PolicyKit support @<:@default=auto@:>@]) + AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal) -EXTRA_COMPILE_WARNINGS(yes) # Solaris requires libresolv for daemon() case "$host_os" in solaris*) - AC_CHECK_LIB(resolv, daemon, [CONSOLE_KIT_LIBS="$CONSOLE_KIT_LIBS -lresolv"]) + AC_CHECK_LIB(resolv, daemon, [CK2_LIBS="$CK2_LIBS -lresolv"]) ;; kfreebsd*-gnu) have_getpeereid=no AC_CHECK_LIB(bsd, getpeereid, have_getpeereid=yes) if test "x$have_getpeereid" = "xyes"; then - CONSOLE_KIT_LIBS="${CONSOLE_KIT_LIBS} -lbsd" + CK2_LIBS="${CK2_LIBS} -lbsd" TOOLS_LIBS="${TOOLS_LIBS} -lbsd" AC_DEFINE(HAVE_GETPEEREID, [], [Define if we have getpeereid]) fi @@ -288,59 +271,19 @@ AM_CONDITIONAL(HAVE_LINUXPAM, test "x$have_linuxpam" = "xyes") # cgroups - Using the kernel to track processes instead of the cookie -have_cgmanager=no -AC_ARG_ENABLE([cgroups], - AS_HELP_STRING([--enable-cgroups], [Enable cgroup support @<:@default=auto@:>@]), - [enable_cgroups=$enableval], - [enable_cgroups=auto]) -AS_IF([test "x$enable_cgroups" != "xno"], [ - PKG_CHECK_MODULES([CGMANAGER], [libcgmanager libnih >= 1.0.2 libnih-dbus >= 1.0.0], [have_cgmanager=yes], [have_cgmanager=no]) - if test "x$enable_cgroups" = "xyes" -a "x$have_cgmanager" = "xno"; then - AC_MSG_ERROR([cgroup support explicitly requested but dependencies not found]) - fi -]) -AS_IF([test "x$have_cgmanager" = "xyes"], [ - AC_DEFINE([HAVE_CGMANAGER], [], [Define if we have cgmanager]) -]) -AM_CONDITIONAL([HAVE_CGMANAGER], [test "x$have_cgmanager" = "xyes"]) -AC_SUBST(HAVE_CGMANAGER) - -# libevdev - for handling VT switching with a session controller -have_libevdev=no -AC_ARG_ENABLE([libevdev], - AS_HELP_STRING([--enable-libevdev], [Enable evdev support @<:@default=auto@:>@]), - [enable_libevdev=$enableval], - [enable_libevdev=auto]) -AS_IF([test "x$enable_libevdev" != "xno"], [ - PKG_CHECK_MODULES([LIBEVDEV], [libevdev], [have_libevdev=yes], [have_libevdev=no]) - if test "x$enable_libevdev" = "xyes" -a "x$have_libevdev" = "xno"; then - AC_MSG_ERROR([libevdev support explicitly requested but dependencies not found]) - fi -]) -AS_IF([test "x$have_libevdev" = "xyes"], [ - AC_DEFINE([HAVE_LIBEVDEV], [], [Define if we have libevdev]) -]) -AM_CONDITIONAL([HAVE_LIBEVDEV], [test "x$have_libevdev" = "xyes"]) -AC_SUBST(HAVE_LIBEVDEV) +XDT_CHECK_OPTIONAL_PACKAGE([CGMANAGER], [libcgmanager], [cgmanager_minimum_version], + [libcgmanager], + [cgmanager - Using the kernel to track processes instead of a session cookie]) + +# libevdev - for device management with a session controller +XDT_CHECK_OPTIONAL_PACKAGE([LIBEVDEV], [libevdev], [libevdev_minimum_version], + [libevdev], + [libevdev - for device management with a sessions controller]) # selinux -have_selinux=no -AC_ARG_ENABLE([selinux], - AS_HELP_STRING([--enable-selinux], [Enable selinux support @<:@default=auto@:>@]), - [enable_selinux=$enableval], - [enable_selinux=auto]) -AS_IF([test "x$enable_selinux" != "xno"], [ - PKG_CHECK_MODULES([SELINUX], [libselinux], [have_selinux=yes], [have_selinux=no]) - if test "x$enable_selinux" = "xyes" -a "x$have_selinux" = "xno"; then - AC_MSG_ERROR([selinux support explicitly requested but dependencies not found]) - fi -]) -AS_IF([test "x$have_selinux" = "xyes"], [ - AC_DEFINE([HAVE_SELINUX], [], [Define if we have selinux]) -]) -AM_CONDITIONAL([HAVE_SELINUX], [test "x$have_selinux" = "xyes"]) -AC_SUBST(HAVE_SELINUX) -AC_SUBST(SELINUX_LIBS) +XDT_CHECK_OPTIONAL_PACKAGE([SELINUX], [libselinux], [selinux_minimum_version], [libselinux], + [Security-Enhanced Linux support]) + dnl ------------------------------------------------------------------------------ dnl udev-acl - apply ACLs for users with local forground sessions @@ -514,79 +457,22 @@ dnl --------------------------------------------------------------------------- dnl Finish dnl --------------------------------------------------------------------------- -# Turn on the additional warnings last, so -Werror doesn't affect other tests. - -AC_ARG_ENABLE(more-warnings, - [AS_HELP_STRING([--enable-more-warnings],[Maximum compiler warnings])], - set_more_warnings="$enableval",[ - if test -d $srcdir/.git; then - set_more_warnings=yes - else - set_more_warnings=no - fi - ]) -AC_MSG_CHECKING(for more warnings) -if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then - AC_MSG_RESULT(yes) - CFLAGS="\ - -Wall \ - -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \ - -Wnested-externs -Wpointer-arith \ - -Wcast-align -Wsign-compare -Wp,-D_FORTIFY_SOURCE=2 \ - $CFLAGS" - - for option in -Wno-strict-aliasing -Wno-sign-compare; do - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $option" - AC_MSG_CHECKING([whether gcc understands $option]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[has_option=yes],[has_option=no]) - if test $has_option = no; then - CFLAGS="$SAVE_CFLAGS" - fi - AC_MSG_RESULT($has_option) - unset has_option - unset SAVE_CFLAGS - done - unset option -else - AC_MSG_RESULT(no) -fi - -# # Enable Debug -# -AC_ARG_ENABLE(debug, - [AS_HELP_STRING([--enable-debug@<:@=no|yes|full@:>@],[change debugging level @<:@default=@<:@yes@:>@@:>@])], - , enable_debug=yes) -AC_MSG_CHECKING([whether to enable debugging]) -if test "$enable_debug" = "yes"; then - DEBUG_CFLAGS="-DG_ENABLE_DEBUG" - AC_MSG_RESULT(yes) -else - if test "x$enable_debug" = "xno"; then - DEBUG_CFLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS" - AC_MSG_RESULT(no) - elif test "$enable_debug" = "full"; then - DEBUG_CFLAGS="-DG_ENABLE_DEBUG -DCONSOLEKIT_DEBUGGING" - AC_MSG_RESULT(yes) - else - DEBUG_CFLAGS= - AC_MSG_RESULT(yes) - fi -fi -AC_SUBST(DEBUG_CFLAGS) +XDT_FEATURE_DEBUG + +# Check for linker optimizations +XDT_FEATURE_LINKER_OPTS() # Flags -AC_SUBST(CONSOLE_KIT_CFLAGS) -AC_SUBST(CONSOLE_KIT_LIBS) +AC_SUBST(CK2_LIBS) +AC_SUBST(TOOLS_LIBS) AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) # systemd - AC_ARG_WITH([systemdsystemunitdir], AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]), [], [with_systemdsystemunitdir=no]) @@ -653,10 +539,8 @@ echo " source code location: ${srcdir} compiler: ${CC} cflags: ${CFLAGS} - debug cflags: ${DEBUG_CFLAGS} + Debugging support: $enable_debug build tests: ${enable_tests} - Base libs: ${CONSOLE_KIT_LIBS} - Tools libs: ${TOOLS_LIBS} Maintainer mode: ${USE_MAINTAINER_MODE} dbus-1 system.d dir: ${DBUS_SYS_DIR} @@ -664,17 +548,39 @@ echo " PAM module dir: ${PAM_MODULE_DIR} Build PAM module: ${msg_pam_module} Build udev-acl: ${enable_udev_acl} - udev support: ${have_libudev} - cgroup support: ${have_cgmanager} - libevdev support: ${have_libevdev} - SELinux support: ${have_selinux} + udev support: ${have_libudev}" + +if test x"$CGMANAGER_FOUND" = x"yes"; then +echo " cgroup support yes" +else +echo " cgroup support no" +fi + +if test x"$LIBEVDEV_FOUND" = x"yes"; then +echo " libevdev support yes" +else +echo " libevdev support no" +fi + +if test x"$POLKIT_FOUND" = x"yes"; then +echo " SELinux support: yes" +else +echo " SELinux support: no" +fi + +echo " Build docs: ${enable_docbook_docs} - xinitrc dir: ${XINITRC_DIR} + xinitrc dir: ${XINITRC_DIR}" + +if test x"$POLKIT_FOUND" = x"yes"; then +echo " PolicyKit support yes" +else +echo " PolicyKit support no" +fi + +echo " RBAC (Solaris) support: ${msg_rbac_shutdown}" - PolicyKit support ${have_polkit} - RBAC (Solaris) support: ${msg_rbac_shutdown} -" -if test x${have_polkit} = xno -a x${msg_rbac_shutdown} = xno; then +if test x"$POLKIT_FOUND" != x"yes" -a x${msg_rbac_shutdown} = xno; then echo "WARNING: PolicyKit and RBAC are disabled. You need to manually edit the ConsoleKit.conf" echo " file to lock down the service. Failure to do so may be" echo " a huge SECURITY HOLE. I repeat: YOU NEED TO EDIT THE FILE" diff --git a/libck-connector/Makefile.am b/libck-connector/Makefile.am index 9a8c0a8..9b09329 100644 --- a/libck-connector/Makefile.am +++ b/libck-connector/Makefile.am @@ -2,7 +2,6 @@ NULL = AM_CFLAGS = \ -I. \ - -U_FORTIFY_SOURCE \ $(LIBDBUS_CFLAGS) \ $(NULL) diff --git a/m4/xdt-depends.m4 b/m4/xdt-depends.m4 new file mode 100644 index 0000000..c6423a1 --- /dev/null +++ b/m4/xdt-depends.m4 @@ -0,0 +1,336 @@ +dnl Copyright (c) 2002-2015 +dnl The Xfce development team. All rights reserved. +dnl +dnl Written for Xfce by Benedikt Meurer <benny@xfce.org>. +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License along +dnl with this program; if not, write to the Free Software Foundation, Inc., +dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +dnl +dnl xdt-depends +dnl ----------- +dnl Contains M4 macros to check for software dependencies. +dnl Partly based on prior work of the XDG contributors. +dnl + + + +dnl We need recent a autoconf version +AC_PREREQ([2.60]) + + + +dnl XDT_PROG_PKG_CONFIG() +dnl +dnl Checks for the freedesktop.org pkg-config +dnl utility and sets the PKG_CONFIG environment +dnl variable to the full path if found. +dnl +AC_DEFUN([XDT_PROG_PKG_CONFIG], +[ + # minimum supported version of pkg-config + xdt_cv_PKG_CONFIG_MIN_VERSION=0.9.0 + + m4_ifdef([PKG_PROG_PKG_CONFIG], + [ + PKG_PROG_PKG_CONFIG([$xdt_cv_PKG_CONFIG_MIN_VERSION]) + + if test x"$PKG_CONFIG" = x""; then + echo + echo "*** Your version of pkg-config is too old. You need atleast" + echo "*** pkg-config $xdt_cv_PKG_CONFIG_MIN_VERSION or newer. You can download pkg-config" + echo "*** from the freedesktop.org software repository at" + echo "***" + echo "*** http://www.freedesktop.org/software/pkgconfig" + echo "***" + exit 1; + fi + ], + [ + echo + echo "*** The pkg-config utility could not be found on your system." + echo "*** Make sure it is in your path, or set the PKG_CONFIG" + echo "*** environment variable to the full path to pkg-config." + echo "*** You can download pkg-config from the freedesktop.org" + echo "*** software repository at" + echo "***" + echo "*** http://www.freedesktop.org/software/pkgconfig" + echo "***" + exit 1 + ]) +]) + + + +dnl XDT_CHECK_PACKAGE(varname, package, version, [action-if], [action-if-not]) +dnl +dnl Checks if "package" >= "version" is installed on the +dnl target system, using the pkg-config utility. If the +dnl dependency is met, "varname"_CFLAGS, "varname"_LIBS, +dnl "varname"_VERSION and "varname"_REQUIRED_VERSION +dnl will be set and marked for substition. +dnl +dnl "varname"_REQUIRED_VERSION will be set to the value of +dnl "version". This is mostly useful to automatically +dnl place the correct version information into the RPM +dnl .spec file. +dnl +dnl In addition, if the dependency is met, "action-if" will +dnl be executed if given. +dnl +dnl If the package check fails, "action-if-not" will be +dnl executed. If this parameter isn't specified, a diagnostic +dnl message will be printed and the configure script will +dnl be terminated with exit code 1. +dnl +AC_DEFUN([XDT_CHECK_PACKAGE], +[ + XDT_PROG_PKG_CONFIG() + + AC_MSG_CHECKING([for $2 >= $3]) + if $PKG_CONFIG "--atleast-version=$3" "$2" >/dev/null 2>&1; then + $1_VERSION=`$PKG_CONFIG --modversion "$2"` + AC_MSG_RESULT([$$1_VERSION]) + + AC_MSG_CHECKING([$1_CFLAGS]) + $1_CFLAGS=`$PKG_CONFIG --cflags "$2"` + AC_MSG_RESULT([$$1_CFLAGS]) + + AC_MSG_CHECKING([$1_LIBS]) + $1_LIBS=`$PKG_CONFIG --libs "$2"` + AC_MSG_RESULT([$$1_LIBS]) + + $1_REQUIRED_VERSION=$3 + + AC_SUBST([$1_VERSION]) + AC_SUBST([$1_CFLAGS]) + AC_SUBST([$1_LIBS]) + AC_SUBST([$1_REQUIRED_VERSION]) + + ifelse([$4], , , [$4]) + elif $PKG_CONFIG --exists "$2" >/dev/null 2>&1; then + xdt_cv_version=`$PKG_CONFIG --modversion "$2"` + AC_MSG_RESULT([found, but $xdt_cv_version]) + + ifelse([$5], , + [ + echo "*** The required package $2 was found on your system," + echo "*** but the installed version ($xdt_cv_version) is too old." + echo "*** Please upgrade $2 to atleast version $3, or adjust" + echo "*** the PKG_CONFIG_PATH environment variable if you installed" + echo "*** the new version of the package in a nonstandard prefix so" + echo "*** pkg-config is able to find it." + exit 1 + ], [$5]) + else + AC_MSG_RESULT([not found]) + + ifelse([$5], , + [ + echo "*** The required package $2 was not found on your system." + echo "*** Please install $2 (atleast version $3) or adjust" + echo "*** the PKG_CONFIG_PATH environment variable if you" + echo "*** installed the package in a nonstandard prefix so that" + echo "*** pkg-config is able to find it." + exit 1 + ], [$5]) + fi +]) + + + +dnl XDT_CHECK_OPTIONAL_PACKAGE(varname, package, version, optionname, helpstring, [default]) +dnl +dnl Checks for an optional dependency on "package" >= "version". "default" +dnl can be "yes" or "no" (defaults to "yes" if not specified) and controls +dnl whether configure should check this dependency by default, or only if +dnl the user explicitly enables it using a command line switch. +dnl +dnl This macro automatically adds a commandline switch based on the "optionname" +dnl parameter (--enable-optionname/--disable-optionname), which allows the +dnl user to explicitly control whether this optional dependency should be +dnl enabled or not. The "helpstring" parameter gives a brief(!) description +dnl about this dependency. +dnl +dnl If the user chose to enable this dependency and the required package +dnl was found, this macro defines the variable "varname"_FOUND and sets it +dnl to the string "yes", in addition to the 4 variables set by XDT_CHECK_PACKAGE. +dnl But "varname"_FOUND will not be marked for substition. Furthermore, +dnl a CPP define HAVE_"varname" will be placed in config.h (or added to +dnl the cc command line, depending on your configure.ac) and set to +dnl 1. +dnl +AC_DEFUN([XDT_CHECK_OPTIONAL_PACKAGE], +[ + AC_REQUIRE([XDT_PROG_PKG_CONFIG]) + + AC_ARG_ENABLE([$4], +AC_HELP_STRING([--enable-$4], [Enable checking for $5 (default=m4_default([$6], [yes]))]) +AC_HELP_STRING([--disable-$4], [Disable checking for $5]), + [xdt_cv_$1_check=$enableval], [xdt_cv_$1_check=m4_default([$6], [yes])]) + + if test x"$xdt_cv_$1_check" = x"yes"; then + if $PKG_CONFIG --exists "$2 >= $3" >/dev/null 2>&1; then + XDT_CHECK_PACKAGE([$1], [$2], [$3], + [ + AC_DEFINE([HAVE_$1], [1], [Define if $2 >= $3 present]) + $1_FOUND="yes" + ]) + else + AC_MSG_CHECKING([for optional package $2 >= $3]) + AC_MSG_RESULT([not found]) + fi + else + AC_MSG_CHECKING([for optional package $2]) + AC_MSG_RESULT([disabled]) + fi + + AM_CONDITIONAL([HAVE_$1], [test x"$$1_FOUND" = x"yes"]) +]) + + + +dnl XDT_CHECK_LIBX11() +dnl +dnl Executes various checks for X11. Sets LIBX11_CFLAGS, LIBX11_LDFLAGS +dnl and LIBX11_LIBS (and marks them for substitution). In addition +dnl HAVE_LIBX11 is set to 1 in config.h, if the X window system and +dnl the development files are detected on the target system. +dnl +AC_DEFUN([XDT_CHECK_LIBX11], +[ + AC_REQUIRE([AC_PATH_XTRA]) + + LIBX11_CFLAGS= LIBX11_LDFLAGS= LIBX11_LIBS= + if test x"$no_x" != x"yes"; then + AC_CHECK_LIB([X11], [main], + [ + AC_DEFINE([HAVE_LIBX11], [1], [Define if libX11 is available]) + LIBX11_CFLAGS="$X_CFLAGS" + for option in $X_PRE_LIBS $X_EXTRA_LIBS $X_LIBS; do + case "$option" in + -L*) + path=`echo $option | sed 's/^-L//'` + if test x"$path" != x""; then + LIBX11_LDFLAGS="$LIBX11_LDFLAGS -L$path" + fi + ;; + *) + LIBX11_LIBS="$LIBX11_LIBS $option" + ;; + esac + done + if ! echo $LIBX11_LIBS | grep -- '-lX11' >/dev/null; then + LIBX11_LIBS="$LIBX11_LIBS -lX11" + fi + ], [], [$X_CFLAGS $X_PRE_LIBS $X_EXTRA_LIBS $X_LIBS]) + fi + AC_SUBST([LIBX11_CFLAGS]) + AC_SUBST([LIBX11_LDFLAGS]) + AC_SUBST([LIBX11_LIBS]) +]) + + + +dnl XDT_CHECK_LIBX11_REQUIRE() +dnl +dnl Similar to XDT_CHECK_LIBX11(), but terminates with an error if +dnl the X window system and development files aren't detected on the +dnl target system. +dnl +AC_DEFUN([XDT_CHECK_LIBX11_REQUIRE], +[ + AC_REQUIRE([XDT_CHECK_LIBX11]) + + if test x"$no_x" = x"yes"; then + AC_MSG_ERROR([X Window system libraries and header files are required]) + fi +]) + + + +dnl XDT_CHECK_LIBSM() +dnl +dnl Checks whether the session management library is present on the +dnl target system, and sets LIBSM_CFLAGS, LIBSM_LDFLAGS and LIBSM_LIBS +dnl properly. In addition, HAVE_LIBSM will be set to 1 in config.h +dnl if libSM is detected. +dnl +AC_DEFUN([XDT_CHECK_LIBSM], +[ + AC_REQUIRE([XDT_CHECK_LIBX11]) + + LIBSM_CFLAGS= LIBSM_LDFLAGS= LIBSM_LIBS= + if test x"$no_x" != x"yes"; then + AC_CHECK_LIB([SM], [SmcSaveYourselfDone], + [ + AC_DEFINE([HAVE_LIBSM], [1], [Define if libSM is available]) + LIBSM_CFLAGS="$LIBX11_CFLAGS" + LIBSM_LDFLAGS="$LIBX11_LDFLAGS" + LIBSM_LIBS="$LIBX11_LIBS" + if ! echo $LIBSM_LIBS | grep -- '-lSM' >/dev/null; then + LIBSM_LIBS="$LIBSM_LIBS -lSM -lICE" + fi + ], [], [$LIBX11_CFLAGS $LIBX11_LDFLAGS $LIBX11_LIBS -lICE]) + fi + AC_SUBST([LIBSM_CFLAGS]) + AC_SUBST([LIBSM_LDFLAGS]) + AC_SUBST([LIBSM_LIBS]) +]) + + + +dnl XDT_CHECK_LIBXPM() +dnl +dnl Checks if the Xpm library is present on the target system, and +dnl sets LIBXPM_CFLAGS, LIBXPM_LDFLAGS and LIBXPM_LIBS. In addition, +dnl HAVE_LIBXPM will be set to 1 in config.h if libXpm is detected. +dnl +AC_DEFUN([XDT_CHECK_LIBXPM], +[ + AC_REQUIRE([XDT_CHECK_LIBX11]) + + LIBXPM_CFLAGS= LIBXPM_LDFLAGS= LIBXPM_LIBS= + if test "$no_x" != "yes"; then + AC_CHECK_LIB([Xpm], [main], + [ + AC_DEFINE([HAVE_LIBXPM], [1], [Define if libXpm is available]) + LIBXPM_CFLAGS="$LIBX11_CFLAGS" + LIBXPM_LDFLAGS="$LIBX11_LDFLAGS" + LIBXPM_LIBS="$LIBX11_LIBS" + if ! echo $LIBXPM_LIBS | grep -- '-lXpm' >/dev/null; then + LIBXPM_LIBS="$LIBXPM_LIBS -lXpm" + fi + ], [], [$LIBX11_CFLAGS $LIBX11_LDFLAGS $LIBX11_LIBS -lXpm]) + fi + AC_SUBST([LIBXPM_CFLAGS]) + AC_SUBST([LIBXPM_LDFLAGS]) + AC_SUBST([LIBXPM_LIBS]) +]) + + + +dnl XDT_CHECK_LIBXPM_REQUIRE() +dnl +dnl Similar to XDT_CHECK_LIBXPM(), but fails if the Xpm library isn't +dnl present on the target system. +dnl +AC_DEFUN([XDT_CHECK_LIBXPM_REQUIRE], +[ + AC_REQUIRE([XDT_CHECK_LIBX11_REQUIRE]) + AC_REQUIRE([XDT_CHECK_LIBXPM]) + + if test x"$LIBXPM_LIBS" = x""; then + AC_MSG_ERROR([The Xpm library was not found on your system]) + fi +]) diff --git a/m4/xdt-features.m4 b/m4/xdt-features.m4 new file mode 100644 index 0000000..c4ba116 --- /dev/null +++ b/m4/xdt-features.m4 @@ -0,0 +1,219 @@ +dnl Copyright (c) 2002-2015 +dnl The Xfce development team. All rights reserved. +dnl +dnl Written for Xfce by Benedikt Meurer <benny@xfce.org>. +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License along +dnl with this program; if not, write to the Free Software Foundation, Inc., +dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +dnl +dnl xdt-depends +dnl ----------- +dnl Contains M4 macros to check for software dependencies. +dnl Partly based on prior work of the XDG contributors. +dnl + + + +dnl We need recent a autoconf version +AC_PREREQ([2.60]) + + +dnl XDT_SUPPORTED_FLAGS(VAR, FLAGS) +dnl +dnl For each token in FLAGS, checks to be sure the compiler supports +dnl the flag, and if so, adds each one to VAR. +dnl +AC_DEFUN([XDT_SUPPORTED_FLAGS], +[ + for flag in $2; do + AC_MSG_CHECKING([if $CC supports $flag]) + saved_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $flag" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ ])], [flag_supported=yes], [flag_supported=no]) + CFLAGS="$saved_CFLAGS" + AC_MSG_RESULT([$flag_supported]) + + if test "x$flag_supported" = "xyes"; then + $1="$$1 $flag" + fi + done +]) + + + +dnl XDT_FEATURE_DEBUG(default_level=minimum) +dnl +AC_DEFUN([XDT_FEATURE_DEBUG], +[ + dnl weird indentation to keep output indentation correct + AC_ARG_ENABLE([debug], + AC_HELP_STRING([--enable-debug@<:@=no|minimum|yes|full@:>@], + [Build with debugging support @<:@default=m4_default([$1], [minimum])@:>@]) +AC_HELP_STRING([--disable-debug], [Include no debugging support]), + [enable_debug=$enableval], [enable_debug=m4_default([$1], [minimum])]) + + AC_MSG_CHECKING([whether to build with debugging support]) + if test x"$enable_debug" = x"full" -o x"$enable_debug" = x"yes"; then + AC_DEFINE([DEBUG], [1], [Define for debugging support]) + + xdt_cv_additional_CFLAGS="-DXFCE_DISABLE_DEPRECATED \ + -Wall -Wextra \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter -Wold-style-definition \ + -Wdeclaration-after-statement \ + -Wmissing-declarations \ + -Wmissing-noreturn -Wpointer-arith \ + -Wcast-align -Wformat -Wformat-security -Wformat-y2k \ + -Winit-self -Wmissing-include-dirs -Wundef \ + -Wnested-externs" + CPPFLAGS="$CPPFLAGS" + + if test x`uname` = x"Linux"; then + xdt_cv_additional_CFLAGS="$xdt_cv_additional_CFLAGS -fstack-protector" + fi + + dnl # signal.h inline is crapy on openbsd + if test x`uname` != x"OpenBSD"; then + xdt_cv_additional_CFLAGS="$xdt_cv_additional_CFLAGS -Wredundant-decls" + fi + + if test x"$enable_debug" = x"full"; then + AC_DEFINE([DEBUG_TRACE], [1], [Define for tracing support]) + xdt_cv_additional_CFLAGS="$xdt_cv_additional_CFLAGS -O0 -g -Werror" + CPPFLAGS="$CPPFLAGS -DG_ENABLE_DEBUG" + AC_MSG_RESULT([full]) + else + xdt_cv_additional_CFLAGS="$xdt_cv_additional_CFLAGS -g -Wshadow" + AC_MSG_RESULT([yes]) + fi + + XDT_SUPPORTED_FLAGS([supported_CFLAGS], [$xdt_cv_additional_CFLAGS]) + + ifelse([$CXX], , , [ + dnl FIXME: should test on c++ compiler, but the following line causes + dnl autoconf errors for projects that don't check for a + dnl c++ compiler at all. + dnl AC_LANG_PUSH([C++]) + dnl XDT_SUPPORTED_FLAGS([supported_CXXFLAGS], [$xdt_cv_additional_CFLAGS]) + dnl AC_LANG_POP() + dnl instead, just use supported_CFLAGS... + supported_CXXFLAGS="$supported_CFLAGS" + ]) + + CFLAGS="$CFLAGS $supported_CFLAGS" + CXXFLAGS="$CXXFLAGS $supported_CXXFLAGS" + else + CPPFLAGS="$CPPFLAGS -DNDEBUG" + + if test x"$enable_debug" = x"no"; then + CPPFLAGS="$CPPFLAGS -DG_DISABLE_CAST_CHECKS -DG_DISABLE_ASSERT" + AC_MSG_RESULT([no]) + else + AC_MSG_RESULT([minimum]) + fi + fi +]) + + +dnl XDT_FEATURE_VISIBILITY() +dnl +dnl Checks to see if the compiler supports the 'visibility' attribute +dnl If so, adds -DHAVE_GNUC_VISIBILTY to CPPFLAGS. Also sets the +dnl automake conditional HAVE_GNUC_VISIBILITY. +dnl +AC_DEFUN([XDT_FEATURE_VISIBILITY], +[ + AC_ARG_ENABLE([visibility], + AC_HELP_STRING([--disable-visibility], + [Don't use ELF visibility attributes]), + [enable_visibility=$enableval], [enable_visibility=yes]) + have_gnuc_visibility=no + if test "x$enable_visibility" != "xno"; then + XDT_SUPPORTED_FLAGS([xdt_vis_test_cflags], [-Wall -Werror -Wno-unused-parameter]) + saved_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $xdt_vis_test_cflags" + AC_MSG_CHECKING([whether $CC supports the GNUC visibility attribute]) + AC_COMPILE_IFELSE([AC_LANG_SOURCE( + [ + void test_default (void); + void test_hidden (void); + + void __attribute__ ((visibility("default"))) test_default (void) {} + void __attribute__ ((visibility("hidden"))) test_hidden (void) {} + + int main (int argc, char **argv) { + test_default (); + test_hidden (); + return 0; + } + ])], + [ + have_gnuc_visibility=yes + AC_MSG_RESULT([yes]) + ], + [ + AC_MSG_RESULT([no]) + ]) + CFLAGS="$saved_CFLAGS" + fi + + if test "x$have_gnuc_visibility" = "xyes"; then + CPPFLAGS="$CPPFLAGS -DHAVE_GNUC_VISIBILITY" + xdt_vis_hidden_cflags="" + XDT_SUPPORTED_FLAGS([xdt_vis_hidden_cflags], [-xldscope=hidden]) + if test "x$xdt_vis_hidden_cflags" = "x"; then + XDT_SUPPORTED_FLAGS([xdt_vis_hidden_cflags], [-fvisibility=hidden]) + fi + CFLAGS="$CFLAGS $xdt_vis_hidden_cflags" + fi + + AM_CONDITIONAL([HAVE_GNUC_VISIBILITY], [test "x$have_gnuc_visibility" = "xyes"]) +]) + +dnl XDT_FEATURE_LINKER_OPTS +dnl +dnl Checks for and enables any special linker optimizations. +dnl +AC_DEFUN([XDT_FEATURE_LINKER_OPTS], +[ + AC_ARG_ENABLE([linker-opts], + AC_HELP_STRING([--disable-linker-opts], + [Disable linker optimizations]), + [enable_linker_opts=$enableval], [enable_linker_opts=yes]) + + if test "x$enable_linker_opts" != "xno"; then + if test x`uname` != x"OpenBSD"; then + AC_MSG_CHECKING([whether $LD accepts --as-needed]) + case `$LD --as-needed -v 2>&1 </dev/null` in + *GNU* | *'with BFD'*) + LDFLAGS="$LDFLAGS -Wl,--as-needed" + AC_MSG_RESULT([yes]) + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac + fi + AC_MSG_CHECKING([whether $LD accepts -O1]) + case `$LD -O1 -v 2>&1 </dev/null` in + *GNU* | *'with BFD'*) + LDFLAGS="$LDFLAGS -Wl,-O1" + AC_MSG_RESULT([yes]) + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac + fi +]) diff --git a/pam-ck-connector/Makefile.am b/pam-ck-connector/Makefile.am index 6d4f34a..7778d16 100644 --- a/pam-ck-connector/Makefile.am +++ b/pam-ck-connector/Makefile.am @@ -3,7 +3,6 @@ NULL = if ENABLE_PAM_MODULE AM_CFLAGS = \ - -U_FORTIFY_SOURCE \ $(LIBDBUS_CFLAGS) \ -I$(top_builddir)/libck-connector \ $(NULL) diff --git a/src/Makefile.am b/src/Makefile.am index 93059dc..9e342ef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,11 +9,18 @@ SUBDIRS = \ AM_CFLAGS = \ -I. \ -I$(srcdir) \ - -U_FORTIFY_SOURCE \ - $(CONSOLE_KIT_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GIO_CFLAGS) \ + $(GIO_UNIX_CFLAGS) \ $(POLKIT_CFLAGS) \ + $(LIBDBUS_CFLAGS) \ $(CGMANAGER_CFLAGS) \ - $(DISABLE_DEPRECATED_CFLAGS) \ + $(LIBUDEV_CFLAGS) \ + $(LIBDRM_CFLAGS) \ + $(SELINUX_CFLAGS) \ + $(LIBEVDEV_CFLAGS) \ + $(RBAC_CFLAGS) \ + $(LIBX11_CFLAGS) \ -DPREFIX=\""$(prefix)"\" \ -DBINDIR=\""$(bindir)"\" \ -DLIBDIR=\""$(libdir)"\" \ @@ -24,13 +31,24 @@ AM_CFLAGS = \ -DRUNDIR=\""$(RUNDIR)"\" \ -DCONSOLE_KIT_PID_FILE=\""$(CONSOLE_KIT_PID_FILE)"\" \ -DLOCALEDIR=\"$(localedir)\" \ - $(WARN_CFLAGS) \ - $(DEBUG_CFLAGS) \ - $(DBUS_CFLAGS) \ - $(LIBUDEV_CFLAGS) \ - $(LIBDRM_CFLAGS) \ $(NULL) +CONSOLE_KIT_LIBS = \ + $(CK2_LIBS) \ + $(GLIB_LIBS) \ + $(GIO_LIBS) \ + $(GIO_UNIX_LIBS) \ + $(LIBDBUS_LIBS) \ + $(SELINUX_LIBS) \ + $(LIBEVDEV_LIBS) \ + $(POLKIT_LIBS) \ + $(RBAC_LIBS) \ + $(CGMANAGER_LIBS) \ + $(LIBUDEV_LIBS) \ + $(LIBDRM_LIBS) \ + $(LIBX11_LIBS) + + noinst_LTLIBRARIES = \ libck.la \ libck-event-log.la \ @@ -201,13 +219,8 @@ EXTRA_console_kit_daemon_SOURCES = \ $(NULL) console_kit_daemon_LDADD = \ - $(CONSOLE_KIT_LIBS) \ - $(POLKIT_LIBS) \ - $(RBAC_LIBS) \ - $(CGMANAGER_LIBS) \ - $(LIBUDEV_LIBS) \ - $(LIBDRM_LIBS) \ - libck.la \ + $(CONSOLE_KIT_LIBS) \ + libck.la \ libck-event-log.la \ $(NULL) diff --git a/tools/Makefile.am b/tools/Makefile.am index 9e99617..1fb173f 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -39,9 +39,18 @@ AM_CFLAGS = \ -I$(srcdir) \ -I$(top_srcdir)/src \ -I$(top_srcdir)/libck-connector \ - -U_FORTIFY_SOURCE \ - $(CONSOLE_KIT_CFLAGS) \ - $(XLIB_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GIO_CFLAGS) \ + $(GIO_UNIX_CFLAGS) \ + $(POLKIT_CFLAGS) \ + $(LIBDBUS_CFLAGS) \ + $(CGMANAGER_CFLAGS) \ + $(LIBUDEV_CFLAGS) \ + $(LIBDRM_CFLAGS) \ + $(SELINUX_CFLAGS) \ + $(LIBEVDEV_CFLAGS) \ + $(RBAC_CFLAGS) \ + $(LIBX11_CFLAGS) \ $(DISABLE_DEPRECATED_CFLAGS) \ -DPREFIX=\""$(prefix)"\" \ -DBINDIR=\""$(bindir)"\" \ @@ -52,12 +61,24 @@ AM_CFLAGS = \ -DLOCALSTATEDIR=\""$(localstatedir)"\" \ -DRUNDIR=\""$(RUNDIR)"\" \ -DLOCALEDIR=\"$(localedir)\" \ - $(HISTORY_CFLAGS) \ - $(WARN_CFLAGS) \ - $(DEBUG_CFLAGS) \ - $(DBUS_CFLAGS) \ $(NULL) +CONSOLE_KIT_LIBS = \ + $(CK2_LIBS) \ + $(TOOLS_LIBS) \ + $(GLIB_LIBS) \ + $(GIO_LIBS) \ + $(GIO_UNIX_LIBS) \ + $(LIBDBUS_LIBS) \ + $(SELINUX_LIBS) \ + $(LIBEVDEV_LIBS) \ + $(POLKIT_LIBS) \ + $(RBAC_LIBS) \ + $(CGMANAGER_LIBS) \ + $(LIBUDEV_LIBS) \ + $(LIBDRM_LIBS) \ + $(LIBX11_LIBS) + bin_PROGRAMS = \ ck-launch-session \ ck-list-sessions \ @@ -93,7 +114,7 @@ ck_history_SOURCES = \ $(NULL) ck_history_LDADD = \ - $(HISTORY_LIBS) \ + $(CONSOLE_KIT_LIBS) \ $(Z_LIBS) \ $(top_builddir)/src/libck-event-log.la \ $(NULL) @@ -103,7 +124,7 @@ ck_log_system_start_SOURCES = \ $(NULL) ck_log_system_start_LDADD = \ - $(HISTORY_LIBS) \ + $(CONSOLE_KIT_LIBS) \ $(top_builddir)/src/libck-event-log.la \ $(NULL) @@ -112,7 +133,7 @@ ck_log_system_restart_SOURCES = \ $(NULL) ck_log_system_restart_LDADD = \ - $(HISTORY_LIBS) \ + $(CONSOLE_KIT_LIBS) \ $(top_builddir)/src/libck-event-log.la \ $(NULL) @@ -121,7 +142,7 @@ ck_log_system_stop_SOURCES = \ $(NULL) ck_log_system_stop_LDADD = \ - $(HISTORY_LIBS) \ + $(CONSOLE_KIT_LIBS) \ $(top_builddir)/src/libck-event-log.la \ $(NULL) @@ -137,7 +158,7 @@ ck_collect_session_info_SOURCES = \ $(NULL) ck_collect_session_info_LDADD = \ - $(TOOLS_LIBS) \ + $(CONSOLE_KIT_LIBS) \ $(top_builddir)/src/libck.la \ $(NULL) @@ -146,7 +167,7 @@ ck_get_x11_server_pid_SOURCES = \ $(NULL) ck_get_x11_server_pid_LDADD = \ - $(TOOLS_LIBS) \ + $(CONSOLE_KIT_LIBS) \ $(XLIB_LIBS) \ $(top_builddir)/src/libck.la \ $(NULL) @@ -156,7 +177,7 @@ ck_get_x11_display_device_SOURCES = \ $(NULL) ck_get_x11_display_device_LDADD = \ - $(TOOLS_LIBS) \ + $(CONSOLE_KIT_LIBS) \ $(top_builddir)/src/libck.la \ $(NULL) @@ -165,7 +186,7 @@ ck_remove_directory_SOURCES = \ $(NULL) ck_remove_directory_LDADD = \ - $(TOOLS_LIBS) \ + $(CONSOLE_KIT_LIBS) \ $(top_builddir)/src/libck.la \ $(NULL) |