Blame m4/guile.m4

Packit 549fdc
## Autoconf macros for working with Guile.
Packit 549fdc
##
Packit 549fdc
##   Copyright (C) 1998, 2001, 2006, 2010, 2012 Free Software
Packit 549fdc
##   Foundation, Inc.
Packit 549fdc
##
Packit 549fdc
## This library is free software; you can redistribute it and/or
Packit 549fdc
## modify it under the terms of the GNU Lesser General Public
Packit 549fdc
## License as published by the Free Software Foundation; either
Packit 549fdc
## version 2.1 of the License, or (at your option) any later version.
Packit 549fdc
## 
Packit 549fdc
## This library is distributed in the hope that it will be useful,
Packit 549fdc
## but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 549fdc
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 549fdc
## Lesser General Public License for more details.
Packit 549fdc
## 
Packit 549fdc
## You should have received a copy of the GNU Lesser General Public
Packit 549fdc
## License along with this library; if not, write to the Free Software
Packit 549fdc
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Packit 549fdc
Packit 549fdc
## Index
Packit 549fdc
## -----
Packit 549fdc
##
Packit 549fdc
## GUILE_PROGS -- set paths to Guile interpreter, config and tool programs
Packit 549fdc
## GUILE_FLAGS -- set flags for compiling and linking with Guile
Packit 549fdc
## GUILE_SITE_DIR -- find path to Guile "site" directory
Packit 549fdc
## GUILE_CHECK -- evaluate Guile Scheme code and capture the return value
Packit 549fdc
## GUILE_MODULE_CHECK -- check feature of a Guile Scheme module
Packit 549fdc
## GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module
Packit 549fdc
## GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable
Packit 549fdc
## GUILE_MODULE_EXPORTS -- check if a module exports a variable
Packit 549fdc
## GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable
Packit 549fdc
Packit 549fdc
## Code
Packit 549fdc
## ----
Packit 549fdc
Packit 549fdc
## NOTE: Comments preceding an AC_DEFUN (starting from "Usage:") are massaged
Packit 549fdc
## into doc/ref/autoconf-macros.texi (see Makefile.am in that directory).
Packit 549fdc
Packit 549fdc
# GUILE_PROGS -- set paths to Guile interpreter, config and tool programs
Packit 549fdc
#
Packit 549fdc
# Usage: GUILE_PROGS
Packit 549fdc
#
Packit 549fdc
# This macro looks for programs @code{guile}, @code{guile-config} and
Packit 549fdc
# @code{guile-tools}, and sets variables @var{GUILE}, @var{GUILE_CONFIG} and
Packit 549fdc
# @var{GUILE_TOOLS}, to their paths, respectively.  If either of the first two
Packit 549fdc
# is not found, signal error.
Packit 549fdc
#
Packit 549fdc
# The variables are marked for substitution, as by @code{AC_SUBST}.
Packit 549fdc
#
Packit 549fdc
AC_DEFUN([GUILE_PROGS],
Packit 549fdc
 [AC_PATH_PROG(GUILE,guile)
Packit 549fdc
  if test "$GUILE" = "" ; then
Packit 549fdc
      AC_MSG_ERROR([guile required but not found])
Packit 549fdc
  fi
Packit 549fdc
  AC_SUBST(GUILE)
Packit 549fdc
  AC_PATH_PROG(GUILE_CONFIG,guile-config)
Packit 549fdc
  if test "$GUILE_CONFIG" = "" ; then
Packit 549fdc
      AC_MSG_ERROR([guile-config required but not found])
Packit 549fdc
  fi
Packit 549fdc
  AC_SUBST(GUILE_CONFIG)
Packit 549fdc
  AC_PATH_PROG(GUILE_TOOLS,guile-tools)
Packit 549fdc
  AC_SUBST(GUILE_TOOLS)
Packit 549fdc
 ])
