5.8.2 Autoconf Macros

As mentioned earlier in this chapter, Guile supports parallel
installation, and uses pkg-config to let the user choose which
version of Guile they are interested in. pkg-config has its own
set of Autoconf macros that are probably installed on most every
development system. The most useful of these macros is
PKG_CHECK_MODULES.

PKG_CHECK_MODULES([GUILE], [guile-2.0])

This example looks for Guile and sets the GUILE_CFLAGS and
GUILE_LIBS variables accordingly, or prints an error and exits if
Guile was not found.

Guile comes with additional Autoconf macros providing more information,
installed as prefix/share/aclocal/guile.m4. Their names
all begin with GUILE_.

Autoconf Macro: GUILE_PKG[VERSIONS]

This macro runs the pkg-config tool to find development files
for an available version of Guile.

By default, this macro will search for the latest stable version of
Guile (e.g. 2.0), falling back to the previous stable version
(e.g. 1.8) if it is available. If no guile-VERSION.pc file is
found, an error is signalled. The found version is stored in
GUILE_EFFECTIVE_VERSION.

If GUILE_PROGS was already invoked, this macro ensures that the
development files have the same effective version as the Guile
program.

GUILE_EFFECTIVE_VERSION is marked for substitution, as by
AC_SUBST.

Autoconf Macro: GUILE_FLAGS

This macro runs the pkg-config tool to find out how to compile
and link programs against Guile. It sets four variables:
GUILE_CFLAGS, GUILE_LDFLAGS, GUILE_LIBS, and
GUILE_LTLIBS.

GUILE_CFLAGS: flags to pass to a C or C++ compiler to build code that
uses Guile header files. This is almost always just one or more -I
flags.

GUILE_LDFLAGS: flags to pass to the compiler to link a program
against Guile. This includes -lguile-VERSION for the
Guile library itself, and may also include one or more -L flag
to tell the compiler where to find the libraries. But it does not
include flags that influence the program’s runtime search path for
libraries, and will therefore lead to a program that fails to start,
unless all necessary libraries are installed in a standard location
such as /usr/lib.

GUILE_LIBS and GUILE_LTLIBS: flags to pass to the compiler or to
libtool, respectively, to link a program against Guile. It includes flags
that augment the program’s runtime search path for libraries, so that shared
libraries will be found at the location where they were during linking, even
in non-standard locations. GUILE_LIBS is to be used when linking the
program directly with the compiler, whereas GUILE_LTLIBS is to be used
when linking the program is done through libtool.

The variables are marked for substitution, as by AC_SUBST.

Autoconf Macro: GUILE_SITE_DIR

This looks for Guile’s "site" directory, usually something like
PREFIX/share/guile/site, and sets var GUILE_SITE to the path.
Note that the var name is different from the macro name.

The variable is marked for substitution, as by AC_SUBST.

Autoconf Macro: GUILE_PROGS[VERSION]

This macro looks for programs guile and guild, setting
variables GUILE and GUILD to their paths, respectively.
If guile is not found, signal an error.

By default, this macro will search for the latest stable version of
Guile (e.g. 2.0). x.y or x.y.z versions can be specified. If an older
version is found, the macro will signal an error.

The effective version of the found guile is set to
GUILE_EFFECTIVE_VERSION. This macro ensures that the effective
version is compatible with the result of a previous invocation of
GUILE_FLAGS, if any.

As a legacy interface, it also looks for guile-config and
guile-tools, setting GUILE_CONFIG and GUILE_TOOLS.

The variables are marked for substitution, as by AC_SUBST.

Autoconf Macro: GUILE_CHECK_RETVALvar check

var is a shell variable name to be set to the return value.
check is a Guile Scheme expression, evaluated with "$GUILE -c", and
returning either 0 or non-#f to indicate the check passed.
Non-0 number or #f indicates failure.
Avoid using the character "#" since that confuses autoconf.

Autoconf Macro: GUILE_MODULE_CHECKvar module featuretest description

var is a shell variable name to be set to "yes" or "no".
module is a list of symbols, like: (ice-9 common-list).
featuretest is an expression acceptable to GUILE_CHECK, q.v.
description is a present-tense verb phrase (passed to AC_MSG_CHECKING).

Autoconf Macro: GUILE_MODULE_AVAILABLEvar module

var is a shell variable name to be set to "yes" or "no".
module is a list of symbols, like: (ice-9 common-list).

Autoconf Macro: GUILE_MODULE_REQUIREDsymlist

symlist is a list of symbols, WITHOUT surrounding parens,
like: ice-9 common-list.

Autoconf Macro: GUILE_MODULE_EXPORTSvar module modvar

var is a shell variable to be set to "yes" or "no".
module is a list of symbols, like: (ice-9 common-list).
modvar is the Guile Scheme variable to check.

Autoconf Macro: GUILE_MODULE_REQUIRED_EXPORTmodule modvar

module is a list of symbols, like: (ice-9 common-list).
modvar is the Guile Scheme variable to check.