Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
divert(-1) -*- Autoconf -*-
|
|
|
|
# This file is part of Autoconf.
|
|
|
|
# Base m4 layer.
|
|
|
|
# Requires GNU m4.
|
2000-05-11 22:29:00 +08:00
|
|
|
# Copyright (C) 1999, 2000 Free Software Foundation, Inc.
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
#
|
|
|
|
# This program 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 2, or (at your option)
|
|
|
|
# any later version.
|
|
|
|
#
|
|
|
|
# This program 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 this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
# 02111-1307, USA.
|
|
|
|
#
|
|
|
|
# As a special exception, the Free Software Foundation gives unlimited
|
|
|
|
# permission to copy, distribute and modify the configure scripts that
|
|
|
|
# are the output of Autoconf. You need not follow the terms of the GNU
|
|
|
|
# General Public License when using or distributing such scripts, even
|
|
|
|
# though portions of the text of Autoconf appear in them. The GNU
|
|
|
|
# General Public License (GPL) does govern all other use of the material
|
|
|
|
# that constitutes the Autoconf program.
|
|
|
|
#
|
|
|
|
# Certain portions of the Autoconf source text are designed to be copied
|
|
|
|
# (in certain cases, depending on the input) into the output of
|
|
|
|
# Autoconf. We call these the "data" portions. The rest of the Autoconf
|
|
|
|
# source text consists of comments plus executable code that decides which
|
|
|
|
# of the data portions to output in any given case. We call these
|
|
|
|
# comments and executable code the "non-data" portions. Autoconf never
|
|
|
|
# copies any of the non-data portions into its output.
|
|
|
|
#
|
|
|
|
# This special exception to the GPL applies to versions of Autoconf
|
|
|
|
# released by the Free Software Foundation. When you make and
|
|
|
|
# distribute a modified version of Autoconf, you may extend this special
|
|
|
|
# exception to the GPL to apply to your modified version as well, *unless*
|
|
|
|
# your modified version has the potential to copy into its output some
|
|
|
|
# of the text that was the non-data portion of the version that you started
|
|
|
|
# with. (In other words, unless your change moves or copies text from
|
|
|
|
# the non-data portions to the data portions.) If your modification has
|
|
|
|
# such potential, you must delete any notice of this special exception
|
|
|
|
# to the GPL from your modified version.
|
|
|
|
#
|
|
|
|
# Written by Akim Demaille.
|
|
|
|
#
|
|
|
|
|
2000-05-11 22:29:00 +08:00
|
|
|
# Set the quotes, whatever the current quoting system.
|
|
|
|
changequote()
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
changequote([, ])
|
|
|
|
|
|
|
|
# Some old m4's don't support m4exit. But they provide
|
|
|
|
# equivalent functionality by core dumping because of the
|
|
|
|
# long macros we define.
|
|
|
|
ifdef([__gnu__], ,
|
|
|
|
[errprint(Autoconf requires GNU m4. Install it before installing Autoconf or
|
|
|
|
set the M4 environment variable to its path name.)
|
|
|
|
m4exit(2)])
|
|
|
|
|
2000-02-08 19:20:57 +08:00
|
|
|
|
Improve support of name spaces in libm4. Put the m4 builtins
in the `libm4' name space.
* libm4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_undefine): Private copies in the global name space. Used by
the name space mechanisms.
(m4_namespace_register): New macro.
(m4_namespace_define): Use it.
(builtin, changequote, defn, dnl, esyscmd, ifdef, ifelse, indir,
patsubst, popdef, pushdef, regexp, undefine, syscmd, sysval): Put
in the `libm4' name space.
(m4_disable, m4_enable): Use the private m4_indir, otherwise once
`libm4' closed, there is no `indir' available, and therefore no
means to reopen a name space.
2000-02-08 21:11:21 +08:00
|
|
|
## --------------------------------- ##
|
|
|
|
## Defining macros and name spaces. ##
|
|
|
|
## --------------------------------- ##
|
2000-02-08 19:20:57 +08:00
|
|
|
|
|
|
|
# m4_rename(SRC, DST)
|
|
|
|
# -------------------
|
|
|
|
#
|
|
|
|
# Rename the macro SRC as DST.
|
|
|
|
define([m4_rename],
|
Get rid of the m4 name spaces.
* libm4.m4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_popdef, m4_pushdef, m4_undefine, m4_namespace_push,
m4_namespace_pop, m4_namespace_register, m4_namespace_define,
m4_disable, m4_enable): Removed.
All dependencies adjusted.
* libm4.m4: Remove all the name space initialization.
* acgeneral.m4: Adjust.
(AU_DEFINE): Redefine as `AC_DEFUN'.
* autoupdate.m4: Adjust.
* tests/tools.m4: Temporarily disable the `autoupdate' test.
2000-05-11 21:28:47 +08:00
|
|
|
[define([$2], defn([$1]))undefine([$1])])
|
2000-02-08 19:20:57 +08:00
|
|
|
|
2000-02-08 21:43:58 +08:00
|
|
|
# Some m4 internals have names colliding with tokens we might use.
|
|
|
|
# Rename them a` la `m4 --prefix-builtins'.
|
2000-05-19 20:55:42 +08:00
|
|
|
m4_rename([eval], [m4_eval])
|
|
|
|
m4_rename([format], [m4_format])
|
|
|
|
m4_rename([shift], [m4_shift])
|
|
|
|
m4_rename([symbols], [m4_symbols])
|
2000-02-08 19:20:57 +08:00
|
|
|
|
|
|
|
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
## --------------------------------------------- ##
|
|
|
|
## Move some m4 builtins to a safer name space. ##
|
|
|
|
## --------------------------------------------- ##
|
|
|
|
|
|
|
|
# m4_errprint(MSG)
|
|
|
|
# ----------------
|
|
|
|
# Same as `errprint', but reports the file and line.
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_errprint], [errprint(__file__:__line__: [$1
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
])])
|
|
|
|
|
|
|
|
|
|
|
|
# m4_warn(MSG)
|
|
|
|
# ------------
|
|
|
|
# Warn the user.
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_warn], [m4_errprint([warning: $1])])
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
# m4_fatal(MSG, [EXIT-STATUS])
|
|
|
|
# ----------------------------
|
|
|
|
# Fatal the user. :)
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_fatal],
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
[m4_errprint([error: $1])dnl
|
|
|
|
m4exit(ifelse([$2],, 1, [$2]))])
|
|
|
|
|
Get rid of the m4 name spaces.
* libm4.m4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_popdef, m4_pushdef, m4_undefine, m4_namespace_push,
m4_namespace_pop, m4_namespace_register, m4_namespace_define,
m4_disable, m4_enable): Removed.
All dependencies adjusted.
* libm4.m4: Remove all the name space initialization.
* acgeneral.m4: Adjust.
(AU_DEFINE): Redefine as `AC_DEFUN'.
* autoupdate.m4: Adjust.
* tests/tools.m4: Temporarily disable the `autoupdate' test.
2000-05-11 21:28:47 +08:00
|
|
|
|
2000-03-16 23:17:26 +08:00
|
|
|
# m4_assert( EXPRESSION [, EXIT-STATUS = 1 ])
|
|
|
|
# ------------------------------------------
|
|
|
|
# This macro ensures that EXPRESSION evaluates to true, and exits if
|
|
|
|
# EXPRESSION evaluates to false.
|
|
|
|
define([m4_assert],
|
|
|
|
[ifelse(m4_eval([$1]), 0,
|
|
|
|
[m4_fatal([assert failed: $1], [$2])],
|
|
|
|
[])])
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
|
Get rid of the m4 name spaces.
* libm4.m4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_popdef, m4_pushdef, m4_undefine, m4_namespace_push,
m4_namespace_pop, m4_namespace_register, m4_namespace_define,
m4_disable, m4_enable): Removed.
All dependencies adjusted.
* libm4.m4: Remove all the name space initialization.
* acgeneral.m4: Adjust.
(AU_DEFINE): Redefine as `AC_DEFUN'.
* autoupdate.m4: Adjust.
* tests/tools.m4: Temporarily disable the `autoupdate' test.
2000-05-11 21:28:47 +08:00
|
|
|
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
# We also want to neutralize include (and sinclude for symmetry),
|
|
|
|
# but we want to extend them slightly: warn when a file is included
|
|
|
|
# several times. This is in general a dangerous operation because
|
|
|
|
# quite nobody quotes the first argument of define.
|
|
|
|
#
|
|
|
|
# For instance in the following case:
|
|
|
|
# define(foo, [bar])
|
|
|
|
# then a second reading will turn into
|
|
|
|
# define(bar, [bar])
|
|
|
|
# which is certainly not what was meant.
|
|
|
|
|
|
|
|
# m4_include_unique(FILE)
|
|
|
|
# -----------------------
|
|
|
|
# Declare that the FILE was loading; and warn if it has already
|
|
|
|
# been included.
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_include_unique],
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
[ifdef([m4_include($1)],
|
|
|
|
[m4_warn([file `$1' included several times])])dnl
|
|
|
|
define([m4_include($1)])])
|
|
|
|
|
|
|
|
|
|
|
|
# m4_include(FILE)
|
|
|
|
# ----------------
|
|
|
|
# As the builtin include, but warns against multiple inclusions.
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_include],
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
[m4_include_unique([$1])dnl
|
|
|
|
builtin([include], [$1])])
|
|
|
|
|
|
|
|
|
|
|
|
# m4_sinclude(FILE)
|
|
|
|
# -----------------
|
|
|
|
# As the builtin sinclude, but warns against multiple inclusions.
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_sinclude],
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
[m4_include_unique([$1])dnl
|
|
|
|
builtin([sinclude], [$1])])
|
|
|
|
|
|
|
|
# Neutralize include and sinclude.
|
|
|
|
undefine([include])
|
|
|
|
undefine([sinclude])
|
|
|
|
|
|
|
|
|
|
|
|
## --------------------------------------- ##
|
|
|
|
## Some additional m4 structural control. ##
|
|
|
|
## --------------------------------------- ##
|
|
|
|
|
|
|
|
# Both `ifval' and `ifset' tests against the empty string. The
|
|
|
|
# difference is that `ifset' is specialized on macros.
|
|
|
|
#
|
|
|
|
# In case of arguments of macros, eg $[1], it makes little difference.
|
|
|
|
# In the case of a macro `FOO', you don't want to check `ifval(FOO,
|
|
|
|
# TRUE)', because if `FOO' expands with commas, there is a shifting of
|
|
|
|
# the arguments. So you want to run `ifval([FOO])', but then you just
|
|
|
|
# compare the *string* `FOO' against `', which, of course fails.
|
|
|
|
#
|
|
|
|
# So you want a variation of `ifset' that expects a macro name as $[1].
|
|
|
|
# If this macro is both defined and defined to a non empty value, then
|
|
|
|
# it runs TRUE etc.
|
|
|
|
|
|
|
|
|
2000-03-14 01:52:26 +08:00
|
|
|
# ifval(COND, [IF-TRUE], [IF-FALSE])
|
|
|
|
# ----------------------------------
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
# If COND is not the empty string, expand IF-TRUE, otherwise IF-FALSE.
|
|
|
|
# Comparable to ifdef.
|
|
|
|
define([ifval], [ifelse([$1],[],[$3],[$2])])
|
|
|
|
|
|
|
|
|
2000-03-14 01:52:26 +08:00
|
|
|
# ifset(MACRO, [IF-TRUE], [IF-FALSE])
|
|
|
|
# -----------------------------------
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
# If MACRO has no definition, or of its definition is the empty string,
|
|
|
|
# expand IF-FALSE, otherwise IF-TRUE.
|
|
|
|
define([ifset],
|
|
|
|
[ifdef([$1],
|
|
|
|
[ifelse(defn([$1]), [], [$3], [$2])],
|
|
|
|
[$3])])
|
|
|
|
|
|
|
|
|
2000-03-14 01:52:26 +08:00
|
|
|
# ifndef(NAME, [IF-NOT-DEFINED], [IF-DEFINED])
|
|
|
|
# --------------------------------------------
|
|
|
|
define([ifndef],
|
|
|
|
[ifdef([$1], [$3], [$2])])
|
|
|
|
|
|
|
|
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
# m4_default(EXP1, EXP2)
|
|
|
|
# ----------------------
|
|
|
|
# Returns EXP1 if non empty, otherwise EXP2.
|
|
|
|
define([m4_default], [ifval([$1], [$1], [$2])])
|
|
|
|
|
|
|
|
|
2000-03-16 23:17:26 +08:00
|
|
|
# m4_shiftn( N, ... )
|
|
|
|
# -------------------
|
|
|
|
# Returns ... shifted N times. Useful for recursive "varargs" constructs.
|
|
|
|
define([m4_shiftn],
|
|
|
|
[m4_assert(($1 >= 0) && ($# > $1))dnl
|
|
|
|
_m4_shiftn($@)])
|
|
|
|
|
|
|
|
define([_m4_shiftn],
|
|
|
|
[ifelse([$1], 0,
|
|
|
|
[m4_shift($@)],
|
|
|
|
[_m4_shiftn(m4_eval([$1]-1), m4_shift(m4_shift($@)))])])
|
|
|
|
|
|
|
|
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
# m4_case(SWITCH, VAL1, IF-VAL1, VAL2, IF-VAL2, ..., DEFAULT)
|
|
|
|
# -----------------------------------------------------------
|
|
|
|
# m4 equivalent of
|
|
|
|
# switch (SWITCH)
|
|
|
|
# {
|
|
|
|
# case VAL1:
|
|
|
|
# IF-VAL1;
|
|
|
|
# break;
|
|
|
|
# case VAL2:
|
|
|
|
# IF-VAL2;
|
|
|
|
# break;
|
|
|
|
# ...
|
|
|
|
# default:
|
|
|
|
# DEFAULT;
|
|
|
|
# break;
|
|
|
|
# }.
|
|
|
|
# All the values are optional, and the macro is robust to active
|
|
|
|
# symbols properly quoted.
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_case],
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
[ifelse([$#], 0, [],
|
|
|
|
[$#], 1, [],
|
|
|
|
[$#], 2, [$2],
|
|
|
|
[$1], [$2], [$3],
|
2000-03-16 23:17:26 +08:00
|
|
|
[m4_case([$1], m4_shiftn(3, $@))])])
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
# m4_match(SWITCH, RE1, VAL1, RE2, VAL2, ..., DEFAULT)
|
|
|
|
# ----------------------------------------------------
|
|
|
|
# m4 equivalent of
|
|
|
|
#
|
|
|
|
# if (SWITCH =~ RE1)
|
|
|
|
# VAL1;
|
|
|
|
# elif (SWITCH =~ RE2)
|
|
|
|
# VAL2;
|
|
|
|
# elif ...
|
|
|
|
# ...
|
|
|
|
# else
|
|
|
|
# DEFAULT
|
|
|
|
#
|
|
|
|
# All the values are optional, and the macro is robust to active symbols
|
|
|
|
# properly quoted.
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_match],
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
[ifelse([$#], 0, [],
|
|
|
|
[$#], 1, [],
|
|
|
|
[$#], 2, [$2],
|
2000-03-16 23:17:26 +08:00
|
|
|
regexp([$1], [$2]), -1, [m4_match([$1], m4_shiftn(3, $@))],
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
[$3])])
|
|
|
|
|
2000-03-24 00:14:57 +08:00
|
|
|
# m4_do(STRING, ...)
|
|
|
|
# ------------------
|
|
|
|
# This macro invokes all its arguments (in sequence, of course). It is
|
|
|
|
# useful for making your macros more structured and readable by dropping
|
|
|
|
# unecessary dnl's and have the macros indented properly.
|
|
|
|
|
|
|
|
define([m4_do],
|
|
|
|
[ifelse($#, 0, [],
|
|
|
|
$#, 1, [$1],
|
|
|
|
[$1[]m4_do(m4_shift($@))])])
|
|
|
|
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
## --------------------- ##
|
|
|
|
## Implementing m4 loops ##
|
|
|
|
## --------------------- ##
|
|
|
|
|
|
|
|
|
2000-03-16 23:17:26 +08:00
|
|
|
# m4_for(VARIABLE, FIRST, LAST, [STEP = +/-1], EXPRESSION)
|
2000-02-08 16:41:52 +08:00
|
|
|
# --------------------------------------
|
|
|
|
# Expand EXPRESSION defining VARIABLE to FROM, FROM + 1, ..., TO.
|
|
|
|
# Both limits are included.
|
2000-03-16 23:17:26 +08:00
|
|
|
|
2000-02-08 16:41:52 +08:00
|
|
|
define([m4_for],
|
2000-03-16 23:17:26 +08:00
|
|
|
[m4_case(m4_sign(m4_eval($3 - $2)),
|
|
|
|
1, [m4_assert(m4_sign(m4_default($4, 1)) == 1)],
|
|
|
|
-1, [m4_assert(m4_sign(m4_default($4, -1)) == -1)])dnl
|
|
|
|
pushdef([$1], [$2])dnl
|
|
|
|
ifelse(m4_eval([$3 > $2]), 1,
|
|
|
|
[_m4_for([$1], [$3], m4_default([$4], 1), [$5])],
|
|
|
|
[_m4_for([$1], [$3], m4_default([$4], -1), [$5])])dnl
|
|
|
|
popdef([$1])])
|
2000-02-08 16:41:52 +08:00
|
|
|
|
|
|
|
define([_m4_for],
|
2000-03-16 23:17:26 +08:00
|
|
|
[$4[]dnl
|
|
|
|
ifelse($1, [$2], [],
|
Get rid of the m4 name spaces.
* libm4.m4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_popdef, m4_pushdef, m4_undefine, m4_namespace_push,
m4_namespace_pop, m4_namespace_register, m4_namespace_define,
m4_disable, m4_enable): Removed.
All dependencies adjusted.
* libm4.m4: Remove all the name space initialization.
* acgeneral.m4: Adjust.
(AU_DEFINE): Redefine as `AC_DEFUN'.
* autoupdate.m4: Adjust.
* tests/tools.m4: Temporarily disable the `autoupdate' test.
2000-05-11 21:28:47 +08:00
|
|
|
[define([$1], m4_eval($1+[$3]))_m4_for([$1], [$2], [$3], [$4])])])
|
2000-02-08 16:41:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
# Implementing `foreach' loops in m4 is much more tricky than it may
|
|
|
|
# seem. Actually, the example of a `foreach' loop in the m4
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
# documentation is wrong: it does not quote the arguments properly,
|
|
|
|
# which leads to undesired expansions.
|
|
|
|
#
|
|
|
|
# The example in the documentation is:
|
|
|
|
#
|
2000-05-11 00:16:31 +08:00
|
|
|
# | # foreach(VAR, (LIST), STMT)
|
|
|
|
# | define([foreach],
|
|
|
|
# | [pushdef([$1])_foreach([$1], [$2], [$3])popdef([$1])])
|
|
|
|
# | define([_arg1], [$1])
|
|
|
|
# | define([_foreach],
|
|
|
|
# | [ifelse([$2], [()], ,
|
|
|
|
# | [define([$1], _arg1$2)$3[]_foreach([$1],
|
|
|
|
# | (shift$2),
|
|
|
|
# | [$3])])])
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
#
|
|
|
|
# But then if you run
|
|
|
|
#
|
|
|
|
# | define(a, 1)
|
|
|
|
# | define(b, 2)
|
|
|
|
# | define(c, 3)
|
2000-05-11 00:16:31 +08:00
|
|
|
# | foreach([f], [([a], [(b], [c)])], [echo f
|
|
|
|
# | ])
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
#
|
|
|
|
# it gives
|
|
|
|
#
|
|
|
|
# => echo 1
|
|
|
|
# => echo (2,3)
|
|
|
|
#
|
|
|
|
# which is not what is expected.
|
|
|
|
#
|
2000-05-11 00:16:31 +08:00
|
|
|
# Of course the problem is that many quotes are missing. So you add
|
|
|
|
# plenty of quotes at random places, until you reach the expected
|
|
|
|
# result. Alternatively, if you are a quoting wizard, you directly
|
|
|
|
# reach the following implementation (but if you really did, then
|
|
|
|
# apply to the maintenance of libm4!).
|
|
|
|
#
|
|
|
|
# | # foreach(VAR, (LIST), STMT)
|
|
|
|
# | define([foreach], [pushdef([$1])_foreach($@)popdef([$1])])
|
|
|
|
# | define([_arg1], [[$1]])
|
|
|
|
# | define([_foreach],
|
|
|
|
# | [ifelse($2, [()], ,
|
|
|
|
# | [define([$1], [_arg1$2])$3[]_foreach([$1],
|
|
|
|
# | [(shift$2)],
|
|
|
|
# | [$3])])])
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
#
|
|
|
|
# which this time answers
|
|
|
|
#
|
|
|
|
# => echo a
|
|
|
|
# => echo (b
|
|
|
|
# => echo c)
|
|
|
|
#
|
|
|
|
# Bingo!
|
2000-05-11 00:16:31 +08:00
|
|
|
#
|
|
|
|
# Well, not quite.
|
|
|
|
#
|
|
|
|
# With a better look, you realize that the parens are more a pain than
|
|
|
|
# a help: since anyway you need to quote properly the list, you end up
|
|
|
|
# with always using an outermost pair of parens and an outermost pair
|
|
|
|
# of quotes. Rejecting the parens both eases the implementation, and
|
|
|
|
# simplifies the use:
|
|
|
|
#
|
|
|
|
# | # foreach(VAR, (LIST), STMT)
|
|
|
|
# | define([foreach], [pushdef([$1])_foreach($@)popdef([$1])])
|
|
|
|
# | define([_arg1], [$1])
|
|
|
|
# | define([_foreach],
|
|
|
|
# | [ifelse($2, [], ,
|
|
|
|
# | [define([$1], [_arg1($2)])$3[]_foreach([$1],
|
|
|
|
# | [shift($2)],
|
|
|
|
# | [$3])])])
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Now, just replace the `$2' with `m4_quote($2)' in the outer `ifelse'
|
|
|
|
# to improve robustness, and you come up with a quite satisfactory
|
|
|
|
# implementation.
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
# m4_foreach(VARIABLE, LIST, EXPRESSION)
|
|
|
|
# --------------------------------------
|
2000-05-11 00:16:31 +08:00
|
|
|
#
|
|
|
|
# Expand EXPRESSION assigning each value of the LIST to VARIABLE.
|
|
|
|
# LIST should have the form `item_1, item_2, ..., item_n', i.e. the
|
|
|
|
# whole list must *quoted*. Quote members too if you don't want them
|
|
|
|
# to be expanded.
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
#
|
|
|
|
# This macro is robust to active symbols:
|
2000-05-11 00:16:31 +08:00
|
|
|
# | define(active, [ACT, IVE])
|
|
|
|
# | m4_foreach(Var, [active, active], [-Var-])
|
|
|
|
# => -ACT--IVE--ACT--IVE-
|
|
|
|
#
|
|
|
|
# | m4_foreach(Var, [[active], [active]], [-Var-])
|
|
|
|
# => -ACT, IVE--ACT, IVE-
|
|
|
|
#
|
|
|
|
# | m4_foreach(Var, [[[active]], [[active]]], [-Var-])
|
|
|
|
# => -active--active-
|
|
|
|
define([m4_foreach],
|
|
|
|
[pushdef([$1])_m4_foreach($@)popdef([$1])])
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
|
2000-02-08 19:20:57 +08:00
|
|
|
# Low level macros used to define m4_foreach.
|
2000-05-11 00:16:31 +08:00
|
|
|
define([m4_car], [$1])
|
|
|
|
define([_m4_foreach],
|
|
|
|
[ifelse(m4_quote($2), [], [],
|
Get rid of the m4 name spaces.
* libm4.m4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_popdef, m4_pushdef, m4_undefine, m4_namespace_push,
m4_namespace_pop, m4_namespace_register, m4_namespace_define,
m4_disable, m4_enable): Removed.
All dependencies adjusted.
* libm4.m4: Remove all the name space initialization.
* acgeneral.m4: Adjust.
(AU_DEFINE): Redefine as `AC_DEFUN'.
* autoupdate.m4: Adjust.
* tests/tools.m4: Temporarily disable the `autoupdate' test.
2000-05-11 21:28:47 +08:00
|
|
|
[define([$1], [m4_car($2)])$3[]_m4_foreach([$1],
|
|
|
|
[m4_shift($2)],
|
|
|
|
[$3])])])
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
|
|
|
|
|
2000-02-09 19:59:24 +08:00
|
|
|
## ----------------- ##
|
|
|
|
## Text processing. ##
|
|
|
|
## ----------------- ##
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
|
2000-03-09 00:13:32 +08:00
|
|
|
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
# m4_quote(STRING)
|
|
|
|
# ----------------
|
|
|
|
# Return STRING quoted.
|
|
|
|
#
|
|
|
|
# It is important to realize the difference between `quote(exp)' and
|
|
|
|
# `[exp]': in the first case you obtain the quoted *result* of the
|
|
|
|
# expansion of EXP, while in the latter you just obtain the string
|
|
|
|
# `exp'.
|
2000-03-09 00:13:32 +08:00
|
|
|
define([m4_quote], [[$*]])
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
|
|
|
|
|
2000-03-03 01:11:31 +08:00
|
|
|
# m4_noquote(STRING)
|
|
|
|
# ------------------
|
|
|
|
# Return the result of ignoring all quotes in STRING and invoking the
|
|
|
|
# macros it contains. Amongst other things useful for enabling macro
|
|
|
|
# invocations inside strings with [] blocks (for instance regexps and
|
|
|
|
# help-strings).
|
|
|
|
define([m4_noquote],
|
|
|
|
[changequote(-=<{,}>=-)$1-=<{}>=-changequote([,])])
|
|
|
|
|
|
|
|
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
# m4_split(STRING, [REGEXP])
|
|
|
|
# --------------------------
|
2000-02-08 21:53:32 +08:00
|
|
|
#
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
# Split STRING into an m4 list of quoted elements. The elements are
|
|
|
|
# quoted with [ and ]. Beginning spaces and end spaces *are kept*.
|
|
|
|
# Use m4_strip to remove them.
|
|
|
|
#
|
|
|
|
# REGEXP specifies where to split. Default is [\t ]+.
|
2000-02-08 21:53:32 +08:00
|
|
|
#
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
# Pay attention to the changequotes. Inner changequotes exist for
|
|
|
|
# obvious reasons (we want to insert square brackets). Outer
|
|
|
|
# changequotes are needed because otherwise the m4 parser, when it
|
|
|
|
# sees the closing bracket we add to the result, believes it is the
|
Get rid of the m4 name spaces.
* libm4.m4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_popdef, m4_pushdef, m4_undefine, m4_namespace_push,
m4_namespace_pop, m4_namespace_register, m4_namespace_define,
m4_disable, m4_enable): Removed.
All dependencies adjusted.
* libm4.m4: Remove all the name space initialization.
* acgeneral.m4: Adjust.
(AU_DEFINE): Redefine as `AC_DEFUN'.
* autoupdate.m4: Adjust.
* tests/tools.m4: Temporarily disable the `autoupdate' test.
2000-05-11 21:28:47 +08:00
|
|
|
# end of the body of the macro we define.
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
#
|
2000-02-08 21:53:32 +08:00
|
|
|
# Also, notice that $1 is quoted twice, since we want the result to
|
|
|
|
# be quoted. Then you should understand that the argument of
|
|
|
|
# patsubst is ``STRING'' (i.e., with additional `` and '').
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
#
|
|
|
|
# This macro is safe on active symbols, i.e.:
|
|
|
|
# define(active, ACTIVE)
|
|
|
|
# m4_split([active active ])end
|
|
|
|
# => [active], [active], []end
|
2000-02-08 21:53:32 +08:00
|
|
|
|
|
|
|
changequote(<<, >>)
|
Get rid of the m4 name spaces.
* libm4.m4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_popdef, m4_pushdef, m4_undefine, m4_namespace_push,
m4_namespace_pop, m4_namespace_register, m4_namespace_define,
m4_disable, m4_enable): Removed.
All dependencies adjusted.
* libm4.m4: Remove all the name space initialization.
* acgeneral.m4: Adjust.
(AU_DEFINE): Redefine as `AC_DEFUN'.
* autoupdate.m4: Adjust.
* tests/tools.m4: Temporarily disable the `autoupdate' test.
2000-05-11 21:28:47 +08:00
|
|
|
define(<<m4_split>>,
|
2000-02-08 21:53:32 +08:00
|
|
|
<<changequote(``, '')dnl
|
|
|
|
[dnl Can't use m4_default here instead of ifelse, because m4_default uses
|
|
|
|
dnl [ and ] as quotes.
|
|
|
|
patsubst(````$1'''',
|
2000-03-16 23:17:26 +08:00
|
|
|
ifelse(``$2'',, ``[ ]+'', ``$2''),
|
2000-02-08 21:53:32 +08:00
|
|
|
``], ['')]dnl
|
|
|
|
changequote([, ])>>)
|
|
|
|
changequote([, ])
|
|
|
|
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
# m4_join(STRING)
|
|
|
|
# ---------------
|
|
|
|
# If STRING contains end of lines, replace them with spaces. If there
|
|
|
|
# are backslashed end of lines, remove them. This macro is safe with
|
|
|
|
# active symbols.
|
|
|
|
# define(active, ACTIVE)
|
|
|
|
# m4_join([active
|
|
|
|
# act\
|
|
|
|
# ive])end
|
|
|
|
# => active activeend
|
|
|
|
define([m4_join],
|
|
|
|
[translit(patsubst([[[$1]]], [\\
|
|
|
|
]), [
|
|
|
|
], [ ])])
|
|
|
|
|
|
|
|
|
|
|
|
# m4_strip(STRING)
|
|
|
|
# ----------------
|
|
|
|
# Expands into STRING with tabs and spaces singled out into a single
|
|
|
|
# space, and removing leading and trailing spaces.
|
|
|
|
#
|
|
|
|
# This macro is robust to active symbols.
|
|
|
|
# define(active, ACTIVE)
|
|
|
|
# m4_strip([ active active ])end
|
|
|
|
# => active activeend
|
|
|
|
#
|
|
|
|
# This macro is fun! Because we want to preserve active symbols, STRING
|
|
|
|
# must be quoted for each evaluation, which explains there are 4 levels
|
|
|
|
# of brackets around $1 (don't forget that the result must be quoted
|
|
|
|
# too, hence one more quoting than applications).
|
|
|
|
#
|
|
|
|
# Then notice the patsubst of the middle: it is in charge of removing
|
|
|
|
# the leading space. Why not just `patsubst(..., [^ ])'? Because this
|
|
|
|
# macro will receive the output of the preceding patsubst, i.e. more or
|
|
|
|
# less [[STRING]]. So if there is a leading space in STRING, then it is
|
|
|
|
# the *third* character, since there are two leading `['; Equally for
|
|
|
|
# the outer patsubst.
|
|
|
|
define([m4_strip],
|
|
|
|
[patsubst(patsubst(patsubst([[[[$1]]]],
|
|
|
|
[[ ]+], [ ]),
|
|
|
|
[^\(..\) ], [\1]),
|
|
|
|
[ \(.\)$], [\1])])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# m4_append(MACRO-NAME, STRING)
|
|
|
|
# -----------------------------
|
|
|
|
# Redefine MACRO-NAME to hold its former content plus STRING at the
|
|
|
|
# end. It is valid to use this macro with MACRO-NAME undefined.
|
|
|
|
#
|
|
|
|
# This macro is robust to active symbols. It can be used to grow
|
|
|
|
# strings.
|
|
|
|
#
|
|
|
|
# | define(active, ACTIVE)
|
|
|
|
# | m4_append([sentence], [This is an])
|
|
|
|
# | m4_append([sentence], [ active ])
|
|
|
|
# | m4_append([sentence], [symbol.])
|
|
|
|
# | sentence
|
|
|
|
# | undefine([active])dnl
|
|
|
|
# | sentence
|
|
|
|
# => This is an ACTIVE symbol.
|
|
|
|
# => This is an active symbol.
|
|
|
|
#
|
|
|
|
# It can be used to define hooks.
|
|
|
|
#
|
|
|
|
# | define(active, ACTIVE)
|
|
|
|
# | m4_append([hooks], [define([act1], [act2])])
|
|
|
|
# | m4_append([hooks], [define([act2], [active])])
|
|
|
|
# | undefine([active])
|
|
|
|
# | act1
|
|
|
|
# | hooks
|
|
|
|
# | act1
|
|
|
|
# => act1
|
|
|
|
# =>
|
|
|
|
# => active
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_append],
|
Get rid of the m4 name spaces.
* libm4.m4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_popdef, m4_pushdef, m4_undefine, m4_namespace_push,
m4_namespace_pop, m4_namespace_register, m4_namespace_define,
m4_disable, m4_enable): Removed.
All dependencies adjusted.
* libm4.m4: Remove all the name space initialization.
* acgeneral.m4: Adjust.
(AU_DEFINE): Redefine as `AC_DEFUN'.
* autoupdate.m4: Adjust.
* tests/tools.m4: Temporarily disable the `autoupdate' test.
2000-05-11 21:28:47 +08:00
|
|
|
[define([$1],
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
ifdef([$1], [defn([$1])])[$2])])
|
|
|
|
|
|
|
|
|
|
|
|
# m4_list_append(MACRO-NAME, STRING)
|
|
|
|
# ----------------------------------
|
|
|
|
# Same as `m4_append', but each element is separated by `, '.
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_list_append],
|
Get rid of the m4 name spaces.
* libm4.m4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_popdef, m4_pushdef, m4_undefine, m4_namespace_push,
m4_namespace_pop, m4_namespace_register, m4_namespace_define,
m4_disable, m4_enable): Removed.
All dependencies adjusted.
* libm4.m4: Remove all the name space initialization.
* acgeneral.m4: Adjust.
(AU_DEFINE): Redefine as `AC_DEFUN'.
* autoupdate.m4: Adjust.
* tests/tools.m4: Temporarily disable the `autoupdate' test.
2000-05-11 21:28:47 +08:00
|
|
|
[define([$1],
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
ifdef([$1], [defn([$1]), ])[$2])])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-02-08 19:20:57 +08:00
|
|
|
## ----------------------------------- ##
|
|
|
|
## Helping macros to display strings. ##
|
|
|
|
## ----------------------------------- ##
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
|
2000-05-11 00:16:31 +08:00
|
|
|
# m4_foreach_quoted(VARIABLE, LIST, EXPRESSION)
|
|
|
|
# ---------------------------------------------
|
|
|
|
# FIXME: This macro should not exists. Currently it's used only in
|
|
|
|
# m4_wrap, which needs to be rewritten. But it's godam hard.
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_foreach_quoted],
|
2000-05-11 00:16:31 +08:00
|
|
|
[pushdef([$1], [])_m4_foreach_quoted($@)popdef([$1])])
|
|
|
|
|
|
|
|
# Low level macros used to define m4_foreach.
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_car_quoted], [[$1]])
|
|
|
|
define([_m4_foreach_quoted],
|
2000-05-11 00:16:31 +08:00
|
|
|
[ifelse($2, [()], ,
|
Get rid of the m4 name spaces.
* libm4.m4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_popdef, m4_pushdef, m4_undefine, m4_namespace_push,
m4_namespace_pop, m4_namespace_register, m4_namespace_define,
m4_disable, m4_enable): Removed.
All dependencies adjusted.
* libm4.m4: Remove all the name space initialization.
* acgeneral.m4: Adjust.
(AU_DEFINE): Redefine as `AC_DEFUN'.
* autoupdate.m4: Adjust.
* tests/tools.m4: Temporarily disable the `autoupdate' test.
2000-05-11 21:28:47 +08:00
|
|
|
[define([$1], [m4_car_quoted$2])$3[]_m4_foreach_quoted([$1],
|
|
|
|
[(m4_shift$2)],
|
|
|
|
[$3])])])
|
2000-05-11 00:16:31 +08:00
|
|
|
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
|
|
|
|
# m4_wrap(STRING, [PREFIX], [FIRST-PREFIX], [WIDTH])
|
|
|
|
# --------------------------------------------------
|
|
|
|
# Expands into STRING wrapped to hold in WIDTH columns (default = 79).
|
|
|
|
# If prefix is set, each line is prefixed with it. If FIRST-PREFIX is
|
|
|
|
# specified, then the first line is prefixed with it. As a special
|
|
|
|
# case, if the length of the first prefix is greater than that of
|
|
|
|
# PREFIX, then FIRST-PREFIX will be left alone on the first line.
|
|
|
|
#
|
|
|
|
# Typical outputs are:
|
|
|
|
#
|
|
|
|
# m4_wrap([Short string */], [ ], [/* ], 20)
|
|
|
|
# => /* Short string */
|
|
|
|
#
|
|
|
|
# m4_wrap([Much longer string */], [ ], [/* ], 20)
|
|
|
|
# => /* Much longer
|
|
|
|
# => string */
|
|
|
|
#
|
|
|
|
# m4_wrap([Short doc.], [ ], [ --short ], 30)
|
|
|
|
# => --short Short doc.
|
|
|
|
#
|
|
|
|
# m4_wrap([Short doc.], [ ], [ --too-wide ], 30)
|
|
|
|
# => --too-wide
|
|
|
|
# => Short doc.
|
|
|
|
#
|
|
|
|
# m4_wrap([Super long documentation.], [ ], [ --too-wide ], 30)
|
|
|
|
# => --too-wide
|
|
|
|
# => Super long
|
|
|
|
# => documentation.
|
|
|
|
#
|
|
|
|
# FIXME: there is no checking of a longer PREFIX than WIDTH, but do
|
|
|
|
# we really want to bother with people trying each single corner
|
|
|
|
# of a software?
|
|
|
|
#
|
|
|
|
# This macro does not leave a trailing space behind the last word,
|
|
|
|
# what complicates it a bit. The algorithm is stupid simple: all the
|
|
|
|
# words are preceded by m4_Separator which is defined to empty for the
|
|
|
|
# first word, and then ` ' (single space) for all the others.
|
|
|
|
define([m4_wrap],
|
|
|
|
[pushdef([m4_Prefix], m4_default([$2], []))dnl
|
|
|
|
pushdef([m4_Prefix1], m4_default([$3], [m4_Prefix]))dnl
|
|
|
|
pushdef([m4_Width], m4_default([$4], 79))dnl
|
|
|
|
pushdef([m4_Cursor], len(m4_Prefix1))dnl
|
|
|
|
pushdef([m4_Separator], [])dnl
|
|
|
|
m4_Prefix1[]dnl
|
|
|
|
ifelse(m4_eval(m4_Cursor > len(m4_Prefix)),
|
|
|
|
1, [define([m4_Cursor], len(m4_Prefix))
|
|
|
|
m4_Prefix])[]dnl
|
2000-05-11 00:16:31 +08:00
|
|
|
m4_foreach_quoted([m4_Word], (m4_split(m4_strip(m4_join([$1])))),
|
Get rid of the m4 name spaces.
* libm4.m4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_popdef, m4_pushdef, m4_undefine, m4_namespace_push,
m4_namespace_pop, m4_namespace_register, m4_namespace_define,
m4_disable, m4_enable): Removed.
All dependencies adjusted.
* libm4.m4: Remove all the name space initialization.
* acgeneral.m4: Adjust.
(AU_DEFINE): Redefine as `AC_DEFUN'.
* autoupdate.m4: Adjust.
* tests/tools.m4: Temporarily disable the `autoupdate' test.
2000-05-11 21:28:47 +08:00
|
|
|
[define([m4_Cursor], m4_eval(m4_Cursor + len(m4_Word) + 1))dnl
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
dnl New line if too long, else insert a space unless it is the first
|
|
|
|
dnl of the words.
|
|
|
|
ifelse(m4_eval(m4_Cursor > m4_Width),
|
|
|
|
1, [define([m4_Cursor], m4_eval(len(m4_Prefix) + len(m4_Word) + 1))]
|
|
|
|
m4_Prefix,
|
|
|
|
[m4_Separator])[]dnl
|
|
|
|
m4_Word[]dnl
|
Get rid of the m4 name spaces.
* libm4.m4 (m4_changequote, m4_define, m4_defn, m4_dnl, m4_indir,
m4_popdef, m4_pushdef, m4_undefine, m4_namespace_push,
m4_namespace_pop, m4_namespace_register, m4_namespace_define,
m4_disable, m4_enable): Removed.
All dependencies adjusted.
* libm4.m4: Remove all the name space initialization.
* acgeneral.m4: Adjust.
(AU_DEFINE): Redefine as `AC_DEFUN'.
* autoupdate.m4: Adjust.
* tests/tools.m4: Temporarily disable the `autoupdate' test.
2000-05-11 21:28:47 +08:00
|
|
|
define([m4_Separator], [ ])])dnl
|
Create libm4.m4.
* Makefile.am: Adjusted for libm4.m4.
* acgeneral.m4 (m4_errprint, m4_warn, m4_fatal, m4_prefix,
m4_eval, m4_shift, m4_format, m4_include_unique, m4_include,
m4_sinclude, m4_quote, m4_split, m4_join, m4_strip, m4_append,
m4_list_append, ifval, ifset, m4_default, m4_case, m4_match,
m4_foreach): Moved from here, to...
* libm4.m4: here.
* acgeneral.m4 (AC_WRAP): Moved from here, to...
* libm4.m4 (m4_wrap): here. All callers changed.
* acgeneral.m4: Don't include acversion.m4.
* autoconf.m4: Include libm4.m4 and acversion.m4.
* autoheader.m4: Likewise.
2000-02-08 01:42:03 +08:00
|
|
|
popdef([m4_Separator])dnl
|
|
|
|
popdef([m4_Cursor])dnl
|
|
|
|
popdef([m4_Width])dnl
|
|
|
|
popdef([m4_Prefix1])dnl
|
|
|
|
popdef([m4_Prefix])dnl
|
|
|
|
])
|
2000-02-09 19:59:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## ------------------- ##
|
|
|
|
## Number processing. ##
|
|
|
|
## ------------------- ##
|
|
|
|
|
|
|
|
# m4_sign(A)
|
|
|
|
# ----------
|
|
|
|
#
|
|
|
|
# The sign of the integer A.
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_sign],
|
2000-02-09 19:59:24 +08:00
|
|
|
[m4_match([$1],
|
|
|
|
[^-], -1,
|
|
|
|
[^0+], 0,
|
|
|
|
1)])
|
|
|
|
|
|
|
|
# m4_cmp(A, B)
|
|
|
|
# ------------
|
|
|
|
#
|
|
|
|
# Compare two integers.
|
|
|
|
# A < B -> -1
|
|
|
|
# A = B -> 0
|
|
|
|
# A > B -> 1
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_cmp],
|
2000-02-09 19:59:24 +08:00
|
|
|
[m4_sign(m4_eval([$1 - $2]))])
|
|
|
|
|
|
|
|
|
|
|
|
# m4_list_cmp(A, B)
|
|
|
|
# -----------------
|
|
|
|
#
|
|
|
|
# Compare the two lists of integers A and B. For instance:
|
|
|
|
# m4_list_cmp((1, 0), (1)) -> 0
|
|
|
|
# m4_list_cmp((1, 0), (1, 0)) -> 0
|
|
|
|
# m4_list_cmp((1, 2), (1, 0)) -> 1
|
|
|
|
# m4_list_cmp((1, 2, 3), (1, 2)) -> 1
|
|
|
|
# m4_list_cmp((1, 2, -3), (1, 2)) -> -1
|
|
|
|
# m4_list_cmp((1, 0), (1, 2)) -> -1
|
|
|
|
# m4_list_cmp((1), (1, 2)) -> -1
|
2000-05-11 22:29:00 +08:00
|
|
|
define([m4_list_cmp],
|
2000-02-09 19:59:24 +08:00
|
|
|
[ifelse([$1$2], [()()], 0,
|
|
|
|
[$1], [()], [m4_list_cmp((0), [$2])],
|
|
|
|
[$2], [()], [m4_list_cmp([$1], (0))],
|
|
|
|
[m4_case(m4_cmp(m4_car$1, m4_car$2),
|
|
|
|
-1, -1,
|
|
|
|
1, 1,
|
|
|
|
0, [m4_list_cmp((m4_shift$1), (m4_shift$2))])])])
|