guile.m4 6.9 KB

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