* guile.m4: add serial number to m4
[bpt/guile.git] / guile-config / guile.m4
CommitLineData
b6aaeeac
TTN
1## Autoconf macros for working with Guile.
2##
6e7d5622 3## Copyright (C) 1998,2001, 2006 Free Software Foundation, Inc.
b6aaeeac 4##
73be1d9e
MV
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.
9##
10## This library is distributed in the hope that it will be useful,
b6aaeeac 11## but WITHOUT ANY WARRANTY; without even the implied warranty of
73be1d9e
MV
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13## Lesser General Public License for more details.
14##
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
92205699 17## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
b6aaeeac 18
84eebc64
NJ
19# serial 9
20
b6aaeeac
TTN
21## Index
22## -----
23##
24## GUILE_PROGS -- set paths to Guile interpreter, config and tool programs
25## GUILE_FLAGS -- set flags for compiling and linking with Guile
26## GUILE_SITE_DIR -- find path to Guile "site" directory
27## GUILE_CHECK -- evaluate Guile Scheme code and capture the return value
28## GUILE_MODULE_CHECK -- check feature of a Guile Scheme module
29## GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module
30## GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable
31## GUILE_MODULE_EXPORTS -- check if a module exports a variable
32## GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable
33
34## Code
35## ----
36
8c4b7ca3
TTN
37## NOTE: Comments preceding an AC_DEFUN (starting from "Usage:") are massaged
38## into doc/ref/autoconf-macros.texi (see Makefile.am in that directory).
39
b6aaeeac
TTN
40# GUILE_PROGS -- set paths to Guile interpreter, config and tool programs
41#
42# Usage: GUILE_PROGS
43#
8c4b7ca3
TTN
44# This macro looks for programs @code{guile}, @code{guile-config} and
45# @code{guile-tools}, and sets variables @var{GUILE}, @var{GUILE_CONFIG} and
46# @var{GUILE_TOOLS}, to their paths, respectively. If either of the first two
e12ed7aa 47# is not found, signal error.
b6aaeeac 48#
8c4b7ca3 49# The variables are marked for substitution, as by @code{AC_SUBST}.
b6aaeeac
TTN
50#
51AC_DEFUN([GUILE_PROGS],
52 [AC_PATH_PROG(GUILE,guile)
53 if test "$GUILE" = "" ; then
54 AC_MSG_ERROR([guile required but not found])
55 fi
56 AC_SUBST(GUILE)
57 AC_PATH_PROG(GUILE_CONFIG,guile-config)
58 if test "$GUILE_CONFIG" = "" ; then
59 AC_MSG_ERROR([guile-config required but not found])
60 fi
61 AC_SUBST(GUILE_CONFIG)
62 AC_PATH_PROG(GUILE_TOOLS,guile-tools)
63 AC_SUBST(GUILE_TOOLS)
64 ])
65
66# GUILE_FLAGS -- set flags for compiling and linking with Guile
67#
68# Usage: GUILE_FLAGS
69#
8c4b7ca3
TTN
70# This macro runs the @code{guile-config} script, installed with Guile, to
71# find out where Guile's header files and libraries are installed. It sets
72# two variables, @var{GUILE_CFLAGS} and @var{GUILE_LDFLAGS}.
b6aaeeac 73#
8c4b7ca3
TTN
74# @var{GUILE_CFLAGS}: flags to pass to a C or C++ compiler to build code that
75# uses Guile header files. This is almost always just a @code{-I} flag.
b6aaeeac 76#
8c4b7ca3
TTN
77# @var{GUILE_LDFLAGS}: flags to pass to the linker to link a program against
78# Guile. This includes @code{-lguile} for the Guile library itself, any
79# libraries that Guile itself requires (like -lqthreads), and so on. It may
80# also include a @code{-L} flag to tell the compiler where to find the
b6aaeeac
TTN
81# libraries.
82#
8c4b7ca3
TTN
83# The variables are marked for substitution, as by @code{AC_SUBST}.
84#
85AC_DEFUN([GUILE_FLAGS],
86 [AC_REQUIRE([GUILE_PROGS])dnl
87 AC_MSG_CHECKING([libguile compile flags])
88 GUILE_CFLAGS="`$GUILE_CONFIG compile`"
89 AC_MSG_RESULT([$GUILE_CFLAGS])
90 AC_MSG_CHECKING([libguile link flags])
91 GUILE_LDFLAGS="`$GUILE_CONFIG link`"
92 AC_MSG_RESULT([$GUILE_LDFLAGS])
2b9fe19f
JB
93 AC_SUBST(GUILE_CFLAGS)
94 AC_SUBST(GUILE_LDFLAGS)
8c4b7ca3 95 ])
d0001215 96
b6aaeeac
TTN
97# GUILE_SITE_DIR -- find path to Guile "site" directory
98#
99# Usage: GUILE_SITE_DIR
100#
101# This looks for Guile's "site" directory, usually something like
8c4b7ca3 102# PREFIX/share/guile/site, and sets var @var{GUILE_SITE} to the path.
b6aaeeac
TTN
103# Note that the var name is different from the macro name.
104#
8c4b7ca3 105# The variable is marked for substitution, as by @code{AC_SUBST}.
b6aaeeac
TTN
106#
107AC_DEFUN([GUILE_SITE_DIR],
108 [AC_REQUIRE([GUILE_PROGS])dnl
109 AC_MSG_CHECKING(for Guile site directory)
110 GUILE_SITE=`[$GUILE_CONFIG] info pkgdatadir`/site
111 AC_MSG_RESULT($GUILE_SITE)
112 AC_SUBST(GUILE_SITE)
113 ])
114
115# GUILE_CHECK -- evaluate Guile Scheme code and capture the return value
116#
117# Usage: GUILE_CHECK_RETVAL(var,check)
118#
8c4b7ca3
TTN
119# @var{var} is a shell variable name to be set to the return value.
120# @var{check} is a Guile Scheme expression, evaluated with "$GUILE -c", and
b6aaeeac
TTN
121# returning either 0 or non-#f to indicate the check passed.
122# Non-0 number or #f indicates failure.
123# Avoid using the character "#" since that confuses autoconf.
124#
125AC_DEFUN([GUILE_CHECK],
126 [AC_REQUIRE([GUILE_PROGS])
127 $GUILE -c "$2" > /dev/null 2>&1
128 $1=$?
129 ])
130
131# GUILE_MODULE_CHECK -- check feature of a Guile Scheme module
132#
133# Usage: GUILE_MODULE_CHECK(var,module,featuretest,description)
134#
8c4b7ca3
TTN
135# @var{var} is a shell variable name to be set to "yes" or "no".
136# @var{module} is a list of symbols, like: (ice-9 common-list).
137# @var{featuretest} is an expression acceptable to GUILE_CHECK, q.v.
138# @var{description} is a present-tense verb phrase (passed to AC_MSG_CHECKING).
b6aaeeac
TTN
139#
140AC_DEFUN([GUILE_MODULE_CHECK],
141 [AC_MSG_CHECKING([if $2 $4])
142 GUILE_CHECK($1,(use-modules $2) (exit ((lambda () $3))))
143 if test "$$1" = "0" ; then $1=yes ; else $1=no ; fi
144 AC_MSG_RESULT($$1)
d0001215
TTN
145 ])
146
b6aaeeac
TTN
147# GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module
148#
149# Usage: GUILE_MODULE_AVAILABLE(var,module)
150#
8c4b7ca3
TTN
151# @var{var} is a shell variable name to be set to "yes" or "no".
152# @var{module} is a list of symbols, like: (ice-9 common-list).
b6aaeeac
TTN
153#
154AC_DEFUN([GUILE_MODULE_AVAILABLE],
155 [GUILE_MODULE_CHECK($1,$2,0,is available)
d0001215
TTN
156 ])
157
b6aaeeac
TTN
158# GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable
159#
160# Usage: GUILE_MODULE_REQUIRED(symlist)
161#
8c4b7ca3
TTN
162# @var{symlist} is a list of symbols, WITHOUT surrounding parens,
163# like: ice-9 common-list.
b6aaeeac
TTN
164#
165AC_DEFUN([GUILE_MODULE_REQUIRED],
166 [GUILE_MODULE_AVAILABLE(ac_guile_module_required, ($1))
d0001215
TTN
167 if test "$ac_guile_module_required" = "no" ; then
168 AC_MSG_ERROR([required guile module not found: ($1)])
169 fi
170 ])
171
b6aaeeac
TTN
172# GUILE_MODULE_EXPORTS -- check if a module exports a variable
173#
174# Usage: GUILE_MODULE_EXPORTS(var,module,modvar)
175#
8c4b7ca3
TTN
176# @var{var} is a shell variable to be set to "yes" or "no".
177# @var{module} is a list of symbols, like: (ice-9 common-list).
178# @var{modvar} is the Guile Scheme variable to check.
b6aaeeac
TTN
179#
180AC_DEFUN([GUILE_MODULE_EXPORTS],
181 [GUILE_MODULE_CHECK($1,$2,$3,exports `$3')
182 ])
183
184# GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable
185#
186# Usage: GUILE_MODULE_REQUIRED_EXPORT(module,modvar)
187#
8c4b7ca3
TTN
188# @var{module} is a list of symbols, like: (ice-9 common-list).
189# @var{modvar} is the Guile Scheme variable to check.
b6aaeeac
TTN
190#
191AC_DEFUN([GUILE_MODULE_REQUIRED_EXPORT],
192 [GUILE_MODULE_EXPORTS(guile_module_required_export,$1,$2)
193 if test "$guile_module_required_export" = "no" ; then
194 AC_MSG_ERROR([module $1 does not export $2; required])
195 fi
196 ])
197
198## guile.m4 ends here