Packit 549fdc
Packit 549fdc
# GUILE_FLAGS -- set flags for compiling and linking with Guile
Packit 549fdc
#
Packit 549fdc
# Usage: GUILE_FLAGS
Packit 549fdc
#
Packit 549fdc
# This macro runs the @code{guile-config} script, installed with Guile, to
Packit 549fdc
# find out where Guile's header files and libraries are installed.  It sets
Packit 549fdc
# two variables, @var{GUILE_CFLAGS} and @var{GUILE_LDFLAGS}.
Packit 549fdc
#
Packit 549fdc
# @var{GUILE_CFLAGS}: flags to pass to a C or C++ compiler to build code that
Packit 549fdc
# uses Guile header files.  This is almost always just a @code{-I} flag.
Packit 549fdc
#
Packit 549fdc
# @var{GUILE_LDFLAGS}: flags to pass to the linker to link a program against
Packit 549fdc
# Guile.  This includes @code{-lguile} for the Guile library itself, any
Packit 549fdc
# libraries that Guile itself requires (like -lqthreads), and so on.  It may
Packit 549fdc
# also include a @code{-L} flag to tell the compiler where to find the
Packit 549fdc
# libraries.
Packit 549fdc
#
Packit 549fdc
# The variables are marked for substitution, as by @code{AC_SUBST}.
Packit 549fdc
#
Packit 549fdc
AC_DEFUN([GUILE_FLAGS],
Packit 549fdc
 [AC_REQUIRE([GUILE_PROGS])dnl
Packit 549fdc
  AC_MSG_CHECKING([libguile compile flags])
Packit 549fdc
  GUILE_CFLAGS="`$GUILE_CONFIG compile`"
Packit 549fdc
  AC_MSG_RESULT([$GUILE_CFLAGS])
Packit 549fdc
  AC_MSG_CHECKING([libguile link flags])
Packit 549fdc
  GUILE_LDFLAGS="`$GUILE_CONFIG link`"
Packit 549fdc
  AC_MSG_RESULT([$GUILE_LDFLAGS])
Packit 549fdc
  AC_SUBST(GUILE_CFLAGS)
Packit 549fdc
  AC_SUBST(GUILE_LDFLAGS)
Packit 549fdc
 ])
Packit 549fdc
Packit 549fdc
# GUILE_SITE_DIR -- find path to Guile "site" directory
Packit 549fdc
#
Packit 549fdc
# Usage: GUILE_SITE_DIR
Packit 549fdc
#
Packit 549fdc
# This looks for Guile's "site" directory, usually something like
Packit 549fdc
# PREFIX/share/guile/site, and sets var @var{GUILE_SITE} to the path.
Packit 549fdc
# Note that the var name is different from the macro name.
Packit 549fdc
#
Packit 549fdc
# The variable is marked for substitution, as by @code{AC_SUBST}.
Packit 549fdc
#
Packit 549fdc
AC_DEFUN([GUILE_SITE_DIR],
Packit 549fdc
 [AC_REQUIRE([GUILE_PROGS])dnl
Packit 549fdc
  AC_MSG_CHECKING(for Guile site directory)
Packit 549fdc
  GUILE_SITE=`[$GUILE_CONFIG] info pkgdatadir`/site
Packit 549fdc
  AC_MSG_RESULT($GUILE_SITE)
Packit 549fdc
  AC_SUBST(GUILE_SITE)
Packit 549fdc
 ])
Packit 549fdc
Packit 549fdc
# GUILE_CHECK -- evaluate Guile Scheme code and capture the return value
Packit 549fdc
#
Packit 549fdc
# Usage: GUILE_CHECK_RETVAL(var,check)
Packit 549fdc
#
Packit 549fdc
# @var{var} is a shell variable name to be set to the return value.
Packit 549fdc
# @var{check} is a Guile Scheme expression, evaluated with "$GUILE -c", and
Packit 549fdc
#    returning either 0 or non-#f to indicate the check passed.
Packit 549fdc
#    Non-0 number or #f indicates failure.
Packit 549fdc
#    Avoid using the character "#" since that confuses autoconf.
Packit 549fdc
#
Packit 549fdc
AC_DEFUN([GUILE_CHECK],
Packit 549fdc
 [AC_REQUIRE([GUILE_PROGS])
Packit 549fdc
  $GUILE -c "$2" > /dev/null 2>&1
Packit 549fdc
  $1=$?
Packit 549fdc
 ])
