aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-05-11 14:13:11 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-05-11 14:13:11 +0300
commitf1335bff82d6a0dc9a14f070d7f4cdbe8f01bdce (patch)
tree20f38622d9d106bb2b3fe5ffc65e310ba204535e
parent4254b0590e609b82dac3d688ecb401c9eefb7e25 (diff)
downloadgint-f1335bff82d6a0dc9a14f070d7f4cdbe8f01bdce.tar.gz
gint-f1335bff82d6a0dc9a14f070d7f4cdbe8f01bdce.tar.bz2
Add options for conditional checking.
* gint.m4 (_GINT_OPTION_SWITCH): New macro. * guile.m4 (GINT_CHECK_GUILE): Always declare substitution variables. Generate --with-guile/--enable-guile options, if requested. Don't do any checking if disabled by those options. * README: Describe new features.
-rw-r--r--README85
-rw-r--r--gint.m410
-rw-r--r--guile.m4196
3 files changed, 202 insertions, 89 deletions
diff --git a/README b/README
index 2973837..9ca2c76 100644
--- a/README
+++ b/README
@@ -9,7 +9,7 @@ See end of file for copyright statement.
GINT
====
Sergey Poznyakoff <gray@gnu.org>
-1, April 5, 2010
+2, May 11, 2010
NAME
----
@@ -273,21 +273,58 @@ Scheme counterpart. By supplying the +snarf-doc-filter+ option, you instruct
*GINT* to use Scheme implementation instead. See the section
<<doc-snarfing, Doc snarfing>> for a detailed discussion.
+[[option-generators]]
+By default, the generated +configure+ script always checks for Guile. The
+following options modify this behavior:
+
+with-guile::
+Add a +--with-guile+ option to configure. Do not check for Guile if
+configure was called with +--with-guile=no+ (or +--without-guile+).
+
+without-guile::
+Same as above, except that Guile checks are disabled by default. I.e. the
+configure script checks for Guile only if invoked with the +--with-guile+
+option.
+
+enable-guile::
+Add a +--enable-guile+ option to configure. Do not check for Guile if
+configure was called with +--enable-guile=no+ (or +--disable-guile+).
+
+disable-guile::
+Same as above, except that Guile checks are disabled by default. I.e. the
+configure script checks for Guile only if invoked with the +--enable-guile+
+option.
+
+Only one of these four options may be given to a +GINT_INIT+ invocation.
+
Here is a more complex example:
.+GINT_INIT+ macro
-------------------------------------------------------
-GINT_INIT([modules/gint], [1.8 std-site-dir],
+GINT_INIT([modules/gint], [1.8 with-guile std-site-dir],
[use_guile=yes],
[use_guile=no])
-------------------------------------------------------
This fragment initializes the +GINT+ module located in `modules/gint` and
-checks for Guile version 1.8 or newer. The resulting script sets
-<<sitedir,sitedir>> to the standard Guile site directory. The
-shell variable `use_guile` is set to `yes` or `no`, depending on
-whether Guile was found or not.
+checks for Guile version 1.8 or newer. The resulting script understands
+the +--with-guile+ option and sets <<sitedir,sitedir>> to the standard Guile
+site directory. The shell variable `use_guile` is set to `yes` or `no`,
+depending on whether Guile was found or not.
+
+Notice, that you may not use this macro within a shell conditional, or
+within any +Autoconf+ macro that generates such a conditional. In particular,
+the following invocation is wrong:
+
+.*Wrong usage*
+-----------------------------------------
+AC_ARG_WITH([guile],
+ [GINT_INIT([modules/gint])])
+-----------------------------------------
+
+Instead, use one of the <<option-generators, option generating>> options,
+described above.
[[gint-subst-vars]]
Substitution Variables
@@ -295,10 +332,12 @@ Substitution Variables
Upon successful return, +GINT_INIT+ sets the following Automake
substitution variables:
+[[GUILE_VERSION]]
GUILE_VERSION::
The version of Guile, as a string, e.g. `1.9.9`. Additionally,
a _C_ preprocessor macro with the same name is defined.
+[[GUILE_VERSION_NUMBER]]
GUILE_VERSION_NUMBER::
The version of Guile packed into a decimal number using the following formula:
+
@@ -330,6 +369,40 @@ The full pathname of the `guile-tools` binary.
GUILE_SITE::
The full pathname of the Guile site-wide module directory.
+[[gint-shell-vars]]
+Shell Variables
+---------------
+The +GINT_INIT+ macro sets the following shell variables:
+
+gint_enable_guile::
+By default, set to `yes`. If an <<option-generators, option generating>>
+option was used, this variable is set to `no` if the *Guile* checks were
+disabled (either by default or by the user request) and to `yes` otherwise.
+
+gint_cv_guile::
+Set to `yes` if a sufficiently new version of *Guile* was found, and to
+`no` otherwise.
+
+[[gint_cv_guile_debug]]
+gint_cv_guile_debug::
+Set if guile supports the debugging macros (i.e. +SCM_DEVAL_P+,
++SCM_BACKTRACE_P+, +SCM_RECORD_POSITIONS_P+ and SCM_RESET_DEBUG_MODE).
+
+[[config.h defines]]
+Config.h Defines
+----------------
+GUILE_DEBUG_MACROS::
+Defined if guile supports the debugging macros (i.e. +SCM_DEVAL_P+,
++SCM_BACKTRACE_P+, +SCM_RECORD_POSITIONS_P+ and SCM_RESET_DEBUG_MODE).
+See also the <<gint_cv_guile_debug, +gint_cv_guile_debug+>> variable.
+
+GUILE_VERSION::
+Same as the <<GUILE_VERSION, +GUILE_VERSION+>> substitution variable.
+
+GUILE_VERSION_NUMBER::
+Same as the <<GUILE_VERSION_NUMBER, +GUILE_VERSION_NUMBER+>> substitution
+variable.
+
[[doc-snarfing]]
Doc Snarfing
~~~~~~~~~~~~
diff --git a/gint.m4 b/gint.m4
index 511d2c1..4f3ff48 100644
--- a/gint.m4
+++ b/gint.m4
@@ -38,6 +38,16 @@ AC_DEFUN([_GINT_SET_OPTION],
AC_DEFUN([_GINT_IF_OPTION_SET],
[m4_ifset(_GINT_MANGLE_OPTION([$1]),[$2],[$3])])
+# _GINT_OPTION_SWITCH(NAME1,IF-SET1,[NAME2,IF-SET2,[...]],[IF-NOT-SET])
+# ------------------------------------------------------------------------
+# If NAME1 is set, run IF-SET1. Otherwise, if NAME2 is set, run IF-SET2.
+# Continue the process for all name-if-set pairs within [...]. If none
+# of the options is set, run IF-NOT-SET.
+AC_DEFUN([_GINT_OPTION_SWITCH],
+[m4_if([$4],,[_GINT_IF_OPTION_SET($@)],dnl
+[$3],,[_GINT_IF_OPTION_SET($@)],dnl
+[_GINT_IF_OPTION_SET([$1],[$2],[_GINT_OPTION_SWITCH(m4_shift(m4_shift($@)))])])])
+
# _GINT_SET_OPTIONS(OPTIONS)
# ----------------------------------
# OPTIONS is a space-separated list of Gint options.
diff --git a/guile.m4 b/guile.m4
index 1d340b4..ccf9dc6 100644
--- a/guile.m4
+++ b/guile.m4
@@ -23,98 +23,128 @@ m4_define([_gint_mangle_version],[_gint_eval_version(m4_bpatsubst($1,\.,[,]))])
m4_define([_gint_site_dir],[`guile -c '(write (%site-dir)) (newline)'`])
-dnl GINT_CHECK_GUILE(minversion, [act-if-found], [ac-if-not-found])
+dnl GINT_CHECK_GUILE(minversion, [act-if-found], [act-if-not-found])
dnl $1 $2 $3
AC_DEFUN([GINT_CHECK_GUILE],
[
+ AC_SUBST(GUILE_INCLUDES)
+ AC_SUBST(GUILE_LIBS)
+ AC_SUBST(GUILE_VERSION)
+ AC_SUBST(GUILE_VERSION_NUMBER)
AS_VAR_SET([gint_cv_guile], [no])
- AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $PATH)
- if test "$GUILE_CONFIG" = no; then
- m4_if([$3],,[AC_MSG_ERROR(cannot find Guile)], [$3])
- else
- AC_SUBST(GUILE_INCLUDES)
- AC_SUBST(GUILE_LIBS)
- AC_SUBST(GUILE_VERSION)
- AC_SUBST(GUILE_VERSION_NUMBER)
- AC_PATH_PROG(GUILE_SNARF, guile-snarf)
- AC_PATH_PROG(GUILE_TOOLS, guile-tools)
-
- GUILE_INCLUDES=`$GUILE_CONFIG compile`
- GUILE_LIBS=`$GUILE_CONFIG link`
- GUILE_VERSION=`($GUILE_CONFIG --version 2>&1; echo '')|sed 's/guile-config [[^0-9]]* \([[0-9]][[0-9.]]*\)$/\1/'`
- VEX=`echo $GUILE_VERSION | sed 's/\./ \\\\* 1000 + /;s/\./ \\\\* 100 + /'`
- GUILE_VERSION_NUMBER=`eval expr "$VEX"`
- m4_if([$1],,,[
- if test $GUILE_VERSION_NUMBER -lt _gint_mangle_version($1); then
- m4_if($3,,
- [AC_MSG_ERROR([Guile version too old; required is at least ]$1)],
- [$3])
- fi])
+ _GINT_OPTION_SWITCH(
+ [with-guile],
+ [AC_ARG_WITH([guile],
+ [AC_HELP_STRING([--with-guile],
+ [compile with Guile support (default)])],
+ [gint_enable_guile=$withval],
+ [gint_enable_guile=yes])],
+ [without-guile],
+ [AC_ARG_WITH([guile],
+ [AC_HELP_STRING([--with-guile],
+ [compile with Guile support])],
+ [gint_enable_guile=$withval],
+ [gint_enable_guile=no])],
+ [enable-guile],
+ [AC_ARG_ENABLE([guile],
+ [AC_HELP_STRING([--enable-guile],
+ [enable Guile support (default)])],
+ [gint_enable_guile=$enableval],
+ [gint_enable_guile=yes])],
+ [disable-guile],
+ [AC_ARG_ENABLE([guile],
+ [AC_HELP_STRING([--enable-guile],
+ [enable Guile support])],
+ [gint_enable_guile=$enableval],
+ [gint_enable_guile=no])],
+ [gint_enable_guile=yes])
- save_LIBS=$LIBS
- save_CFLAGS=$CFLAGS
- LIBS="$LIBS $GUILE_LIBS"
- CFLAGS="$CFLAGS $GUILE_INCLUDES"
- AC_TRY_LINK([#include <libguile.h>],
- m4_if([$1], , scm_shell(0, NULL);, [$1]),
- [AS_VAR_SET([gint_cv_guile], $GUILE_VERSION)])
- LIBS=$save_LIBS
- CFLAGS=$save_CFLAGS
- fi
+ if test "$gint_enable_guile" = yes; then
+ AC_PATH_PROG(GUILE_CONFIG, guile-config, no, $PATH)
+ if test "$GUILE_CONFIG" = no; then
+ m4_if([$3],,[AC_MSG_ERROR(cannot find Guile)], [$3])
+ else
+ AC_PATH_PROG(GUILE_SNARF, guile-snarf)
+ AC_PATH_PROG(GUILE_TOOLS, guile-tools)
+
+ GUILE_INCLUDES=`$GUILE_CONFIG compile`
+ GUILE_LIBS=`$GUILE_CONFIG link`
+ GUILE_VERSION=`($GUILE_CONFIG --version 2>&1; echo '')|sed 's/guile-config [[^0-9]]* \([[0-9]][[0-9.]]*\)$/\1/'`
+ VEX=`echo $GUILE_VERSION | sed 's/\./ \\\\* 1000 + /;s/\./ \\\\* 100 + /'`
+ GUILE_VERSION_NUMBER=`eval expr "$VEX"`
- if test $gint_cv_guile = no; then
- GUILE_INCLUDES=
- GUILE_LIBS=
- GUILE_VERSION=
- GUILE_VERSION_NUMBER=
- m4_if([$3],,[AC_MSG_ERROR(required library libguile not found)], [$3])
- else
- save_LIBS=$LIBS
- save_CFLAGS=$CFLAGS
- LIBS="$LIBS $GUILE_LIBS"
- CFLAGS="$CFLAGS $GUILE_INCLUDES"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libguile.h>]],
- [SCM_DEVAL_P = 1;
- SCM_BACKTRACE_P = 1;
- SCM_RECORD_POSITIONS_P = 1;
- SCM_RESET_DEBUG_MODE;])],
- [gint_cv_guile_debug=yes],
- [gint_cv_guile_debug=no])
- if test $gint_cv_guile_debug = yes; then
- AC_DEFINE_UNQUOTED(GUILE_DEBUG_MACROS, 1,
- [Define to 1 if SCM_DEVAL_P, SCM_BACKTRACE_P, SCM_RECORD_POSITIONS_P and SCM_RESET_DEBUG_MODE are defined])
+ m4_if([$1],,,[
+ if test $GUILE_VERSION_NUMBER -lt _gint_mangle_version($1); then
+ m4_if($3,,
+ [AC_MSG_ERROR([Guile version too old; required is at least ]$1)],
+ [$3])
+ fi])
+
+ save_LIBS=$LIBS
+ save_CFLAGS=$CFLAGS
+ LIBS="$LIBS $GUILE_LIBS"
+ CFLAGS="$CFLAGS $GUILE_INCLUDES"
+ AC_TRY_LINK([#include <libguile.h>],
+ m4_if([$1], , scm_shell(0, NULL);, [$1]),
+ [AS_VAR_SET([gint_cv_guile], $GUILE_VERSION)])
+ LIBS=$save_LIBS
+ CFLAGS=$save_CFLAGS
fi
- AC_CHECK_TYPES([scm_t_off],[],[],[#include <libguile.h>])
- LIBS=$save_LIBS
- CFLAGS=$save_CFLAGS
+
+ if test $gint_cv_guile = no; then
+ GUILE_INCLUDES=
+ GUILE_LIBS=
+ GUILE_VERSION=
+ GUILE_VERSION_NUMBER=
+ m4_if([$3],,[AC_MSG_ERROR(required library libguile not found)], [$3])
+ else
+ save_LIBS=$LIBS
+ save_CFLAGS=$CFLAGS
+ LIBS="$LIBS $GUILE_LIBS"
+ CFLAGS="$CFLAGS $GUILE_INCLUDES"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libguile.h>]],
+ [SCM_DEVAL_P = 1;
+ SCM_BACKTRACE_P = 1;
+ SCM_RECORD_POSITIONS_P = 1;
+ SCM_RESET_DEBUG_MODE;])],
+ [gint_cv_guile_debug=yes],
+ [gint_cv_guile_debug=no])
+ if test $gint_cv_guile_debug = yes; then
+ AC_DEFINE_UNQUOTED(GUILE_DEBUG_MACROS, 1,
+ [Define to 1 if SCM_DEVAL_P, SCM_BACKTRACE_P, SCM_RECORD_POSITIONS_P and SCM_RESET_DEBUG_MODE are defined])
+ fi
+ AC_CHECK_TYPES([scm_t_off],[],[],[#include <libguile.h>])
+ LIBS=$save_LIBS
+ CFLAGS=$save_CFLAGS
- AC_SUBST(GUILE_SITE)
- _GINT_IF_OPTION_SET([std-site-dir],
- [GUILE_SITE=_gint_site_dir],
- [AC_ARG_WITH([guile-site-dir],
- AC_HELP_STRING([--with-guile-site-dir=DIR],
- [specify directory to install guile modules to]),
- [case $withval in
- /*) GUILE_SITE=$withval;;
- yes) GUILE_SITE=_gint_site_dir;;
- *) AC_MSG_ERROR([Argument to --with-guile-site-dir must be an absolute directory name]);;
- esac],
- [GUILE_SITE=_gint_site_dir
- pfx=$prefix
- test "x$pfx" = xNONE && pfx=$ac_default_prefix
- case $GUILE_SITE in
- $pfx/*) ;; # OK
- *) AC_MSG_WARN([guile site directory "$GUILE_SITE" lies outside your current prefix ($pfx).])
- GUILE_SITE='$(datadir)/guile/site'
- AC_MSG_WARN([Falling back to ${GUILE_SITE} instead. Use --with-guile-site-dir to force using site directory.])
- ;;
- esac])])
- AC_DEFINE_UNQUOTED(GUILE_VERSION, "$GUILE_VERSION",
- [Guile version number])
- AC_DEFINE_UNQUOTED(GUILE_VERSION_NUMBER, $GUILE_VERSION_NUMBER,
- [Guile version number: MAX*10 + MIN])
- m4_if([$2],,,[$2])
+ AC_SUBST(GUILE_SITE)
+ _GINT_IF_OPTION_SET([std-site-dir],
+ [GUILE_SITE=_gint_site_dir],
+ [AC_ARG_WITH([guile-site-dir],
+ [AC_HELP_STRING([--with-guile-site-dir=DIR],
+ [specify directory to install guile modules to])],
+ [case $withval in
+ /*) GUILE_SITE=$withval;;
+ yes) GUILE_SITE=_gint_site_dir;;
+ *) AC_MSG_ERROR([Argument to --with-guile-site-dir must be an absolute directory name]);;
+ esac],
+ [GUILE_SITE=_gint_site_dir
+ pfx=$prefix
+ test "x$pfx" = xNONE && pfx=$ac_default_prefix
+ case $GUILE_SITE in
+ $pfx/*) ;; # OK
+ *) AC_MSG_WARN([guile site directory "$GUILE_SITE" lies outside your current prefix ($pfx).])
+ GUILE_SITE='$(datadir)/guile/site'
+ AC_MSG_WARN([Falling back to ${GUILE_SITE} instead. Use --with-guile-site-dir to force using site directory.])
+ ;;
+ esac])])
+ AC_DEFINE_UNQUOTED(GUILE_VERSION, "$GUILE_VERSION",
+ [Guile version number])
+ AC_DEFINE_UNQUOTED(GUILE_VERSION_NUMBER, $GUILE_VERSION_NUMBER,
+ [Guile version number: MAX*10 + MIN])
+ m4_if([$2],,,[$2])
+ fi
fi
])

Return to:

Send suggestions and report system problems to the System administrator.