| 1 | # |
| 2 | # Copyright (c) 1998 Etienne Bernard |
| 3 | # Copyright (c) 2002 Clinton Ebadi |
| 4 | # |
| 5 | |
| 6 | # Check if we have a decent C++ compiler |
| 7 | # that supports Standard Template Library (STL) |
| 8 | AC_DEFUN(AC_CPP_STL, |
| 9 | [ |
| 10 | AC_MSG_CHECKING([for STL support]) |
| 11 | |
| 12 | AC_CACHE_VAL(ac_cv_cpp_stl, |
| 13 | [ |
| 14 | AC_LANG_CPLUSPLUS |
| 15 | cat > conftest.$ac_ext <<EOF |
| 16 | #include <list> |
| 17 | int main() { |
| 18 | std::list<int> l; |
| 19 | return 0; |
| 20 | }; |
| 21 | EOF |
| 22 | |
| 23 | |
| 24 | if AC_TRY_EVAL(ac_link) && test -s conftest; then |
| 25 | ac_cv_cpp_stl="have_stl=yes" |
| 26 | else |
| 27 | ac_cv_cpp_stl="have_stl=no" |
| 28 | fi |
| 29 | rm -f conftest* |
| 30 | ])dnl |
| 31 | eval "$ac_cv_cpp_stl" |
| 32 | |
| 33 | AC_MSG_RESULT([$have_stl]) |
| 34 | |
| 35 | if test "$have_stl" != "yes"; then |
| 36 | AC_MSG_ERROR([Sorry, you need STL support with your compiler]) |
| 37 | fi |
| 38 | ]) |
| 39 | |
| 40 | |
| 41 | # Check is compiler has ios_base |
| 42 | AC_DEFUN(AC_CPP_STL_IOSBASE, |
| 43 | [ |
| 44 | AC_MSG_CHECKING([for std::ios_base in iostreams]) |
| 45 | |
| 46 | AC_CACHE_VAL(ac_cv_cpp_iosbase, |
| 47 | [ |
| 48 | AC_LANG_CPLUSPLUS |
| 49 | cat > conftest.$ac_ext <<EOF |
| 50 | #include <iostream> |
| 51 | #include <fstream> |
| 52 | int main() { |
| 53 | std::ifstream file ("README", std::ios_base::in); |
| 54 | return 0; |
| 55 | }; |
| 56 | EOF |
| 57 | |
| 58 | if AC_TRY_EVAL(ac_link) && test -s conftest; then |
| 59 | ac_cv_cpp_iosbase="have_iosbase=yes" |
| 60 | else |
| 61 | ac_cv_cpp_iosbase="have_iosbase=no" |
| 62 | fi |
| 63 | rm -f conftest* |
| 64 | ])dnl |
| 65 | eval "$ac_cv_cpp_iosbase" |
| 66 | |
| 67 | AC_MSG_RESULT([$have_iosbase]) |
| 68 | |
| 69 | if test "$have_iosbase" = "yes"; then |
| 70 | HAVE_IOSBASE="-DHAVE_IOSBASE" |
| 71 | AC_DEFINE(HAVE_IOSBASE,1, [std::ios_base]) |
| 72 | else |
| 73 | AC_DEFINE(HAVE_IOSBASE,0) |
| 74 | fi |
| 75 | ]) |
| 76 | |
| 77 | # Check if STL elements support the clear() method |
| 78 | AC_DEFUN(AC_CPP_STL_CLEAR, |
| 79 | [ |
| 80 | AC_MSG_CHECKING([for clear() method in STL objects]) |
| 81 | |
| 82 | AC_CACHE_VAL(ac_cv_cpp_stl_clear, |
| 83 | [ |
| 84 | AC_LANG_CPLUSPLUS |
| 85 | cat > conftest.$ac_ext <<EOF |
| 86 | #include <map> |
| 87 | int main() { |
| 88 | std::map<int, int, std::less<int> > m; |
| 89 | m.clear(); |
| 90 | return 0; |
| 91 | }; |
| 92 | EOF |
| 93 | |
| 94 | if AC_TRY_EVAL(ac_link) && test -s conftest; then |
| 95 | ac_cv_cpp_stl_clear="have_stl_clear=yes" |
| 96 | else |
| 97 | ac_cv_cpp_stl_clear="have_stl_clear=no" |
| 98 | fi |
| 99 | rm -f conftest* |
| 100 | ])dnl |
| 101 | eval "$ac_cv_cpp_stl_clear" |
| 102 | |
| 103 | AC_MSG_RESULT([$have_stl_clear]) |
| 104 | |
| 105 | if test "$have_stl_clear" = "yes"; then |
| 106 | HAVE_STL_CLEAR="-DHAVE_STL_CLEAR" |
| 107 | AC_DEFINE(HAVE_STL_CLEAR,1, [STL Objects have a clear method]) |
| 108 | fi |
| 109 | ]) |
| 110 | ## Autoconf macros for working with Guile. |
| 111 | ## |
| 112 | ## Copyright (C) 1998,2001 Free Software Foundation, Inc. |
| 113 | ## |
| 114 | ## This program is free software; you can redistribute it and/or modify |
| 115 | ## it under the terms of the GNU General Public License as published by |
| 116 | ## the Free Software Foundation; either version 2, or (at your option) |
| 117 | ## any later version. |
| 118 | ## |
| 119 | ## This program is distributed in the hope that it will be useful, |
| 120 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 121 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 122 | ## GNU General Public License for more details. |
| 123 | ## |
| 124 | ## You should have received a copy of the GNU General Public License |
| 125 | ## along with this software; see the file COPYING. If not, write to |
| 126 | ## the Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
| 127 | ## Boston, MA 02111-1307 USA |
| 128 | ## |
| 129 | ## As a special exception, the Free Software Foundation gives permission |
| 130 | ## for additional uses of the text contained in its release of GUILE. |
| 131 | ## |
| 132 | ## The exception is that, if you link the GUILE library with other files |
| 133 | ## to produce an executable, this does not by itself cause the |
| 134 | ## resulting executable to be covered by the GNU General Public License. |
| 135 | ## Your use of that executable is in no way restricted on account of |
| 136 | ## linking the GUILE library code into it. |
| 137 | ## |
| 138 | ## This exception does not however invalidate any other reasons why |
| 139 | ## the executable file might be covered by the GNU General Public License. |
| 140 | ## |
| 141 | ## This exception applies only to the code released by the |
| 142 | ## Free Software Foundation under the name GUILE. If you copy |
| 143 | ## code from other Free Software Foundation releases into a copy of |
| 144 | ## GUILE, as the General Public License permits, the exception does |
| 145 | ## not apply to the code that you add in this way. To avoid misleading |
| 146 | ## anyone as to the status of such modified files, you must delete |
| 147 | ## this exception notice from them. |
| 148 | ## |
| 149 | ## If you write modifications of your own for GUILE, it is your choice |
| 150 | ## whether to permit this exception to apply to your modifications. |
| 151 | ## If you do not wish that, delete this exception notice. |
| 152 | |
| 153 | ## Index |
| 154 | ## ----- |
| 155 | ## |
| 156 | ## GUILE_PROGS -- set paths to Guile interpreter, config and tool programs |
| 157 | ## GUILE_FLAGS -- set flags for compiling and linking with Guile |
| 158 | ## GUILE_SITE_DIR -- find path to Guile "site" directory |
| 159 | ## GUILE_CHECK -- evaluate Guile Scheme code and capture the return value |
| 160 | ## GUILE_MODULE_CHECK -- check feature of a Guile Scheme module |
| 161 | ## GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module |
| 162 | ## GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable |
| 163 | ## GUILE_MODULE_EXPORTS -- check if a module exports a variable |
| 164 | ## GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable |
| 165 | |
| 166 | ## Code |
| 167 | ## ---- |
| 168 | |
| 169 | ## NOTE: Comments preceding an AC_DEFUN (starting from "Usage:") are massaged |
| 170 | ## into doc/ref/autoconf-macros.texi (see Makefile.am in that directory). |
| 171 | |
| 172 | # GUILE_PROGS -- set paths to Guile interpreter, config and tool programs |
| 173 | # |
| 174 | # Usage: GUILE_PROGS |
| 175 | # |
| 176 | # This macro looks for programs @code{guile}, @code{guile-config} and |
| 177 | # @code{guile-tools}, and sets variables @var{GUILE}, @var{GUILE_CONFIG} and |
| 178 | # @var{GUILE_TOOLS}, to their paths, respectively. If either of the first two |
| 179 | # is not found, signal error. |
| 180 | # |
| 181 | # The variables are marked for substitution, as by @code{AC_SUBST}. |
| 182 | # |
| 183 | AC_DEFUN([GUILE_PROGS], |
| 184 | [AC_PATH_PROG(GUILE,guile) |
| 185 | if test "$GUILE" = "" ; then |
| 186 | AC_MSG_ERROR([guile required but not found]) |
| 187 | fi |
| 188 | AC_SUBST(GUILE) |
| 189 | AC_PATH_PROG(GUILE_CONFIG,guile-config) |
| 190 | if test "$GUILE_CONFIG" = "" ; then |
| 191 | AC_MSG_ERROR([guile-config required but not found]) |
| 192 | fi |
| 193 | AC_SUBST(GUILE_CONFIG) |
| 194 | AC_PATH_PROG(GUILE_TOOLS,guile-tools) |
| 195 | AC_SUBST(GUILE_TOOLS) |
| 196 | ]) |
| 197 | |
| 198 | # GUILE_FLAGS -- set flags for compiling and linking with Guile |
| 199 | # |
| 200 | # Usage: GUILE_FLAGS |
| 201 | # |
| 202 | # This macro runs the @code{guile-config} script, installed with Guile, to |
| 203 | # find out where Guile's header files and libraries are installed. It sets |
| 204 | # two variables, @var{GUILE_CFLAGS} and @var{GUILE_LDFLAGS}. |
| 205 | # |
| 206 | # @var{GUILE_CFLAGS}: flags to pass to a C or C++ compiler to build code that |
| 207 | # uses Guile header files. This is almost always just a @code{-I} flag. |
| 208 | # |
| 209 | # @var{GUILE_LDFLAGS}: flags to pass to the linker to link a program against |
| 210 | # Guile. This includes @code{-lguile} for the Guile library itself, any |
| 211 | # libraries that Guile itself requires (like -lqthreads), and so on. It may |
| 212 | # also include a @code{-L} flag to tell the compiler where to find the |
| 213 | # libraries. |
| 214 | # |
| 215 | # The variables are marked for substitution, as by @code{AC_SUBST}. |
| 216 | # |
| 217 | AC_DEFUN([GUILE_FLAGS], |
| 218 | [AC_REQUIRE([GUILE_PROGS])dnl |
| 219 | AC_MSG_CHECKING([libguile compile flags]) |
| 220 | GUILE_CFLAGS="`$GUILE_CONFIG compile`" |
| 221 | AC_MSG_RESULT([$GUILE_CFLAGS]) |
| 222 | AC_MSG_CHECKING([libguile link flags]) |
| 223 | GUILE_LDFLAGS="`$GUILE_CONFIG link`" |
| 224 | AC_MSG_RESULT([$GUILE_LDFLAGS]) |
| 225 | AC_SUBST(GUILE_CFLAGS) |
| 226 | AC_SUBST(GUILE_LDFLAGS) |
| 227 | ]) |
| 228 | |
| 229 | # GUILE_SITE_DIR -- find path to Guile "site" directory |
| 230 | # |
| 231 | # Usage: GUILE_SITE_DIR |
| 232 | # |
| 233 | # This looks for Guile's "site" directory, usually something like |
| 234 | # PREFIX/share/guile/site, and sets var @var{GUILE_SITE} to the path. |
| 235 | # Note that the var name is different from the macro name. |
| 236 | # |
| 237 | # The variable is marked for substitution, as by @code{AC_SUBST}. |
| 238 | # |
| 239 | AC_DEFUN([GUILE_SITE_DIR], |
| 240 | [AC_REQUIRE([GUILE_PROGS])dnl |
| 241 | AC_MSG_CHECKING(for Guile site directory) |
| 242 | GUILE_SITE=`[$GUILE_CONFIG] info pkgdatadir`/site |
| 243 | AC_MSG_RESULT($GUILE_SITE) |
| 244 | AC_SUBST(GUILE_SITE) |
| 245 | ]) |
| 246 | |
| 247 | # GUILE_CHECK -- evaluate Guile Scheme code and capture the return value |
| 248 | # |
| 249 | # Usage: GUILE_CHECK_RETVAL(var,check) |
| 250 | # |
| 251 | # @var{var} is a shell variable name to be set to the return value. |
| 252 | # @var{check} is a Guile Scheme expression, evaluated with "$GUILE -c", and |
| 253 | # returning either 0 or non-#f to indicate the check passed. |
| 254 | # Non-0 number or #f indicates failure. |
| 255 | # Avoid using the character "#" since that confuses autoconf. |
| 256 | # |
| 257 | AC_DEFUN([GUILE_CHECK], |
| 258 | [AC_REQUIRE([GUILE_PROGS]) |
| 259 | $GUILE -c "$2" > /dev/null 2>&1 |
| 260 | $1=$? |
| 261 | ]) |
| 262 | |
| 263 | # GUILE_MODULE_CHECK -- check feature of a Guile Scheme module |
| 264 | # |
| 265 | # Usage: GUILE_MODULE_CHECK(var,module,featuretest,description) |
| 266 | # |
| 267 | # @var{var} is a shell variable name to be set to "yes" or "no". |
| 268 | # @var{module} is a list of symbols, like: (ice-9 common-list). |
| 269 | # @var{featuretest} is an expression acceptable to GUILE_CHECK, q.v. |
| 270 | # @var{description} is a present-tense verb phrase (passed to AC_MSG_CHECKING). |
| 271 | # |
| 272 | AC_DEFUN([GUILE_MODULE_CHECK], |
| 273 | [AC_MSG_CHECKING([if $2 $4]) |
| 274 | GUILE_CHECK($1,(use-modules $2) (exit ((lambda () $3)))) |
| 275 | if test "$$1" = "0" ; then $1=yes ; else $1=no ; fi |
| 276 | AC_MSG_RESULT($$1) |
| 277 | ]) |
| 278 | |
| 279 | # GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module |
| 280 | # |
| 281 | # Usage: GUILE_MODULE_AVAILABLE(var,module) |
| 282 | # |
| 283 | # @var{var} is a shell variable name to be set to "yes" or "no". |
| 284 | # @var{module} is a list of symbols, like: (ice-9 common-list). |
| 285 | # |
| 286 | AC_DEFUN([GUILE_MODULE_AVAILABLE], |
| 287 | [GUILE_MODULE_CHECK($1,$2,0,is available) |
| 288 | ]) |
| 289 | |
| 290 | # GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable |
| 291 | # |
| 292 | # Usage: GUILE_MODULE_REQUIRED(symlist) |
| 293 | # |
| 294 | # @var{symlist} is a list of symbols, WITHOUT surrounding parens, |
| 295 | # like: ice-9 common-list. |
| 296 | # |
| 297 | AC_DEFUN([GUILE_MODULE_REQUIRED], |
| 298 | [GUILE_MODULE_AVAILABLE(ac_guile_module_required, ($1)) |
| 299 | if test "$ac_guile_module_required" = "no" ; then |
| 300 | AC_MSG_ERROR([required guile module not found: ($1)]) |
| 301 | fi |
| 302 | ]) |
| 303 | |
| 304 | # GUILE_MODULE_EXPORTS -- check if a module exports a variable |
| 305 | # |
| 306 | # Usage: GUILE_MODULE_EXPORTS(var,module,modvar) |
| 307 | # |
| 308 | # @var{var} is a shell variable to be set to "yes" or "no". |
| 309 | # @var{module} is a list of symbols, like: (ice-9 common-list). |
| 310 | # @var{modvar} is the Guile Scheme variable to check. |
| 311 | # |
| 312 | AC_DEFUN([GUILE_MODULE_EXPORTS], |
| 313 | [GUILE_MODULE_CHECK($1,$2,$3,exports `$3') |
| 314 | ]) |
| 315 | |
| 316 | # GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable |
| 317 | # |
| 318 | # Usage: GUILE_MODULE_REQUIRED_EXPORT(module,modvar) |
| 319 | # |
| 320 | # @var{module} is a list of symbols, like: (ice-9 common-list). |
| 321 | # @var{modvar} is the Guile Scheme variable to check. |
| 322 | # |
| 323 | AC_DEFUN([GUILE_MODULE_REQUIRED_EXPORT], |
| 324 | [GUILE_MODULE_EXPORTS(guile_module_required_export,$1,$2) |
| 325 | if test "$guile_module_required_export" = "no" ; then |
| 326 | AC_MSG_ERROR([module $1 does not export $2; required]) |
| 327 | fi |
| 328 | ]) |
| 329 | |
| 330 | ## guile.m4 ends here |