Autoconf Proposal
From Kolab Wiki
Contents |
What is this?
This is a proposal to move Kolab away from the dist_conf/ directory, and unleash the full power of autoconf.
There's a couple of downsides to dist_conf/:
- The files in dist_conf/ are static,
- The files in dist_conf/ are per distribution, but not per distribution version, which makes them volatile,
- The files in dist_conf/ contain a lot of duplication,
- The files in dist_conf/ are nothing but lists of settings
Example with dist_conf/
Suppose one wants to package Kolab for Fedora or one of its derivative distributions, such as Red Hat Enterprise Linux or CentOS. Fedora (and its derivatives) ship more then one package capable of performing the task of an LDAP server:
- OpenLDAP
- 389/Red Hat/CentOS Directory Services
Many other people run, however:
- Active Directory
- Novell eDirectory
For Kolab to be distributed in a meaningful way, the following files would be required in dist_conf/:
- dist_conf/fedora-openldap
- dist_conf/fedora-389
- dist_conf/fedora-ad
- dist_conf/fedora-edirectory
This can vary on the number of distributions, the number of distribution versions with changes, and the number of LDAP server capable services.
With Autoconf
Various cases
(Semi-)Autodetect
$ autoreconf -v $ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for ldaprc: using /etc/rc.d/init.d/dirsrv configure: creating ./config.status config.status: creating Makefile $ grep LDAPRC Makefile LDAPRC = /etc/rc.d/init.d/dirsrv
Make can now use @LDAPRC@ in any .in file to indicate what is the exact initrc script for the distribution, automatically detected.
Failure to Detect
Should Autoconf be unable to detect which initrc script is to be used, then the following could be the result of ./configure:
$ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes configure: WARNING: Could not automatically detect the LDAP initrc script on this system configure: creating ./config.status config.status: creating Makefile
Flexible
Should there be an initrc script, regardless of whether Autoconf itself can detect it, then the --with-ldaprc configure option is available (at the user's discretion):
$ ./configure -with-ldaprc=/etc/init.d/saslauthd checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for ldaprc: using /etc/init.d/saslauthd configure: creating ./config.status config.status: creating Makefile
While this is all nice and dandy, there's systems out there that could perfectly well be a groupware server, but do not have a local LDAP server.
Without Local LDAP Server
$ ./configure --without-ldaprc checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes not including any ldaprc configure: creating ./config.status config.status: creating Makefile
Other Settings to Include in Autoconf
The same goes for:
- Amavis
- Webserver (through apxs or apxs2 in the case of Apache's httpd)
- The kolab user, group, uid, gid, ...
- The location of php
- The location of tar
- Postfix
- Apache/postfix/cyrus users, groups and locations
- The documentroot for various stuff
- SASL(2)
- ...
Example configure.ac Snippet
(...)
# This option defines which type of ldap rc script is used
# In order, it checks for a number of possibilities or lets
# the packager define the preferred one.
#
# Use:
#
# ./configure --with-ldaprc
AC_ARG_WITH([ldaprc],
[AC_HELP_STRING([--with-ldaprc],
[support fancy SysVInit ldaprc @<:@default=check@:>@])],
[],
[with_ldaprc=check])
LDAPRC=
AS_IF([test "x$with_ldaprc" = "xcheck" -o "$with_ldaprc" == "yes"],
[
# First in the list of preferred LDAP servers is OpenLDAP
if test -f "/etc/rc.d/init.d/slapd"; then
AC_SUBST([LDAPRC], [/etc/rc.d/init.d/slapd])
AC_MSG_RESULT(checking for ldaprc: using /etc/rc.d/init.d/slapd)
AM_CONDITIONAL([HAVE_LDAP], true)
# Then, check for 389/RH/CentOS
elif test -f "/etc/rc.d/init.d/dirsrv"; then
AC_SUBST([LDAPRC], [/etc/rc.d/init.d/dirsrv])
AC_MSG_RESULT(checking for ldaprc: using /etc/rc.d/init.d/dirsrv)
AM_CONDITIONAL([HAVE_LDAP], true)
# This is SuSE
elif test -f "/etc/rc.d/init.d/ldap"; then
AC_SUBST([LDAPRC], [/etc/rc.d/init.d/ldap])
AC_MSG_RESULT(checking for ldaprc: using /etc/rc.d/init.d/ldap)
AM_CONDITIONAL([HAVE_LDAP], true)
else
AC_MSG_WARN(Could not automatically detect the LDAP initrc script on this system)
AM_CONDITIONAL([HAVE_LDAP], false)
fi
],[
if test "x$with_ldaprc" != "xno"; then
if test -f "$with_ldaprc"; then
AC_SUBST([LDAPRC], [$with_ldaprc])
AC_MSG_RESULT(checking for ldaprc: using $with_ldaprc)
AM_CONDITIONAL([HAVE_LDAP], true)
else
AC_MSG_FAILURE(No such file for --with-ldaprc: $with_ldaprc, 1)
AM_CONDITIONAL([HAVE_LDAP], false)
fi
else
AM_CONDITIONAL([HAVE_LDAP], false)
AC_MSG_RESULT(not including any ldaprc)
fi
])
(...)
The HAVE_LDAP can be used as a conditional to perform (or not perform) certain actions in the rest of the Kolab packages.
