aboutsummaryrefslogtreecommitdiff
path: root/am
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-04-21 12:42:12 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-04-21 12:42:12 +0300
commit3f02a6139ea4ed7635453cbcdd600e815a5c2208 (patch)
tree7b5f4ae6581b459cd1ce798c2661bc21803700f6 /am
parentac16853820abac40abb0bc72e7190626877b3c7f (diff)
downloadgrecs-3f02a6139ea4ed7635453cbcdd600e815a5c2208.tar.gz
grecs-3f02a6139ea4ed7635453cbcdd600e815a5c2208.tar.bz2
Improve GRECS_SETUP.
The macro takes an optional second argument. When given, it supplies the name of the preprocessor setup file to install. Options available for use in the 1st argument are: no-preproc Generate the --without-preprocessor option. std-pp-setup Install the default pp-setup file. Note for upgraders: earlier this was the default! pp-setup-option Generate the --with-pp-setup-file option. * am/grecs.m4 (GRECS_SETUP): Handle new options.
Diffstat (limited to 'am')
-rw-r--r--am/grecs.m464
1 files changed, 58 insertions, 6 deletions
diff --git a/am/grecs.m4 b/am/grecs.m4
index 72c6432..dfed409 100644
--- a/am/grecs.m4
+++ b/am/grecs.m4
@@ -1,4 +1,4 @@
-# This file is part of grecs - Gray's Extensible Configuration System
+# This file is part of grecs - Gray's Extensible Configuration System -*- autoconf -*-
# Copyright (C) 2007, 2009, 2010 Sergey Poznyakoff
#
# Grex is free software; you can redistribute it and/or modify
@@ -14,12 +14,48 @@
# You should have received a copy of the GNU General Public License
# along with Grex. If not, see <http://www.gnu.org/licenses/>.
-# GRECS_SETUP([no-preproc])
+# _GRECS_MANGLE_OPTION(NAME)
+# -------------------------
+# Convert NAME to a valid m4 identifier, by replacing invalid characters
+# with underscores, and prepend the _GRECS_OPTION_ suffix to it.
+AC_DEFUN([_GRECS_MANGLE_OPTION],
+[[_GRECS_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _GRECS_SET_OPTION(NAME)
+# ----------------------
+# Set option NAME.
+AC_DEFUN([_GRECS_SET_OPTION],
+[m4_define(_GRECS_MANGLE_OPTION([$1]), 1)])
+
+# _GRECS_IF_OPTION_SET(NAME,IF-SET,IF-NOT-SET)
+# -------------------------------------------
+# Check if option NAME is set.
+AC_DEFUN([_GRECS_IF_OPTION_SET],
+[m4_ifset(_GRECS_MANGLE_OPTION([$1]),[$2],[$3])])
+
+# _GRECS_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([_GRECS_OPTION_SWITCH],
+[m4_if([$4],,[_GRECS_IF_OPTION_SET($@)],dnl
+[$3],,[_GRECS_IF_OPTION_SET($@)],dnl
+[_GRECS_IF_OPTION_SET([$1],[$2],[_GRECS_OPTION_SWITCH(m4_shift(m4_shift($@)))])])])
+
+# _GRECS_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Gint options.
+AC_DEFUN([_GRECS_SET_OPTIONS],
+[m4_foreach_w([_GRECS_Option], [$1], [_GRECS_SET_OPTION(_GRECS_Option)])])
+
+# GRECS_SETUP([no-preproc std-pp-setup pp-setup-option],[pp-setup-file])
AC_DEFUN([GRECS_SETUP],[
+ _GRECS_SET_OPTIONS([$1])
# **********************
# Preprocessor
# **********************
- m4_if($1,[no-preproc],
+ _GRECS_IF_OPTION_SET([no-preproc],
[use_ext_pp=no],
[AC_ARG_WITH([preprocessor],
AC_HELP_STRING([--without-preprocessor],
@@ -48,9 +84,25 @@ AC_DEFUN([GRECS_SETUP],[
DEFAULT_PREPROCESSOR=$PPBIN
if test -n "$DEFAULT_PREPROCESSOR"; then
DEFAULT_PREPROCESSOR="$DEFAULT_PREPROCESSOR $PREPROC_OPTIONS"
- case $PPBIN in
- *m4) AC_SUBST(PP_SETUP_FILE,'pp-setup');; # Install default pp-setup
- esac
+ _GRECS_IF_OPTION_SET([std-pp-setup],
+ [PP_SETUP_FILE='pp-setup'],
+ [m4_if([$2],,[PP_SETUP_FILE=],[PP_SETUP_FILE='$2'])])
+ AC_SUBST(PP_SETUP_FILE)
+ if test -n "$PP_SETUP_FILE"; then
+ _GRECS_IF_OPTION_SET([pp-setup-option],
+ [AC_ARG_WITH([pp-setup-file],
+ AC_HELP_STRING([--with-pp-setup-file],
+ [install the default pp-setup file]),
+ [case "${withval}" in
+ yes) ;;
+ no) PP_SETUP_FILE=;;
+ *) AC_MSG_ERROR([bad value ${withval} for --with-pp-setup-file]) ;;
+ esac])],
+ [case $PPBIN in
+ *m4) ;; # Install default pp-setup
+ *) PP_SETUP_FILE=;; # Skip it
+ esac])
+ fi
fi
PATH=$save_PATH
DEFAULT_PREPROCESSOR="\\\"$DEFAULT_PREPROCESSOR\\\""

Return to:

Send suggestions and report system problems to the System administrator.