Previous: Building the source, Up: Preparation


2.5 Autoconf tests

If you work on a project that uses Autoconf (see GNU Autoconf) to help find installed libraries, the suggestions in the previous section are not the entire story. There are a few methods to detect and incorporate the GNU SASL Library into your Autoconf based package. The preferred approach, is to use Libtool in your project, and use the normal Autoconf header file and library tests.

2.5.1 Autoconf test via `pkg-config'

If your audience is a typical GNU/Linux desktop, you can often assume they have the `pkg-config' tool installed, in which you can use its Autoconf M4 macro to find and set up your package for use with Libgsasl. The following illustrate this scenario.

     AC_ARG_ENABLE(gsasl,
     	AC_HELP_STRING([--disable-gsasl], [don't use GNU SASL]),
     	gsasl=$enableval)
     if test "$gsal" != "no" ; then
     	PKG_CHECK_MODULES(GSASL, libgsasl >= 0.2.15,
     			[gsasl=yes],
                             [gsasl=no])
     	if test "$gsasl" != "yes" ; then
     		sal=no
     		AC_MSG_WARN([Cannot find GNU SASL, disabling])
     	else
     		gsasl=yes
     		AC_DEFINE(USE_GSASL, 1, [Define to 1 if you want GNU SASL.])
     	fi
     fi
     AC_MSG_CHECKING([if GNU SASL should be used])
     AC_MSG_RESULT($gsasl)

2.5.2 Standalone Autoconf test using Libtool

If your package uses Libtool(see GNU Libtool), you can use the normal Autoconf tests to find Libgsasl and rely on the Libtool dependency tracking to include the proper dependency libraries (e.g., Libidn). The following illustrate this scenario.

     AC_CHECK_HEADER(gsasl.h,
     	AC_CHECK_LIB(gsasl, gsasl_check_version,
     		[gsasl=yes AC_SUBST(GSASL_LIBS, -lgsasl)],
     		gsasl=no),
     	gsasl=no)
     AC_ARG_ENABLE(gsasl,
     	AC_HELP_STRING([--disable-gsasl], [don't use GNU SASL]),
     	gsasl=$enableval)
     if test "$gsasl" != "no" ; then
     	AC_DEFINE(USE_SASL, 1, [Define to 1 if you want GNU SASL.])
     else
     	AC_MSG_WARN([Cannot find GNU SASL, diabling])
     fi
     AC_MSG_CHECKING([if GNU SASL should be used])
     AC_MSG_RESULT($gsasl)