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