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