1
## Autoconf macros for working with Guile.
3
## Copyright (C) 1998,2001, 2006 Free Software Foundation, Inc.
5
## This library is free software; you can redistribute it and/or
6
## modify it under the terms of the GNU Lesser General Public
7
## License as published by the Free Software Foundation; either
8
## version 2.1 of the License, or (at your option) any later version.
10
## This library is distributed in the hope that it will be useful,
11
## but WITHOUT ANY WARRANTY; without even the implied warranty of
12
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
## Lesser General Public License for more details.
15
## You should have received a copy of the GNU Lesser General Public
16
## License along with this library; if not, write to the Free Software
17
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
## GUILE_PROGS -- set paths to Guile interpreter, config and tool programs
23
## GUILE_FLAGS -- set flags for compiling and linking with Guile
24
## GUILE_SITE_DIR -- find path to Guile "site" directory
25
## GUILE_CHECK -- evaluate Guile Scheme code and capture the return value
26
## GUILE_MODULE_CHECK -- check feature of a Guile Scheme module
27
## GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module
28
## GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable
29
## GUILE_MODULE_EXPORTS -- check if a module exports a variable
30
## GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable
35
## NOTE: Comments preceding an AC_DEFUN (starting from "Usage:") are massaged
36
## into doc/ref/autoconf-macros.texi (see Makefile.am in that directory).
38
# GUILE_PROGS -- set paths to Guile interpreter, config and tool programs
42
# This macro looks for programs @code{guile}, @code{guile-config} and
43
# @code{guile-tools}, and sets variables @var{GUILE}, @var{GUILE_CONFIG} and
44
# @var{GUILE_TOOLS}, to their paths, respectively. If either of the first two
45
# is not found, signal error.
47
# The variables are marked for substitution, as by @code{AC_SUBST}.
49
AC_DEFUN([GUILE_PROGS],
50
[AC_PATH_PROG(GUILE,guile)
51
if test "$GUILE" = "" ; then
52
AC_MSG_ERROR([guile required but not found])
55
AC_PATH_PROG(GUILE_CONFIG,guile-config)
56
if test "$GUILE_CONFIG" = "" ; then
57
AC_MSG_ERROR([guile-config required but not found])
59
AC_SUBST(GUILE_CONFIG)
60
AC_PATH_PROG(GUILE_TOOLS,guile-tools)
64
# GUILE_FLAGS -- set flags for compiling and linking with Guile
68
# This macro runs the @code{guile-config} script, installed with Guile, to
69
# find out where Guile's header files and libraries are installed. It sets
70
# two variables, @var{GUILE_CFLAGS} and @var{GUILE_LDFLAGS}.
72
# @var{GUILE_CFLAGS}: flags to pass to a C or C++ compiler to build code that
73
# uses Guile header files. This is almost always just a @code{-I} flag.
75
# @var{GUILE_LDFLAGS}: flags to pass to the linker to link a program against
76
# Guile. This includes @code{-lguile} for the Guile library itself, any
77
# libraries that Guile itself requires (like -lqthreads), and so on. It may
78
# also include a @code{-L} flag to tell the compiler where to find the
81
# The variables are marked for substitution, as by @code{AC_SUBST}.
83
AC_DEFUN([GUILE_FLAGS],
84
[AC_REQUIRE([GUILE_PROGS])dnl
85
AC_MSG_CHECKING([libguile compile flags])
86
GUILE_CFLAGS="`$GUILE_CONFIG compile`"
87
AC_MSG_RESULT([$GUILE_CFLAGS])
88
AC_MSG_CHECKING([libguile link flags])
89
GUILE_LDFLAGS="`$GUILE_CONFIG link`"
90
AC_MSG_RESULT([$GUILE_LDFLAGS])
91
AC_SUBST(GUILE_CFLAGS)
92
AC_SUBST(GUILE_LDFLAGS)
95
# GUILE_SITE_DIR -- find path to Guile "site" directory
97
# Usage: GUILE_SITE_DIR
99
# This looks for Guile's "site" directory, usually something like
100
# PREFIX/share/guile/site, and sets var @var{GUILE_SITE} to the path.
101
# Note that the var name is different from the macro name.
103
# The variable is marked for substitution, as by @code{AC_SUBST}.
105
AC_DEFUN([GUILE_SITE_DIR],
106
[AC_REQUIRE([GUILE_PROGS])dnl
107
AC_MSG_CHECKING(for Guile site directory)
108
GUILE_SITE=`[$GUILE_CONFIG] info pkgdatadir`/site
109
AC_MSG_RESULT($GUILE_SITE)
113
# GUILE_CHECK -- evaluate Guile Scheme code and capture the return value
115
# Usage: GUILE_CHECK_RETVAL(var,check)
117
# @var{var} is a shell variable name to be set to the return value.
118
# @var{check} is a Guile Scheme expression, evaluated with "$GUILE -c", and
119
# returning either 0 or non-#f to indicate the check passed.
120
# Non-0 number or #f indicates failure.
121
# Avoid using the character "#" since that confuses autoconf.
123
AC_DEFUN([GUILE_CHECK],
124
[AC_REQUIRE([GUILE_PROGS])
125
$GUILE -c "$2" > /dev/null 2>&1
129
# GUILE_MODULE_CHECK -- check feature of a Guile Scheme module
131
# Usage: GUILE_MODULE_CHECK(var,module,featuretest,description)
133
# @var{var} is a shell variable name to be set to "yes" or "no".
134
# @var{module} is a list of symbols, like: (ice-9 common-list).
135
# @var{featuretest} is an expression acceptable to GUILE_CHECK, q.v.
136
# @var{description} is a present-tense verb phrase (passed to AC_MSG_CHECKING).
138
AC_DEFUN([GUILE_MODULE_CHECK],
139
[AC_MSG_CHECKING([if $2 $4])
140
GUILE_CHECK($1,(use-modules $2) (exit ((lambda () $3))))
141
if test "$$1" = "0" ; then $1=yes ; else $1=no ; fi
145
# GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module
147
# Usage: GUILE_MODULE_AVAILABLE(var,module)
149
# @var{var} is a shell variable name to be set to "yes" or "no".
150
# @var{module} is a list of symbols, like: (ice-9 common-list).
152
AC_DEFUN([GUILE_MODULE_AVAILABLE],
153
[GUILE_MODULE_CHECK($1,$2,0,is available)
156
# GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable
158
# Usage: GUILE_MODULE_REQUIRED(symlist)
160
# @var{symlist} is a list of symbols, WITHOUT surrounding parens,
161
# like: ice-9 common-list.
163
AC_DEFUN([GUILE_MODULE_REQUIRED],
164
[GUILE_MODULE_AVAILABLE(ac_guile_module_required, ($1))
165
if test "$ac_guile_module_required" = "no" ; then
166
AC_MSG_ERROR([required guile module not found: ($1)])
170
# GUILE_MODULE_EXPORTS -- check if a module exports a variable
172
# Usage: GUILE_MODULE_EXPORTS(var,module,modvar)
174
# @var{var} is a shell variable to be set to "yes" or "no".
175
# @var{module} is a list of symbols, like: (ice-9 common-list).
176
# @var{modvar} is the Guile Scheme variable to check.
178
AC_DEFUN([GUILE_MODULE_EXPORTS],
179
[GUILE_MODULE_CHECK($1,$2,$3,exports `$3')
182
# GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable
184
# Usage: GUILE_MODULE_REQUIRED_EXPORT(module,modvar)
186
# @var{module} is a list of symbols, like: (ice-9 common-list).
187
# @var{modvar} is the Guile Scheme variable to check.
189
AC_DEFUN([GUILE_MODULE_REQUIRED_EXPORT],
190
[GUILE_MODULE_EXPORTS(guile_module_required_export,$1,$2)
191
if test "$guile_module_required_export" = "no" ; then
192
AC_MSG_ERROR([module $1 does not export $2; required])
196
## guile.m4 ends here