From b57d5c11612dbb896c53d65c01104bae586f6e17 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Mon, 2 Apr 2007 16:16:16 -0400 Subject: autoconf fixes, separate pamlibdir variable, path expansion at make time The attached patch does the following: - Use a separate $pam-module-dir variable for the pam module - Instead of defining a custom $slibdir variable, just use the standard $libdir variable specified by autoconf - Use the standard autoconf $docdir variable (Add AC_PREREQ(2.59) for that). - Drop AS_AC_EXPAND macro and remove AC_DEFINE_UNQUOTED for dir variables. + Build the init script at make time using sed + Use defines in src/Makefile.am to pass the variables to gcc at make time - Consistently use AC_HELP_STRING everywhere - Remove/Replace deprecated macros: + AM_INIT_AUTOMAKE takes the package name and version number from AC_INIT + AM_CONFIG_HEADER -> AC_CONFIG_HEADERS + AC_OUTPUT -> AC_CONFIG_FILES Patch is tested and make distcheck works. --- acinclude.m4 | 44 ----------- configure.ac | 152 +++++++++++++++++++------------------ data/ConsoleKit.in | 10 +-- data/Makefile.am | 13 ++++ libck-connector/Makefile.am | 3 +- libck-connector/ck-connector.pc.in | 2 +- pam-ck-connector/Makefile.am | 3 +- src/Makefile.am | 1 + 8 files changed, 99 insertions(+), 129 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index f23b6ca..67a9bc8 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,47 +1,3 @@ -dnl as-ac-expand.m4 0.2.0 -dnl autostars m4 macro for expanding directories using configure's prefix -dnl thomas@apestaart.org - -dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR) -dnl example -dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir) -dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local - -AC_DEFUN([AS_AC_EXPAND], -[ - EXP_VAR=[$1] - FROM_VAR=[$2] - - dnl first expand prefix and exec_prefix if necessary - prefix_save=$prefix - exec_prefix_save=$exec_prefix - - dnl if no prefix given, then use /usr/local, the default prefix - if test "x$prefix" = "xNONE"; then - prefix="$ac_default_prefix" - fi - dnl if no exec_prefix given, then use prefix - if test "x$exec_prefix" = "xNONE"; then - exec_prefix=$prefix - fi - - full_var="$FROM_VAR" - dnl loop until it doesn't change anymore - while true; do - new_full_var="`eval echo $full_var`" - if test "x$new_full_var" = "x$full_var"; then break; fi - full_var=$new_full_var - done - - dnl clean up - full_var=$new_full_var - AC_SUBST([$1], "$full_var") - - dnl restore prefix and exec_prefix - prefix=$prefix_save - exec_prefix=$exec_prefix_save -]) - dnl EXTRA_COMPILE_WARNINGS dnl Turn on many useful compiler warnings diff --git a/configure.ac b/configure.ac index cc96ee6..92aea86 100644 --- a/configure.ac +++ b/configure.ac @@ -1,14 +1,14 @@ dnl -*- mode: m4 -*- +AC_PREREQ(2.59) AC_INIT([ConsoleKit], [0.2.1], - [mccann@jhu.edu]) + [mccann@jhu.edu], + [ConsoleKit]) -AC_CONFIG_SRCDIR(src/ck-manager.c) +AC_CONFIG_SRCDIR([src/ck-manager.c]) -AM_INIT_AUTOMAKE(ConsoleKit, 0.2.1) - -AM_CONFIG_HEADER(config.h) +AM_INIT_AUTOMAKE AM_MAINTAINER_MODE @@ -105,11 +105,11 @@ dnl - Are we specifying a different dbus root ? dnl --------------------------------------------------------------------------- AC_ARG_WITH(dbus-sys, - [AC_HELP_STRING([--with-dbus-sys=], - [where D-BUS system.d directory is])]) + [AC_HELP_STRING([--with-dbus-sys=], + [where D-BUS system.d directory is])]) AC_ARG_WITH(dbus-services, - [AC_HELP_STRING([--with-dbus-services=], - [where D-BUS services directory is])]) + [AC_HELP_STRING([--with-dbus-services=], + [where D-BUS services directory is])]) if ! test -z "$with_dbus_sys" ; then DBUS_SYS_DIR="$with_dbus_sys" else @@ -117,32 +117,21 @@ else fi AC_SUBST(DBUS_SYS_DIR) -dnl --------------------------------------------------------------------------- -dnl Expand vars -dnl --------------------------------------------------------------------------- - -AS_AC_EXPAND(LOCALSTATEDIR, $localstatedir) -AS_AC_EXPAND(SYSCONFDIR, $sysconfdir) -AS_AC_EXPAND(DATADIR, $datadir) -AS_AC_EXPAND(BINDIR, $bindir) -AS_AC_EXPAND(SBINDIR, $sbindir) -AS_AC_EXPAND(LIBDIR, $libdir) -AS_AC_EXPAND(LIBEXECDIR, $libexecdir) - dnl --------------------------------------------------------------------------- dnl - PID file dnl --------------------------------------------------------------------------- -AC_ARG_WITH(pid-file, [ --with-pid-file= pid file]) +AC_ARG_WITH(pid-file, + [AC_HELP_STRING([--with-pid-file=], + [pid file location])]) if ! test -z "$with_pid_file"; then CONSOLE_KIT_PID_FILE=$with_pid_file else - CONSOLE_KIT_PID_FILE=${LOCALSTATEDIR}/run/ConsoleKit/pid + CONSOLE_KIT_PID_FILE=${localstatedir}/run/ConsoleKit/pid fi AC_SUBST(CONSOLE_KIT_PID_FILE) -AC_DEFINE_UNQUOTED(CONSOLE_KIT_PID_FILE, "$CONSOLE_KIT_PID_FILE", [pid file]) dnl --------------------------------------------------------------------------- dnl Figure out what tools backend to build @@ -172,39 +161,42 @@ have_pam=no AC_CHECK_LIB(pam, pam_getenv, have_pam=yes) AM_CONDITIONAL(HAVE_PAM, test x$have_pam = xyes) if test "x$have_pam" = "xyes"; then - PAM_LIBS="${PAM_LIBS} -lpam" + PAM_LIBS="${PAM_LIBS} -lpam" fi AC_SUBST(HAVE_PAM) AC_SUBST(PAM_LIBS) -AC_CHECK_HEADERS(security/pam_modutil.h security/pam_ext.h) +AC_CHECK_HEADERS([security/pam_modutil.h security/pam_ext.h]) AC_CHECK_LIB(pam, pam_syslog, [AC_DEFINE(HAVE_PAM_SYSLOG, [], [Define to 1 if you have the pam_syslog function])]) # Check if we should build the PAM module msg_pam_module=no -AC_ARG_ENABLE(pam-module, [AC_HELP_STRING([--enable-pam-module], [build PAM module])],, enable_pam_module=no) +AC_ARG_ENABLE(pam-module, + [AC_HELP_STRING([--enable-pam-module], + [build PAM module])], + , enable_pam_module=no) if test "x$enable_pam_module" = "xyes"; then - if test "x$have_pam" = "xno"; then - AC_MSG_ERROR([--enable-pam-module requires PAM but PAM was not found]) - fi - AC_DEFINE(ENABLE_PAM_MODULE, [], [Set if we build PAM module]) - msg_pam_module=yes + if test "x$have_pam" = "xno"; then + AC_MSG_ERROR([--enable-pam-module requires PAM but PAM was not found]) + fi + AC_DEFINE(ENABLE_PAM_MODULE, [], [Set if we build PAM module]) + msg_pam_module=yes fi AM_CONDITIONAL(ENABLE_PAM_MODULE, test "x$enable_pam_module" = "xyes") dnl --------------------------------------------------------------------------- -dnl - Install directory for connector +dnl - Install directory for PAM security module dnl --------------------------------------------------------------------------- -AC_ARG_WITH(slibdir, - [AC_HELP_STRING([--with-slibdir=], - [directory to install system libraries])]) -if ! test -z "$with_slibdir"; then - SLIBDIR="$with_slibdir" +AC_ARG_WITH(pam-module-dir, + [AC_HELP_STRING([--with-pam-module-dir=], + [directory to install PAM security module])]) +if ! test -z "$with_pam_module_dir"; then + PAM_MODULE_DIR="$with_pam_module_dir" else - SLIBDIR="$libdir" + PAM_MODULE_DIR="/lib/security" fi -AC_SUBST(SLIBDIR) +AC_SUBST(PAM_MODULE_DIR) dnl --------------------------------------------------------------------------- dnl - Where should we put documentation ? @@ -224,25 +216,28 @@ dnl --------------------------------------------------------------------------- dnl - DocBook Documentation dnl --------------------------------------------------------------------------- -AC_ARG_ENABLE(docbook-docs, [ --enable-docbook-docs build documentation (requires xmlto)],enable_docbook_docs=$enableval,enable_docbook_docs=no) +AC_ARG_ENABLE(docbook-docs, + [AC_HELP_STRING([--enable-docbook-docs], + [build documentation (requires xmlto)])], + enable_docbook_docs=$enableval,enable_docbook_docs=no) AC_PATH_PROG(XMLTO, xmlto, no) AC_MSG_CHECKING([whether to build DocBook documentation]) if test x$XMLTO = xno ; then - have_docbook=no + have_docbook=no else - have_docbook=yes + have_docbook=yes fi if test x$enable_docbook_docs = xauto ; then - if test x$have_docbook = xno ; then - enable_docbook_docs=no - else - enable_docbook_docs=yes - fi + if test x$have_docbook = xno ; then + enable_docbook_docs=no + else + enable_docbook_docs=yes + fi fi if test x$enable_docbook_docs = xyes; then - if test x$have_docbook = xno; then - AC_MSG_ERROR([Building DocBook docs explicitly required, but DocBook not found]) - fi + if test x$have_docbook = xno; then + AC_MSG_ERROR([Building DocBook docs explicitly required, but DocBook not found]) + fi fi AM_CONDITIONAL(DOCBOOK_DOCS_ENABLED, test x$enable_docbook_docs = xyes) AC_MSG_RESULT(yes) @@ -254,14 +249,15 @@ dnl --------------------------------------------------------------------------- # Turn on the additional warnings last, so -Werror doesn't affect other tests. AC_ARG_ENABLE(more-warnings, - AC_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_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) @@ -294,15 +290,18 @@ fi # # Enable Debug # -AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug=[no/yes]], [turn on debugging])],, enable_debug=yes) +AC_ARG_ENABLE(debug, + [AC_HELP_STRING([--enable-debug], + [turn on debugging])], + , enable_debug=yes) if test "$enable_debug" = "yes"; then - DEBUG_CFLAGS="-DG_ENABLE_DEBUG" + DEBUG_CFLAGS="-DG_ENABLE_DEBUG" else - if test "x$enable_debug" = "xno"; then - DEBUG_CFLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS" - else - DEBUG_CFLAGS="" - fi + if test "x$enable_debug" = "xno"; then + DEBUG_CFLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS" + else + DEBUG_CFLAGS="" + fi fi AC_SUBST(DEBUG_CFLAGS) @@ -317,13 +316,12 @@ AC_SUBST(LDFLAGS) # Files -AC_OUTPUT([ +AC_CONFIG_FILES([ Makefile src/Makefile tools/Makefile tools/linux/Makefile data/Makefile -data/ConsoleKit doc/Makefile doc/ConsoleKit.xml libck-connector/Makefile @@ -331,19 +329,22 @@ libck-connector/ck-connector.pc pam-ck-connector/Makefile ]) +AC_CONFIG_HEADERS([config.h]) + +AC_OUTPUT + echo " ConsoleKit $VERSION ======================== prefix: ${prefix} exec_prefix: ${exec_prefix} - libdir: ${LIBDIR} - bindir: ${BINDIR} - sbindir: ${SBINDIR} - slibdir: ${SLIBDIR} - sysconfdir: ${SYSCONFDIR} - localstatedir: ${LOCALSTATEDIR} - datadir: ${DATADIR} + libdir: ${libdir} + bindir: ${bindir} + sbindir: ${sbindir} + sysconfdir: ${sysconfdir} + localstatedir: ${localstatedir} + datadir: ${datadir} source code location: ${srcdir} compiler: ${CC} cflags: ${CFLAGS} @@ -352,6 +353,7 @@ echo " dbus-1 system.d dir: ${DBUS_SYS_DIR} Build backend: ${CK_BACKEND} + PAM module dir: ${PAM_MODULE_DIR} Build PAM module: ${msg_pam_module} Build docs: ${enable_docbook_docs} " diff --git a/data/ConsoleKit.in b/data/ConsoleKit.in index 3bc6ef0..83360cd 100755 --- a/data/ConsoleKit.in +++ b/data/ConsoleKit.in @@ -10,10 +10,10 @@ # # Sanity checks. -[ -x @SBINDIR@/console-kit-daemon ] || exit 0 +[ -x @sbindir@/console-kit-daemon ] || exit 0 # Source function library. -. @SYSCONFDIR@/rc.d/init.d/functions +. @sysconfdir@/rc.d/init.d/functions # so we can rearrange this easily processname=console-kit-daemon @@ -26,7 +26,7 @@ start() { daemon --check $servicename $processname RETVAL=$? echo - [ $RETVAL -eq 0 ] && touch @LOCALSTATEDIR@/lock/subsys/$servicename + [ $RETVAL -eq 0 ] && touch @localstatedir@/lock/subsys/$servicename } stop() { @@ -36,7 +36,7 @@ stop() { RETVAL=$? echo if [ $RETVAL -eq 0 ]; then - rm -f @LOCALSTATEDIR@/lock/subsys/$servicename + rm -f @localstatedir@/lock/subsys/$servicename rm -f @CONSOLE_KIT_PID_FILE@ fi } @@ -58,7 +58,7 @@ case "$1" in start ;; condrestart) - if [ -f @LOCALSTATEDIR@/lock/subsys/$servicename ]; then + if [ -f @localstatedir@/lock/subsys/$servicename ]; then stop start fi diff --git a/data/Makefile.am b/data/Makefile.am index 9c8f0ab..f9216c4 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -9,10 +9,23 @@ initd_SCRIPTS= \ ConsoleKit \ $(NULL) + +ConsoleKit: ConsoleKit.in Makefile + $(edit) $< >$@ + +edit = sed \ + -e 's|@sbindir[@]|$(sbindir)|g' \ + -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ + -e 's|@localstatedir[@]|$(localstatedir)|g' \ + -e 's|@CONSOLE_KIT_PID_FILE[@]|$(CONSOLE_KIT_PID_FILE)|g' + EXTRA_DIST = \ $(dbusconf_DATA) \ + $(SCRIPT_IN_FILES) \ $(NULL) MAINTAINERCLEANFILES = \ *~ \ Makefile.in + +CLEANFILES = ConsoleKit diff --git a/libck-connector/Makefile.am b/libck-connector/Makefile.am index e6801fd..757c41e 100644 --- a/libck-connector/Makefile.am +++ b/libck-connector/Makefile.am @@ -5,8 +5,7 @@ INCLUDES = \ $(LIBDBUS_CFLAGS) \ $(NULL) -slibdir = $(SLIBDIR) -slib_LTLIBRARIES = \ +lib_LTLIBRARIES = \ libck-connector.la \ $(NULL) diff --git a/libck-connector/ck-connector.pc.in b/libck-connector/ck-connector.pc.in index 152ce3d..67ecce3 100644 --- a/libck-connector/ck-connector.pc.in +++ b/libck-connector/ck-connector.pc.in @@ -1,6 +1,6 @@ prefix=@prefix@ exec_prefix=@prefix@ -libdir=@SLIBDIR@ +libdir=@libdir@ includedir=@prefix@/include Name: ck-connector diff --git a/pam-ck-connector/Makefile.am b/pam-ck-connector/Makefile.am index 35a4eae..eab4864 100644 --- a/pam-ck-connector/Makefile.am +++ b/pam-ck-connector/Makefile.am @@ -7,8 +7,7 @@ INCLUDES = \ -I$(top_builddir)/libck-connector \ $(NULL) -pamlibdir = $(SLIBDIR)/security - +pamlibdir = $(PAM_MODULE_DIR) pamlib_LTLIBRARIES = \ pam_ck_connector.la \ $(NULL) diff --git a/src/Makefile.am b/src/Makefile.am index 5f18cc7..6d128ce 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,6 +17,7 @@ INCLUDES = \ -DLIBEXECDIR=\""$(libexecdir)"\" \ -DDATADIR=\""$(datadir)"\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DCONSOLE_KIT_PID_FILE=\""$(CONSOLE_KIT_PID_FILE)"\" \ $(WARN_CFLAGS) \ $(DEBUG_CFLAGS) \ $(DBUS_CFLAGS) \ -- cgit