Packit 549fdc
Packit 549fdc
# GUILE_MODULE_CHECK -- check feature of a Guile Scheme module
Packit 549fdc
#
Packit 549fdc
# Usage: GUILE_MODULE_CHECK(var,module,featuretest,description)
Packit 549fdc
#
Packit 549fdc
# @var{var} is a shell variable name to be set to "yes" or "no".
Packit 549fdc
# @var{module} is a list of symbols, like: (ice-9 common-list).
Packit 549fdc
# @var{featuretest} is an expression acceptable to GUILE_CHECK, q.v.
Packit 549fdc
# @var{description} is a present-tense verb phrase (passed to AC_MSG_CHECKING).
Packit 549fdc
#
Packit 549fdc
AC_DEFUN([GUILE_MODULE_CHECK],
Packit 549fdc
         [AC_MSG_CHECKING([if $2 $4])
Packit 549fdc
	  GUILE_CHECK($1,(use-modules $2) (exit ((lambda () $3))))
Packit 549fdc
	  if test "$$1" = "0" ; then $1=yes ; else $1=no ; fi
Packit 549fdc
          AC_MSG_RESULT($$1)
Packit 549fdc
         ])
Packit 549fdc
Packit 549fdc
# GUILE_MODULE_AVAILABLE -- check availability of a Guile Scheme module
Packit 549fdc
#
Packit 549fdc
# Usage: GUILE_MODULE_AVAILABLE(var,module)
Packit 549fdc
#
Packit 549fdc
# @var{var} is a shell variable name to be set to "yes" or "no".
Packit 549fdc
# @var{module} is a list of symbols, like: (ice-9 common-list).
Packit 549fdc
#
Packit 549fdc
AC_DEFUN([GUILE_MODULE_AVAILABLE],
Packit 549fdc
         [GUILE_MODULE_CHECK($1,$2,0,is available)
Packit 549fdc
         ])
Packit 549fdc
Packit 549fdc
# GUILE_MODULE_REQUIRED -- fail if a Guile Scheme module is unavailable
Packit 549fdc
#
Packit 549fdc
# Usage: GUILE_MODULE_REQUIRED(symlist)
Packit 549fdc
#
Packit 549fdc
# @var{symlist} is a list of symbols, WITHOUT surrounding parens,
Packit 549fdc
# like: ice-9 common-list.
Packit 549fdc
#
Packit 549fdc
AC_DEFUN([GUILE_MODULE_REQUIRED],
Packit 549fdc
         [GUILE_MODULE_AVAILABLE(ac_guile_module_required, ($1))
Packit 549fdc
          if test "$ac_guile_module_required" = "no" ; then
Packit 549fdc
              AC_MSG_ERROR([required guile module not found: ($1)])
Packit 549fdc
          fi
Packit 549fdc
         ])
Packit 549fdc
Packit 549fdc
# GUILE_MODULE_EXPORTS -- check if a module exports a variable
Packit 549fdc
#
Packit 549fdc
# Usage: GUILE_MODULE_EXPORTS(var,module,modvar)
Packit 549fdc
#
Packit 549fdc
# @var{var} is a shell variable to be set to "yes" or "no".
Packit 549fdc
# @var{module} is a list of symbols, like: (ice-9 common-list).
Packit 549fdc
# @var{modvar} is the Guile Scheme variable to check.
Packit 549fdc
#
Packit 549fdc
AC_DEFUN([GUILE_MODULE_EXPORTS],
Packit 549fdc
 [GUILE_MODULE_CHECK($1,$2,$3,exports `$3')
Packit 549fdc
 ])
Packit 549fdc
Packit 549fdc
# GUILE_MODULE_REQUIRED_EXPORT -- fail if a module doesn't export a variable
Packit 549fdc
#
Packit 549fdc
# Usage: GUILE_MODULE_REQUIRED_EXPORT(module,modvar)
Packit 549fdc
#
Packit 549fdc
# @var{module} is a list of symbols, like: (ice-9 common-list).
Packit 549fdc
# @var{modvar} is the Guile Scheme variable to check.
Packit 549fdc
#
Packit 549fdc
AC_DEFUN([GUILE_MODULE_REQUIRED_EXPORT],
Packit 549fdc
 [GUILE_MODULE_EXPORTS(guile_module_required_export,$1,$2)
Packit 549fdc
  if test "$guile_module_required_export" = "no" ; then
Packit 549fdc
      AC_MSG_ERROR([module $1 does not export $2; required])
Packit 549fdc
  fi
Packit 549fdc
 ])
Packit 549fdc
Packit 549fdc
## guile.m4 ends here