aboutsummaryrefslogtreecommitdiff
path: root/am/argot.m4
diff options
context:
space:
mode:
Diffstat (limited to 'am/argot.m4')
-rw-r--r--am/argot.m4245
1 files changed, 245 insertions, 0 deletions
diff --git a/am/argot.m4 b/am/argot.m4
new file mode 100644
index 0000000..f5a21aa
--- /dev/null
+++ b/am/argot.m4
@@ -0,0 +1,245 @@
+# This file is part of argot - Gray's Extensible Configuration System -*- autoconf -*-
+# Copyright (C) 2007-2016 Sergey Poznyakoff
+#
+# Grex is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Grex is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Grex. If not, see <http://www.gnu.org/licenses/>.
+
+# _ARGOT_MANGLE_OPTION(NAME)
+# -------------------------
+# Convert NAME to a valid m4 identifier, by replacing invalid characters
+# with underscores, and prepend the _ARGOT_OPTION_ suffix to it.
+AC_DEFUN([_ARGOT_MANGLE_OPTION],
+[[_ARGOT_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _ARGOT_SET_OPTION(NAME)
+# ----------------------
+# Set option NAME.
+AC_DEFUN([_ARGOT_SET_OPTION],
+[m4_define(_ARGOT_MANGLE_OPTION([$1]), 1)])
+
+# _ARGOT_IF_OPTION_SET(NAME,IF-SET,IF-NOT-SET)
+# -------------------------------------------
+# Check if option NAME is set.
+AC_DEFUN([_ARGOT_IF_OPTION_SET],
+[m4_ifset(_ARGOT_MANGLE_OPTION([$1]),[$2],[$3])])
+
+# _ARGOT_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([_ARGOT_OPTION_SWITCH],
+[m4_if([$4],,[_ARGOT_IF_OPTION_SET($@)],dnl
+[$3],,[_ARGOT_IF_OPTION_SET($@)],dnl
+[_ARGOT_IF_OPTION_SET([$1],[$2],[_ARGOT_OPTION_SWITCH(m4_shift(m4_shift($@)))])])])
+
+# _ARGOT_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Grecs options.
+AC_DEFUN([_ARGOT_SET_OPTIONS],
+[m4_foreach_w([_ARGOT_Option], [$1], [_ARGOT_SET_OPTION(_ARGOT_Option)])])
+
+# ARGOT_SETUP([dir],[OPTIONS],[pp-setup-file])
+# dir - Directory in the source tree where argot has been cloned.
+# OPTIONS are:
+# no-preproc Disable the use of preprocessor.
+# std-pp-setup Install standard pp-setup file.
+# pp-setup-option Add the --with-pp-setup-file option to the
+# configuration file. The option allows user to
+# control whether the pp-setup file is installed.
+# tests Build tests.
+# getopt Add getopt.m4 to the distribution.
+# git2chg Add git2chg.awk to the distribution.
+# syntax-doc Add doc/argot-syntax.texi to the distribution.
+# install Build installable library.
+# shared Build shared (convenience) library.
+# install-headers [with "shared"] Install Grecs headers to
+# ARGOT_INCLUDE_DIR.
+# tree-api Use alternative signature of callback functions,
+# passing a pointer to argot_node_t as an argument,
+# instead of pointers to the value and locus.
+# sockaddr-list Sockaddr type keeps a singly-linked list of addresses
+# returned by getaddrinfo.
+# json Compile JSON support
+#
+# The pp-setup-file argument supplies the pathname of the preprocessor
+# setup file in the source tree. It is ignored if std-pp-setup option is
+# given.
+#
+# If neither std-pp-setup option, nor pp-setup-file argument are supplied,
+# no preprocessor setup file is installed.
+
+AC_DEFUN([ARGOT_SETUP],[
+ m4_pushdef([argotdir],m4_if($1,[.],,$1,,[argot/],$1/))
+ AC_PROG_YACC
+ AM_PROG_LEX
+
+ AC_HEADER_SYS_WAIT
+
+ AC_SUBST([ARGOT_SUBDIR],m4_if($1,,argot,$1))
+ _ARGOT_SET_OPTIONS([$2])
+ # **********************
+ # Preprocessor
+ # **********************
+ _ARGOT_IF_OPTION_SET([no-preproc],
+ [use_ext_pp=no],
+ [AC_ARG_WITH([preprocessor],
+ AC_HELP_STRING([--without-preprocessor],
+ [do not use external preprocessor]),
+ [case "${withval}" in
+ yes) use_ext_pp=yes ;;
+ no) use_ext_pp=no ;;
+ *) AC_MSG_ERROR(bad value ${withval} for --with-preprocessor) ;;
+ esac],[use_ext_pp=yes])])
+
+ if test $use_ext_pp != no; then
+ # Check for default preprocessor
+ AC_ARG_VAR([DEFAULT_PREPROCESSOR],
+ [Set default preprocessor name])
+ if test -z "$DEFAULT_PREPROCESSOR" ; then
+ DEFAULT_PREPROCESSOR="m4 -s"
+ fi
+
+ save_PATH=$PATH
+ PREPROC_OPTIONS=`echo $DEFAULT_PREPROCESSOR | sed -n 's/[[^ ]][[^ ]]* //p'`
+ case "$DEFAULT_PREPROCESSOR" in
+ /*) PATH=`expr $DEFAULT_PREPROCESSOR : '\(.*\)/.*'`:$PATH
+ DEFAULT_PREPROCESSOR=`expr $DEFAULT_PREPROCESSOR : '.*/\(.*\)'`;;
+ esac
+ AC_PATH_PROG(PPBIN, $DEFAULT_PREPROCESSOR)
+ if test -n "$PPBIN"; then
+ DEFAULT_PREPROCESSOR="$PPBIN $PREPROC_OPTIONS"
+ _ARGOT_IF_OPTION_SET([std-pp-setup],
+ [PP_SETUP_FILE='pp-setup'],
+ [m4_if([$3],,[PP_SETUP_FILE=],[PP_SETUP_FILE='$3'])])
+ AC_SUBST(PP_SETUP_FILE)
+ if test -n "$PP_SETUP_FILE"; then
+ _ARGOT_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
+ DEFAULT_PREPROCESSOR="\\\"$DEFAULT_PREPROCESSOR\\\""
+ else
+ AC_MSG_WARN([requested preprocessor command "$DEFAULT_PREPROCESSOR" not found])
+ AC_MSG_WARN([preprocessing disabled])
+ DEFAULT_PREPROCESSOR=NULL
+ fi
+ PATH=$save_PATH
+ else
+ DEFAULT_PREPROCESSOR=NULL
+ fi
+ _ARGOT_IF_OPTION_SET([tests],
+ [m4_pushdef([TESTDIR],argotdir[tests])
+ AC_CONFIG_TESTDIR(TESTDIR)
+ AC_CONFIG_FILES(TESTDIR/Makefile TESTDIR/atlocal)
+ m4_popdef([TESTDIR])
+ AM_MISSING_PROG([AUTOM4TE], [autom4te])
+ ARGOT_TESTDIR=tests
+ ])
+ _ARGOT_IF_OPTION_SET([getopt],[
+ AC_CHECK_HEADERS([getopt.h])
+ AC_CHECK_FUNCS([sysconf getdtablesize getopt_long])
+ ARGOT_BUILD_AUX="build-aux/getopt.m4"
+ ])
+ _ARGOT_IF_OPTION_SET([git2chg],[ARGOT_BUILD_AUX="$ARGOT_BUILD_AUX build-aux/git2chg.awk"])
+ AM_CONDITIONAL([ARGOT_COND_META1_PARSER],
+ _ARGOT_OPTION_SWITCH([parser-meta1],[true],
+ [all-parsers],[true],
+ [false]))
+ AM_CONDITIONAL([ARGOT_COND_BIND_PARSER],
+ _ARGOT_OPTION_SWITCH([parser-bind],[true],
+ [all-parsers],[true],
+ [false]))
+ AM_CONDITIONAL([ARGOT_COND_DHCPD_PARSER],
+ _ARGOT_OPTION_SWITCH([parser-dhcpd],[true],
+ [all-parsers],[true],
+ [false]))
+ AM_CONDITIONAL([ARGOT_COND_GIT_PARSER],
+ _ARGOT_OPTION_SWITCH([parser-git],[true],
+ [all-parsers],[true],
+ [false]))
+ AM_CONDITIONAL([ARGOT_COND_INSTALLHEADERS],
+ _ARGOT_IF_OPTION_SET([install-headers],[true],[false]))
+
+ AM_CONDITIONAL([ARGOT_COND_SOCKADDR_LIST],
+ _ARGOT_IF_OPTION_SET([sockaddr-list],[true],[false]))
+ AM_CONDITIONAL([ARGOT_COND_JSON],
+ _ARGOT_IF_OPTION_SET([json],[true],[false]))
+
+ AC_SUBST([ARGOT_SOCKADDR_LIST])
+ _ARGOT_IF_OPTION_SET([sockaddr-list],[ARGOT_SOCKADDR_LIST=1],
+ [ARGOT_SOCKADDR_LIST=0])
+
+ AC_SUBST([ARGOT_TREE_API])
+ _ARGOT_IF_OPTION_SET([tree-api],[ARGOT_TREE_API=1],[ARGOT_TREE_API=0])
+
+ AC_SUBST([ARGOT_SRCDIR],$1)
+ AC_SUBST([ARGOT_BUILD_AUX])
+ AC_SUBST([ARGOT_INCLUDES])
+ AC_SUBST([ARGOT_TESTDIR])
+ AC_SUBST([ARGOT_LDADD])
+ AC_SUBST([ARGOT_DOCDIR])
+ AC_SUBST([ARGOT_CHANGELOG])
+ AC_SUBST([ARGOT_DISTCK_AT])
+ AC_SUBST([ARGOT_README])
+ AC_SUBST([ARGOT_INCLUDES],['-I$(top_srcdir)/]argotdir[include] [-I$(top_builddir)/]argotdir[include]')
+ AC_SUBST([ARGOT_HOST_PROJECT_INCLUDES])
+ AC_SUBST([ARGOT_DISTDOC])
+ AC_SUBST([ARGOT_INCLUDE_DIR],['$(pkgincludedir)'])
+
+ _ARGOT_OPTION_SWITCH([install],[
+ LT_INIT
+ ARGOT_BUILD_TYPE=install
+ ARGOT_LDADD=['$(top_builddir)/]argotdir[src/libargot.la']
+ ARGOT_DOCDIR='doc'
+ ARGOT_CHANGELOG=
+ ARGOT_DISTCK_AT=distck.at
+ ARGOT_README=README.standalone
+ AC_CONFIG_FILES(argotdir[src/Makefile]:argotdir[src/Make-inst.in]
+ argotdir[doc/Makefile])
+ ],[shared],[
+ LT_INIT
+ ARGOT_BUILD_TYPE=shared
+ ARGOT_LDADD=['$(top_builddir)/]argotdir[src/libargot.la']
+ ARGOT_CHANGELOG='#'
+ ARGOT_README=README.submodule
+ _ARGOT_IF_OPTION_SET([syntax-doc],[ARGOT_DISTDOC=doc/argot-syntax.texi])
+ AC_CONFIG_FILES(argotdir[src/Makefile]:argotdir[src/Make-shared.in])
+ ],[
+ ARGOT_BUILD_TYPE=static
+ ARGOT_LDADD=['$(top_builddir)/]argotdir[src/libargot.a']
+ ARGOT_CHANGELOG='#'
+ ARGOT_README=README.submodule
+ _ARGOT_IF_OPTION_SET([syntax-doc],[ARGOT_DISTDOC=doc/argot-syntax.texi])
+ AC_CONFIG_FILES(argotdir[src/Makefile]:argotdir[src/Make-static.in])
+ ])
+ AM_CONDITIONAL([ARGOT_COND_BUILD_INSTALL],[test $ARGOT_BUILD_TYPE = install])
+ AM_CONDITIONAL([ARGOT_COND_BUILD_SHARED],[test $ARGOT_BUILD_TYPE = shared])
+ AM_CONDITIONAL([ARGOT_COND_BUILD_STATIC],[test $ARGOT_BUILD_TYPE = static])
+
+ AC_CONFIG_FILES(argotdir[Makefile]
+ argotdir[include/Makefile]
+ argotdir[include/argot/Makefile]
+ argotdir[include/argot/types.h]:argotdir[include/argot/types.h.in])
+ m4_popdef([argotdir])
+])

Return to:

Send suggestions and report system problems to the System administrator.