1998-09-03 08:47:24 +08:00
|
|
|
#! @SHELL@
|
1993-06-17 04:15:11 +08:00
|
|
|
# autoconf -- create `configure' using m4 macros
|
2001-03-20 02:14:44 +08:00
|
|
|
# Copyright 1992, 1993, 1994, 1996, 1999, 2000, 2001
|
2000-10-17 02:25:55 +08:00
|
|
|
# Free Software Foundation, Inc.
|
1993-06-17 04:15:11 +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
|
1996-06-13 01:55:25 +08:00
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
# 02111-1307, USA.
|
1993-06-17 04:15:11 +08:00
|
|
|
|
2001-03-30 20:49:36 +08:00
|
|
|
me=`echo "$0" | sed -e 's,.*[\\/],,'`
|
2000-02-08 19:39:46 +08:00
|
|
|
|
1994-05-05 01:34:32 +08:00
|
|
|
usage="\
|
Provide a fine grained control over autoconf's warnings.
* acgeneral.m4 (AC_WARNING_IFELSE, _AC_DIAGNOSE, AC_DIAGNOSE):
New macros.
(AC_DEFUN_ONCE, AC_OBSOLETE, AC_BEFORE, AU_DEFUN, AC_PREREQ,
AC_WARNING, AC_FATAL, AC_TRY_RUN): Use AC_DIAGNOSE.
* autoconf.sh: Provide support for `--warnings', `-W'.
* doc/autoconf.texi (Invoking autoconf): Adjust.
(Reporting Messages): New section.
2000-04-13 16:25:11 +08:00
|
|
|
Usage: $0 [OPTION] ... [TEMPLATE-FILE]
|
1999-01-08 11:38:59 +08:00
|
|
|
|
|
|
|
Generate a configuration script from a TEMPLATE-FILE if given, or
|
2000-12-23 18:11:57 +08:00
|
|
|
\`configure.ac' if present, or else \`configure.in'. Output is sent
|
|
|
|
to the standard output if TEMPLATE-FILE is given, else into
|
|
|
|
\`configure'.
|
1999-01-08 11:38:59 +08:00
|
|
|
|
Provide a fine grained control over autoconf's warnings.
* acgeneral.m4 (AC_WARNING_IFELSE, _AC_DIAGNOSE, AC_DIAGNOSE):
New macros.
(AC_DEFUN_ONCE, AC_OBSOLETE, AC_BEFORE, AU_DEFUN, AC_PREREQ,
AC_WARNING, AC_FATAL, AC_TRY_RUN): Use AC_DIAGNOSE.
* autoconf.sh: Provide support for `--warnings', `-W'.
* doc/autoconf.texi (Invoking autoconf): Adjust.
(Reporting Messages): New section.
2000-04-13 16:25:11 +08:00
|
|
|
Operation modes:
|
|
|
|
-h, --help print this help, then exit
|
|
|
|
-V, --version print version number, then exit
|
|
|
|
-v, --verbose verbosely report processing
|
|
|
|
-d, --debug don't remove temporary files
|
|
|
|
-o, --output=FILE save output in FILE (stdout is the default)
|
2000-07-10 18:23:08 +08:00
|
|
|
-W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax]
|
Provide a fine grained control over autoconf's warnings.
* acgeneral.m4 (AC_WARNING_IFELSE, _AC_DIAGNOSE, AC_DIAGNOSE):
New macros.
(AC_DEFUN_ONCE, AC_OBSOLETE, AC_BEFORE, AU_DEFUN, AC_PREREQ,
AC_WARNING, AC_FATAL, AC_TRY_RUN): Use AC_DIAGNOSE.
* autoconf.sh: Provide support for `--warnings', `-W'.
* doc/autoconf.texi (Invoking autoconf): Adjust.
(Reporting Messages): New section.
2000-04-13 16:25:11 +08:00
|
|
|
|
|
|
|
Warning categories include:
|
2000-07-28 15:41:52 +08:00
|
|
|
\`cross' cross compilation issues
|
|
|
|
\`obsolete' obsolete constructs
|
|
|
|
\`syntax' dubious syntactic constructs
|
|
|
|
\`all' all the warnings
|
|
|
|
\`no-CATEGORY' turn off the warnings on CATEGORY
|
|
|
|
\`none' turn off all the warnings
|
|
|
|
\`error' warnings are error
|
2000-07-10 18:23:08 +08:00
|
|
|
|
|
|
|
The environment variable \`WARNINGS' is honored.
|
Provide a fine grained control over autoconf's warnings.
* acgeneral.m4 (AC_WARNING_IFELSE, _AC_DIAGNOSE, AC_DIAGNOSE):
New macros.
(AC_DEFUN_ONCE, AC_OBSOLETE, AC_BEFORE, AU_DEFUN, AC_PREREQ,
AC_WARNING, AC_FATAL, AC_TRY_RUN): Use AC_DIAGNOSE.
* autoconf.sh: Provide support for `--warnings', `-W'.
* doc/autoconf.texi (Invoking autoconf): Adjust.
(Reporting Messages): New section.
2000-04-13 16:25:11 +08:00
|
|
|
|
2000-10-27 06:27:48 +08:00
|
|
|
Library directories:
|
|
|
|
-A, --autoconf-dir=ACDIR Autoconf's macro files location (rarely needed)
|
|
|
|
-l, --localdir=DIR location of the \`aclocal.m4' file
|
|
|
|
|
Provide a fine grained control over autoconf's warnings.
* acgeneral.m4 (AC_WARNING_IFELSE, _AC_DIAGNOSE, AC_DIAGNOSE):
New macros.
(AC_DEFUN_ONCE, AC_OBSOLETE, AC_BEFORE, AU_DEFUN, AC_PREREQ,
AC_WARNING, AC_FATAL, AC_TRY_RUN): Use AC_DIAGNOSE.
* autoconf.sh: Provide support for `--warnings', `-W'.
* doc/autoconf.texi (Invoking autoconf): Adjust.
(Reporting Messages): New section.
2000-04-13 16:25:11 +08:00
|
|
|
Tracing:
|
2000-03-13 23:31:26 +08:00
|
|
|
-t, --trace=MACRO report the list of calls to MACRO
|
|
|
|
-i, --initialization also trace Autoconf's initialization process
|
Provide a fine grained control over autoconf's warnings.
* acgeneral.m4 (AC_WARNING_IFELSE, _AC_DIAGNOSE, AC_DIAGNOSE):
New macros.
(AC_DEFUN_ONCE, AC_OBSOLETE, AC_BEFORE, AU_DEFUN, AC_PREREQ,
AC_WARNING, AC_FATAL, AC_TRY_RUN): Use AC_DIAGNOSE.
* autoconf.sh: Provide support for `--warnings', `-W'.
* doc/autoconf.texi (Invoking autoconf): Adjust.
(Reporting Messages): New section.
2000-04-13 16:25:11 +08:00
|
|
|
|
|
|
|
In tracing mode, no configuration script is created.
|
1999-01-08 11:38:59 +08:00
|
|
|
|
|
|
|
Report bugs to <bug-autoconf@gnu.org>."
|
1993-06-17 04:15:11 +08:00
|
|
|
|
2000-01-10 18:11:57 +08:00
|
|
|
version="\
|
2001-01-16 18:25:57 +08:00
|
|
|
autoconf (@PACKAGE_NAME@) @VERSION@
|
2000-01-10 18:11:57 +08:00
|
|
|
Written by David J. MacKenzie.
|
|
|
|
|
2001-03-20 02:14:44 +08:00
|
|
|
Copyright 1992, 1993, 1994, 1996, 1999, 2000, 2001
|
2000-10-17 02:25:55 +08:00
|
|
|
Free Software Foundation, Inc.
|
2000-01-10 18:11:57 +08:00
|
|
|
This is free software; see the source for copying conditions. There is NO
|
|
|
|
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
|
|
|
|
2000-02-08 19:39:46 +08:00
|
|
|
help="\
|
|
|
|
Try \`$me --help' for more information."
|
|
|
|
|
2000-06-15 19:33:04 +08:00
|
|
|
exit_missing_arg="\
|
|
|
|
echo \"$me: option \\\`\$1' requires an argument\" >&2
|
|
|
|
echo \"\$help\" >&2
|
|
|
|
exit 1"
|
|
|
|
|
1993-06-25 03:57:01 +08:00
|
|
|
# NLS nuisances.
|
1994-05-05 23:49:35 +08:00
|
|
|
if test "${LANG+set}" = set; then LANG=C; export LANG; fi
|
1996-11-21 03:13:42 +08:00
|
|
|
if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
|
|
|
|
if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
|
2000-08-01 19:22:42 +08:00
|
|
|
if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
|
1993-06-25 03:57:01 +08:00
|
|
|
|
2000-01-29 17:22:53 +08:00
|
|
|
# ac_LF_and_DOT
|
|
|
|
# We use echo to avoid assuming a particular line-breaking character.
|
|
|
|
# The extra dot is to prevent the shell from consuming trailing
|
|
|
|
# line-breaks from the sub-command output. A line-break within
|
|
|
|
# single-quotes doesn't work because, if this script is created in a
|
|
|
|
# platform that uses two characters for line-breaks (e.g., DOS), tr
|
|
|
|
# would break.
|
2000-01-29 17:54:27 +08:00
|
|
|
ac_LF_and_DOT=`echo; echo .`
|
2000-01-29 17:22:53 +08:00
|
|
|
|
2000-02-08 21:12:49 +08:00
|
|
|
# Find GNU m4.
|
|
|
|
# Handle the case that m4 has moved since we were configured.
|
|
|
|
# It may have been found originally in a build directory.
|
1995-02-07 07:31:34 +08:00
|
|
|
: ${M4=@M4@}
|
2001-03-30 20:49:36 +08:00
|
|
|
case "$M4" in
|
|
|
|
[\\/]* | ?:[\\/]*) test -f "$M4" || M4=m4 ;;
|
2000-02-08 21:12:49 +08:00
|
|
|
esac
|
|
|
|
# Some non-GNU m4's don't reject the --help option, so give them /dev/null.
|
2000-03-13 23:31:26 +08:00
|
|
|
case `$M4 --help </dev/null 2>&1` in
|
2000-02-08 21:12:49 +08:00
|
|
|
*reload-state*);;
|
|
|
|
*) echo "$me: Autoconf requires GNU m4 1.4 or later" >&2; exit 1 ;;
|
1994-05-03 07:47:38 +08:00
|
|
|
esac
|
1993-06-17 04:15:11 +08:00
|
|
|
|
2000-02-08 21:12:49 +08:00
|
|
|
# Variables.
|
2000-07-19 17:03:53 +08:00
|
|
|
: ${autoconf_dir=${AC_MACRODIR=@datadir@}}
|
2000-09-25 21:24:45 +08:00
|
|
|
test -z "$AC_ACLOCALDIR" &&
|
|
|
|
AC_ACLOCALDIR=`(aclocal --print-ac-dir) 2>/dev/null`
|
2000-02-08 21:12:49 +08:00
|
|
|
: ${AWK=@AWK@}
|
2000-03-13 23:31:26 +08:00
|
|
|
debug=false
|
|
|
|
# Trace Autoconf's initialization?
|
|
|
|
initialization=false
|
2000-05-23 17:52:05 +08:00
|
|
|
localdir=.
|
2000-01-29 17:22:53 +08:00
|
|
|
outfile=
|
2000-03-14 01:28:06 +08:00
|
|
|
# Exit status.
|
|
|
|
status=0
|
2000-01-29 17:22:53 +08:00
|
|
|
# Tasks:
|
|
|
|
# - trace
|
|
|
|
# Trace the first arguments of some macros
|
|
|
|
# - script
|
|
|
|
# Produce the configure script (default)
|
|
|
|
task=script
|
2000-03-29 19:09:59 +08:00
|
|
|
tmp=
|
2000-01-29 17:54:27 +08:00
|
|
|
verbose=:
|
1994-08-01 21:44:22 +08:00
|
|
|
|
2000-05-27 01:45:10 +08:00
|
|
|
# Parse command line.
|
1993-06-17 04:15:11 +08:00
|
|
|
while test $# -gt 0 ; do
|
2000-09-19 20:35:01 +08:00
|
|
|
optarg=`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
|
|
|
|
"x$1" : 'x-.\(.*\)'`
|
2000-07-10 18:23:08 +08:00
|
|
|
case $1 in
|
2000-11-08 01:58:43 +08:00
|
|
|
--version | -V )
|
2000-02-08 21:12:49 +08:00
|
|
|
echo "$version" ; exit 0 ;;
|
2000-11-08 01:58:43 +08:00
|
|
|
--help | -h )
|
2000-01-29 17:22:53 +08:00
|
|
|
echo "$usage"; exit 0 ;;
|
2000-03-14 01:26:21 +08:00
|
|
|
|
2000-11-08 01:58:43 +08:00
|
|
|
--debug | -d )
|
2000-03-13 23:31:26 +08:00
|
|
|
debug=:; shift ;;
|
2000-11-08 01:58:43 +08:00
|
|
|
--verbose | -v )
|
2000-03-14 01:26:21 +08:00
|
|
|
verbose=echo
|
|
|
|
shift;;
|
2000-02-15 17:10:23 +08:00
|
|
|
|
2000-11-08 01:58:43 +08:00
|
|
|
--localdir=* | -l?* )
|
2000-07-10 18:23:08 +08:00
|
|
|
localdir=$optarg
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
2000-11-08 01:58:43 +08:00
|
|
|
--localdir | -l )
|
2000-06-15 19:33:04 +08:00
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
2000-01-29 17:22:53 +08:00
|
|
|
shift
|
2000-03-14 01:26:21 +08:00
|
|
|
localdir=$1
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
2000-02-15 17:10:23 +08:00
|
|
|
|
2000-11-08 01:58:43 +08:00
|
|
|
--autoconf-dir=* | -A?* )
|
2000-07-19 17:03:53 +08:00
|
|
|
autoconf_dir=$optarg
|
|
|
|
shift ;;
|
2000-11-08 01:58:43 +08:00
|
|
|
--autoconf-dir | -A )
|
2000-07-19 17:03:53 +08:00
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
|
|
|
shift
|
|
|
|
autoconf_dir=$1
|
|
|
|
shift ;;
|
2000-11-08 01:58:43 +08:00
|
|
|
--macrodir=* | -m?* )
|
2000-10-27 06:27:48 +08:00
|
|
|
echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
|
2000-07-19 17:03:53 +08:00
|
|
|
autoconf_dir=$optarg
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
2000-11-08 01:58:43 +08:00
|
|
|
--macrodir | -m )
|
2000-10-27 06:27:48 +08:00
|
|
|
echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
|
2000-06-15 19:33:04 +08:00
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
2000-01-29 17:22:53 +08:00
|
|
|
shift
|
2000-07-19 17:03:53 +08:00
|
|
|
autoconf_dir=$1
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
2000-02-15 17:10:23 +08:00
|
|
|
|
2000-11-08 01:58:43 +08:00
|
|
|
--trace=* | -t?* )
|
2000-10-27 06:27:48 +08:00
|
|
|
task=trace
|
|
|
|
traces="$traces '"`echo "$optarg" | sed "s/'/'\\\\\\\\''/g"`"'"
|
|
|
|
shift ;;
|
2000-11-08 01:58:43 +08:00
|
|
|
--trace | -t )
|
2000-06-15 19:33:04 +08:00
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
2000-01-29 17:22:53 +08:00
|
|
|
task=trace
|
|
|
|
shift
|
2000-05-03 16:53:06 +08:00
|
|
|
traces="$traces '"`echo "$1" | sed "s/'/'\\\\\\\\''/g"`"'"
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
2000-11-08 01:58:43 +08:00
|
|
|
--initialization | -i )
|
2000-03-13 23:31:26 +08:00
|
|
|
initialization=:
|
|
|
|
shift;;
|
2000-02-15 17:10:23 +08:00
|
|
|
|
2000-11-08 01:58:43 +08:00
|
|
|
--output=* | -o?* )
|
2000-10-27 06:27:48 +08:00
|
|
|
outfile=$optarg
|
|
|
|
shift ;;
|
2000-11-08 01:58:43 +08:00
|
|
|
--output | -o )
|
2000-06-15 19:33:04 +08:00
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
2000-01-29 17:22:53 +08:00
|
|
|
shift
|
2000-03-14 01:26:21 +08:00
|
|
|
outfile=$1
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
2000-02-15 17:10:23 +08:00
|
|
|
|
2000-11-08 01:58:43 +08:00
|
|
|
--warnings=* | -W?* )
|
2000-10-27 06:27:48 +08:00
|
|
|
warnings=$warnings,$optarg
|
|
|
|
shift ;;
|
2000-11-08 01:58:43 +08:00
|
|
|
--warnings | -W )
|
2000-06-15 19:33:04 +08:00
|
|
|
test $# = 1 && eval "$exit_missing_arg"
|
Provide a fine grained control over autoconf's warnings.
* acgeneral.m4 (AC_WARNING_IFELSE, _AC_DIAGNOSE, AC_DIAGNOSE):
New macros.
(AC_DEFUN_ONCE, AC_OBSOLETE, AC_BEFORE, AU_DEFUN, AC_PREREQ,
AC_WARNING, AC_FATAL, AC_TRY_RUN): Use AC_DIAGNOSE.
* autoconf.sh: Provide support for `--warnings', `-W'.
* doc/autoconf.texi (Invoking autoconf): Adjust.
(Reporting Messages): New section.
2000-04-13 16:25:11 +08:00
|
|
|
shift
|
2000-07-10 18:23:08 +08:00
|
|
|
warnings=$warnings,$1
|
Provide a fine grained control over autoconf's warnings.
* acgeneral.m4 (AC_WARNING_IFELSE, _AC_DIAGNOSE, AC_DIAGNOSE):
New macros.
(AC_DEFUN_ONCE, AC_OBSOLETE, AC_BEFORE, AU_DEFUN, AC_PREREQ,
AC_WARNING, AC_FATAL, AC_TRY_RUN): Use AC_DIAGNOSE.
* autoconf.sh: Provide support for `--warnings', `-W'.
* doc/autoconf.texi (Invoking autoconf): Adjust.
(Reporting Messages): New section.
2000-04-13 16:25:11 +08:00
|
|
|
shift ;;
|
|
|
|
|
2000-01-29 17:22:53 +08:00
|
|
|
-- ) # Stop option processing
|
|
|
|
shift; break ;;
|
|
|
|
- ) # Use stdin as input.
|
|
|
|
break ;;
|
|
|
|
-* )
|
2000-02-08 21:45:24 +08:00
|
|
|
exec >&2
|
|
|
|
echo "$me: invalid option $1"
|
|
|
|
echo "$help"
|
|
|
|
exit 1 ;;
|
2000-01-29 17:22:53 +08:00
|
|
|
* )
|
|
|
|
break ;;
|
|
|
|
esac
|
1993-06-17 04:15:11 +08:00
|
|
|
done
|
|
|
|
|
2000-07-10 18:23:08 +08:00
|
|
|
# The warnings are the concatenation of 1. application's defaults,
|
|
|
|
# 2. $WARNINGS, $3 command line options, in that order.
|
|
|
|
# Set them in the order expected by the M4 macros: the converse.
|
2000-08-01 19:22:42 +08:00
|
|
|
alphabet='abcdefghijklmnopqrstuvwxyz'
|
|
|
|
ALPHABET='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
2000-10-30 11:20:00 +08:00
|
|
|
NUMBERS='0123456789'
|
|
|
|
WORDCHAR=_$alphabet$ALPHABET$NUMBERS
|
|
|
|
|
2000-11-01 23:01:54 +08:00
|
|
|
m4_warnings=
|
2000-08-01 19:22:42 +08:00
|
|
|
for warning in `IFS=,; echo syntax,$WARNINGS,$warnings |
|
|
|
|
tr $ALPHABET $alphabet`
|
2000-07-10 18:23:08 +08:00
|
|
|
do
|
|
|
|
test -n $warning || continue
|
2000-11-01 23:01:54 +08:00
|
|
|
m4_warnings="$warning"`test -n "$m4_warnings" && echo ",$m4_warnings"`
|
2000-07-10 18:23:08 +08:00
|
|
|
done
|
|
|
|
|
Provide a fine grained control over autoconf's warnings.
* acgeneral.m4 (AC_WARNING_IFELSE, _AC_DIAGNOSE, AC_DIAGNOSE):
New macros.
(AC_DEFUN_ONCE, AC_OBSOLETE, AC_BEFORE, AU_DEFUN, AC_PREREQ,
AC_WARNING, AC_FATAL, AC_TRY_RUN): Use AC_DIAGNOSE.
* autoconf.sh: Provide support for `--warnings', `-W'.
* doc/autoconf.texi (Invoking autoconf): Adjust.
(Reporting Messages): New section.
2000-04-13 16:25:11 +08:00
|
|
|
|
2000-03-29 19:09:59 +08:00
|
|
|
# Trap on 0 to stop playing with `rm'.
|
|
|
|
$debug ||
|
|
|
|
{
|
|
|
|
trap 'status=$?; rm -rf $tmp && exit $status' 0
|
2000-08-11 16:51:34 +08:00
|
|
|
trap '(exit $?); exit' 1 2 13 15
|
2000-03-29 19:09:59 +08:00
|
|
|
}
|
|
|
|
|
2000-03-31 16:20:09 +08:00
|
|
|
# Create a (secure) tmp directory for tmp files.
|
2000-03-29 19:09:59 +08:00
|
|
|
: ${TMPDIR=/tmp}
|
2000-03-30 00:15:22 +08:00
|
|
|
{
|
|
|
|
tmp=`(umask 077 && mktemp -d -q "$TMPDIR/acXXXXXX") 2>/dev/null` &&
|
2000-07-10 16:41:59 +08:00
|
|
|
test -n "$tmp" && test -d "$tmp"
|
2000-07-19 16:54:44 +08:00
|
|
|
} ||
|
2000-03-30 00:15:22 +08:00
|
|
|
{
|
2000-09-25 21:24:45 +08:00
|
|
|
tmp=$TMPDIR/ac$$
|
|
|
|
(umask 077 && mkdir $tmp)
|
2000-03-30 00:15:22 +08:00
|
|
|
} ||
|
|
|
|
{
|
|
|
|
echo "$me: cannot create a temporary directory in $TMPDIR" >&2
|
2000-08-11 16:51:34 +08:00
|
|
|
(exit 1); exit;
|
2000-03-30 00:15:22 +08:00
|
|
|
}
|
2000-03-29 19:09:59 +08:00
|
|
|
|
2000-02-08 21:12:49 +08:00
|
|
|
# Running m4.
|
2000-07-19 17:03:53 +08:00
|
|
|
test -f "$autoconf_dir/acsite.m4" && acsite_m4="$autoconf_dir/acsite.m4"
|
2000-05-23 17:52:05 +08:00
|
|
|
test -f "$localdir/aclocal.m4" && aclocal_m4="$localdir/aclocal.m4"
|
2000-11-16 16:33:46 +08:00
|
|
|
m4_common="$acsite_m4 $aclocal_m4 -I $autoconf_dir -I $localdir \
|
* m4sugar.m4 (m4_dquote, m4_pattern_forbid, m4_pattern_allow)
(m4_cr_letters, m4_cr_LETTERS, m4_cr_Letters, m4_cr_digits)
(m4_cr_symbols1, m4_cr_symbols2, m4_re_string, m4_re_word)
(m4_init): New macros.
(m4_token_allow): Remove.
* acgeneral.m4: Don't push BODY into the diversion stack.
(AC_PLAIN_SCRIPT): Do it.
Call m4_init, define the Autoconf patterns.
(AC_INIT): Use AC_PLAIN_SCRIPT.
Remove the useless `dnl' (those where the current diversion is
KILL).
* autoconf.sh (m4_common): Fix quotation.
(finalize.awk): Load forbidden.rx and allowed.rx.
Split the line into tokens, and check their validity.
* tests/tools.at (Forbidden tokens): Adjust.
2000-12-06 16:58:13 +08:00
|
|
|
-Dm4_tmpdir=$tmp"
|
2000-07-19 17:03:53 +08:00
|
|
|
run_m4="$M4 $autoconf_dir/autoconf.m4 $m4_common"
|
|
|
|
run_m4f="$M4 --reload $autoconf_dir/autoconf.m4f $m4_common"
|
2000-02-08 21:12:49 +08:00
|
|
|
|
2000-03-13 23:31:26 +08:00
|
|
|
# Find the input file.
|
1994-09-01 12:59:32 +08:00
|
|
|
case $# in
|
2000-12-23 18:11:57 +08:00
|
|
|
0)
|
|
|
|
case `ls configure.ac configure.in 2>/dev/null` in
|
|
|
|
*ac*in )
|
|
|
|
echo "$me: warning: both \`configure.ac' and \`configure.in' are present." >&2
|
|
|
|
echo "$me: warning: proceeding with \`configure.ac'." >&2
|
|
|
|
infile=configure.ac;;
|
|
|
|
*ac ) infile=configure.ac;;
|
|
|
|
*in ) infile=configure.in;;
|
|
|
|
* )
|
|
|
|
echo "$me: no input file" >&2
|
|
|
|
exit 1;;
|
|
|
|
esac
|
|
|
|
test $task = script && test -z "$outfile" && outfile=configure;;
|
2000-03-14 01:26:21 +08:00
|
|
|
1) infile=$1 ;;
|
2000-02-08 21:45:24 +08:00
|
|
|
*) exec >&2
|
2000-02-08 19:39:46 +08:00
|
|
|
echo "$me: invalid number of arguments."
|
|
|
|
echo "$help"
|
2000-08-11 16:51:34 +08:00
|
|
|
(exit 1); exit ;;
|
1994-09-01 12:59:32 +08:00
|
|
|
esac
|
|
|
|
|
2000-07-10 16:56:19 +08:00
|
|
|
# Unless specified, the output is stdout.
|
|
|
|
test -z "$outfile" && outfile=-
|
|
|
|
|
2000-03-29 19:09:59 +08:00
|
|
|
# We need an actual file.
|
1994-09-01 12:59:32 +08:00
|
|
|
if test z$infile = z-; then
|
2000-03-29 19:09:59 +08:00
|
|
|
infile=$tmp/stdin
|
2000-01-29 17:22:53 +08:00
|
|
|
cat >$infile
|
1994-09-16 02:34:35 +08:00
|
|
|
elif test ! -r "$infile"; then
|
2000-02-08 21:12:49 +08:00
|
|
|
echo "$me: $infile: No such file or directory" >&2
|
2000-08-11 16:51:34 +08:00
|
|
|
(exit 1); exit
|
1993-10-11 02:00:46 +08:00
|
|
|
fi
|
1993-06-17 04:15:11 +08:00
|
|
|
|
2000-01-29 17:22:53 +08:00
|
|
|
# Output is produced into FD 4. Prepare it.
|
2001-01-11 22:18:48 +08:00
|
|
|
case $outfile in
|
|
|
|
-) # Output to stdout
|
2000-01-29 17:22:53 +08:00
|
|
|
exec 4>&1 ;;
|
|
|
|
* )
|
|
|
|
exec 4>$outfile;;
|
|
|
|
esac
|
1993-06-17 04:15:11 +08:00
|
|
|
|
2000-02-08 21:12:49 +08:00
|
|
|
# Initializations are performed. Proceed to the main task.
|
2000-01-29 17:22:53 +08:00
|
|
|
case $task in
|
2000-01-29 17:54:27 +08:00
|
|
|
|
Provide a fine grained control over autoconf's warnings.
* acgeneral.m4 (AC_WARNING_IFELSE, _AC_DIAGNOSE, AC_DIAGNOSE):
New macros.
(AC_DEFUN_ONCE, AC_OBSOLETE, AC_BEFORE, AU_DEFUN, AC_PREREQ,
AC_WARNING, AC_FATAL, AC_TRY_RUN): Use AC_DIAGNOSE.
* autoconf.sh: Provide support for `--warnings', `-W'.
* doc/autoconf.texi (Invoking autoconf): Adjust.
(Reporting Messages): New section.
2000-04-13 16:25:11 +08:00
|
|
|
## --------------------------------- ##
|
|
|
|
## Generate the `configure' script. ##
|
|
|
|
## --------------------------------- ##
|
2000-01-29 17:22:53 +08:00
|
|
|
script)
|
2000-07-10 18:23:08 +08:00
|
|
|
# M4 expansion.
|
2001-04-12 00:29:14 +08:00
|
|
|
: >$tmp/forbidden.rx
|
|
|
|
: >$tmp/allowed.rx
|
2000-10-31 23:20:15 +08:00
|
|
|
$run_m4f -Dm4_warnings=$m4_warnings $infile >$tmp/configure ||
|
2000-09-27 18:02:27 +08:00
|
|
|
{ (exit 1); exit; }
|
1994-08-25 11:45:07 +08:00
|
|
|
|
2000-07-10 16:56:19 +08:00
|
|
|
if test "x$outfile" != x-; then
|
2000-01-29 17:22:53 +08:00
|
|
|
chmod +x $outfile
|
|
|
|
fi
|
|
|
|
|
2000-03-20 18:06:36 +08:00
|
|
|
# Put the real line numbers into configure to make config.log more
|
|
|
|
# helpful. Because quoting can sometimes get really painful in m4,
|
|
|
|
# there are special @tokens@ to substitute.
|
2001-03-30 20:49:36 +08:00
|
|
|
sed 's/^ //' >"$tmp/finalize.awk" <<EOF
|
2000-11-16 16:33:46 +08:00
|
|
|
# Load the list of tokens which escape the forbidden patterns.
|
|
|
|
BEGIN {
|
|
|
|
# Be sure the read GAWK documentation to understand the parens
|
* m4sugar.m4 (m4_dquote, m4_pattern_forbid, m4_pattern_allow)
(m4_cr_letters, m4_cr_LETTERS, m4_cr_Letters, m4_cr_digits)
(m4_cr_symbols1, m4_cr_symbols2, m4_re_string, m4_re_word)
(m4_init): New macros.
(m4_token_allow): Remove.
* acgeneral.m4: Don't push BODY into the diversion stack.
(AC_PLAIN_SCRIPT): Do it.
Call m4_init, define the Autoconf patterns.
(AC_INIT): Use AC_PLAIN_SCRIPT.
Remove the useless `dnl' (those where the current diversion is
KILL).
* autoconf.sh (m4_common): Fix quotation.
(finalize.awk): Load forbidden.rx and allowed.rx.
Split the line into tokens, and check their validity.
* tests/tools.at (Forbidden tokens): Adjust.
2000-12-06 16:58:13 +08:00
|
|
|
# around \`tmp "/forbidden.rx"'.
|
|
|
|
while ((getline pattern < (tmp "/forbidden.rx")) > 0)
|
|
|
|
forbidden = (forbidden ? forbidden "|" : "") pattern
|
|
|
|
close (tmp "/forbidden.rx")
|
|
|
|
if (verbose)
|
|
|
|
errprint("$me: forbidden: " forbidden)
|
|
|
|
|
|
|
|
while ((getline pattern < (tmp "/allowed.rx")) > 0)
|
|
|
|
allowed = (allowed ? allowed "|" : "") pattern
|
2000-12-16 03:23:16 +08:00
|
|
|
if (!allowed)
|
|
|
|
allowed = "^$"
|
* m4sugar.m4 (m4_dquote, m4_pattern_forbid, m4_pattern_allow)
(m4_cr_letters, m4_cr_LETTERS, m4_cr_Letters, m4_cr_digits)
(m4_cr_symbols1, m4_cr_symbols2, m4_re_string, m4_re_word)
(m4_init): New macros.
(m4_token_allow): Remove.
* acgeneral.m4: Don't push BODY into the diversion stack.
(AC_PLAIN_SCRIPT): Do it.
Call m4_init, define the Autoconf patterns.
(AC_INIT): Use AC_PLAIN_SCRIPT.
Remove the useless `dnl' (those where the current diversion is
KILL).
* autoconf.sh (m4_common): Fix quotation.
(finalize.awk): Load forbidden.rx and allowed.rx.
Split the line into tokens, and check their validity.
* tests/tools.at (Forbidden tokens): Adjust.
2000-12-06 16:58:13 +08:00
|
|
|
close (tmp "/allowed.rx")
|
|
|
|
if (verbose)
|
|
|
|
errprint("$me: allowed: " allowed)
|
2000-11-16 16:33:46 +08:00
|
|
|
}
|
|
|
|
|
* m4sugar.m4 (m4_dquote, m4_pattern_forbid, m4_pattern_allow)
(m4_cr_letters, m4_cr_LETTERS, m4_cr_Letters, m4_cr_digits)
(m4_cr_symbols1, m4_cr_symbols2, m4_re_string, m4_re_word)
(m4_init): New macros.
(m4_token_allow): Remove.
* acgeneral.m4: Don't push BODY into the diversion stack.
(AC_PLAIN_SCRIPT): Do it.
Call m4_init, define the Autoconf patterns.
(AC_INIT): Use AC_PLAIN_SCRIPT.
Remove the useless `dnl' (those where the current diversion is
KILL).
* autoconf.sh (m4_common): Fix quotation.
(finalize.awk): Load forbidden.rx and allowed.rx.
Split the line into tokens, and check their validity.
* tests/tools.at (Forbidden tokens): Adjust.
2000-12-06 16:58:13 +08:00
|
|
|
function errprint (message)
|
2000-08-07 20:07:17 +08:00
|
|
|
{
|
2001-03-30 20:49:36 +08:00
|
|
|
# BAD! the pipe to 'cat >&2' doesn't work for DJGPP.
|
|
|
|
# print message | "cat >&2"
|
|
|
|
# Use normal redirection instead:
|
|
|
|
print message > "$tmp/finalize.err"
|
2000-08-07 20:07:17 +08:00
|
|
|
}
|
|
|
|
|
* m4sugar.m4 (m4_dquote, m4_pattern_forbid, m4_pattern_allow)
(m4_cr_letters, m4_cr_LETTERS, m4_cr_Letters, m4_cr_digits)
(m4_cr_symbols1, m4_cr_symbols2, m4_re_string, m4_re_word)
(m4_init): New macros.
(m4_token_allow): Remove.
* acgeneral.m4: Don't push BODY into the diversion stack.
(AC_PLAIN_SCRIPT): Do it.
Call m4_init, define the Autoconf patterns.
(AC_INIT): Use AC_PLAIN_SCRIPT.
Remove the useless `dnl' (those where the current diversion is
KILL).
* autoconf.sh (m4_common): Fix quotation.
(finalize.awk): Load forbidden.rx and allowed.rx.
Split the line into tokens, and check their validity.
* tests/tools.at (Forbidden tokens): Adjust.
2000-12-06 16:58:13 +08:00
|
|
|
function undefined (file, line, macro)
|
2000-11-16 16:33:46 +08:00
|
|
|
{
|
2001-05-20 00:55:05 +08:00
|
|
|
errprint(file ":" line ": error: possibly undefined macro: " macro)
|
2000-11-16 16:33:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Body.
|
2000-03-20 18:06:36 +08:00
|
|
|
{
|
* m4sugar.m4 (m4_dquote, m4_pattern_forbid, m4_pattern_allow)
(m4_cr_letters, m4_cr_LETTERS, m4_cr_Letters, m4_cr_digits)
(m4_cr_symbols1, m4_cr_symbols2, m4_re_string, m4_re_word)
(m4_init): New macros.
(m4_token_allow): Remove.
* acgeneral.m4: Don't push BODY into the diversion stack.
(AC_PLAIN_SCRIPT): Do it.
Call m4_init, define the Autoconf patterns.
(AC_INIT): Use AC_PLAIN_SCRIPT.
Remove the useless `dnl' (those where the current diversion is
KILL).
* autoconf.sh (m4_common): Fix quotation.
(finalize.awk): Load forbidden.rx and allowed.rx.
Split the line into tokens, and check their validity.
* tests/tools.at (Forbidden tokens): Adjust.
2000-12-06 16:58:13 +08:00
|
|
|
sub (/[ \t]*$/, "")
|
2000-08-07 20:07:17 +08:00
|
|
|
if (\$0 == "")
|
2000-03-20 18:06:36 +08:00
|
|
|
{
|
|
|
|
if (!duplicate)
|
2000-08-07 20:07:17 +08:00
|
|
|
{
|
|
|
|
oline++
|
|
|
|
print
|
|
|
|
}
|
2000-03-20 18:06:36 +08:00
|
|
|
duplicate = 1
|
|
|
|
next
|
|
|
|
}
|
|
|
|
duplicate = 0
|
|
|
|
oline++
|
2000-08-07 20:07:17 +08:00
|
|
|
if (\$0 ~ /__oline__/)
|
* m4sugar.m4 (m4_dquote, m4_pattern_forbid, m4_pattern_allow)
(m4_cr_letters, m4_cr_LETTERS, m4_cr_Letters, m4_cr_digits)
(m4_cr_symbols1, m4_cr_symbols2, m4_re_string, m4_re_word)
(m4_init): New macros.
(m4_token_allow): Remove.
* acgeneral.m4: Don't push BODY into the diversion stack.
(AC_PLAIN_SCRIPT): Do it.
Call m4_init, define the Autoconf patterns.
(AC_INIT): Use AC_PLAIN_SCRIPT.
Remove the useless `dnl' (those where the current diversion is
KILL).
* autoconf.sh (m4_common): Fix quotation.
(finalize.awk): Load forbidden.rx and allowed.rx.
Split the line into tokens, and check their validity.
* tests/tools.at (Forbidden tokens): Adjust.
2000-12-06 16:58:13 +08:00
|
|
|
while (sub (/__oline__/, oline))
|
2000-04-28 17:46:55 +08:00
|
|
|
continue
|
2000-08-07 20:07:17 +08:00
|
|
|
while (sub (/@<:@/, "["))
|
2000-03-20 18:06:36 +08:00
|
|
|
continue
|
2000-08-07 20:07:17 +08:00
|
|
|
while (sub (/@:>@/, "]"))
|
2000-03-20 18:06:36 +08:00
|
|
|
continue
|
2000-08-07 20:07:17 +08:00
|
|
|
while (sub (/@S\|@/, "$"))
|
2000-03-20 18:06:36 +08:00
|
|
|
continue
|
2000-08-07 20:07:17 +08:00
|
|
|
while (sub (/@%:@/, "#"))
|
2000-03-20 18:06:36 +08:00
|
|
|
continue
|
* m4sugar.m4 (m4_dquote, m4_pattern_forbid, m4_pattern_allow)
(m4_cr_letters, m4_cr_LETTERS, m4_cr_Letters, m4_cr_digits)
(m4_cr_symbols1, m4_cr_symbols2, m4_re_string, m4_re_word)
(m4_init): New macros.
(m4_token_allow): Remove.
* acgeneral.m4: Don't push BODY into the diversion stack.
(AC_PLAIN_SCRIPT): Do it.
Call m4_init, define the Autoconf patterns.
(AC_INIT): Use AC_PLAIN_SCRIPT.
Remove the useless `dnl' (those where the current diversion is
KILL).
* autoconf.sh (m4_common): Fix quotation.
(finalize.awk): Load forbidden.rx and allowed.rx.
Split the line into tokens, and check their validity.
* tests/tools.at (Forbidden tokens): Adjust.
2000-12-06 16:58:13 +08:00
|
|
|
|
2000-03-20 18:06:36 +08:00
|
|
|
print
|
* m4sugar.m4 (m4_dquote, m4_pattern_forbid, m4_pattern_allow)
(m4_cr_letters, m4_cr_LETTERS, m4_cr_Letters, m4_cr_digits)
(m4_cr_symbols1, m4_cr_symbols2, m4_re_string, m4_re_word)
(m4_init): New macros.
(m4_token_allow): Remove.
* acgeneral.m4: Don't push BODY into the diversion stack.
(AC_PLAIN_SCRIPT): Do it.
Call m4_init, define the Autoconf patterns.
(AC_INIT): Use AC_PLAIN_SCRIPT.
Remove the useless `dnl' (those where the current diversion is
KILL).
* autoconf.sh (m4_common): Fix quotation.
(finalize.awk): Load forbidden.rx and allowed.rx.
Split the line into tokens, and check their validity.
* tests/tools.at (Forbidden tokens): Adjust.
2000-12-06 16:58:13 +08:00
|
|
|
|
|
|
|
# Dubious feature: we tolerate macro names when commented.
|
|
|
|
sub (/#.*/, "")
|
|
|
|
|
|
|
|
# Get the tokens.
|
|
|
|
split (\$0, tokens, /[^$WORDCHAR]*/)
|
|
|
|
|
|
|
|
for (token in tokens)
|
|
|
|
if (match (tokens[token], forbidden) &&
|
|
|
|
!match (tokens[token], allowed))
|
|
|
|
{
|
|
|
|
macros [tokens [token]] = oline
|
|
|
|
some_macros_were_not_expanded = 1
|
|
|
|
}
|
2000-08-07 20:07:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# If there are some macros which are left unexpanded in the output,
|
|
|
|
# try to find the input which is responsible. Otherwise, try to help.
|
|
|
|
END {
|
|
|
|
if (some_macros_were_not_expanded)
|
|
|
|
{
|
|
|
|
line = 0
|
|
|
|
while (getline < "$infile")
|
|
|
|
{
|
|
|
|
line++
|
|
|
|
for (macro in macros)
|
2000-11-16 16:33:46 +08:00
|
|
|
if (index (\$0, macro))
|
|
|
|
{
|
|
|
|
delete macros [macro]
|
|
|
|
undefined("$infile", line, macro)
|
|
|
|
}
|
2000-08-07 20:07:17 +08:00
|
|
|
}
|
|
|
|
close ("$infile")
|
|
|
|
for (macro in macros)
|
2000-08-09 14:53:07 +08:00
|
|
|
undefined("$outfile", macros [macro], macro)
|
2000-08-07 20:07:17 +08:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
2000-11-16 16:33:46 +08:00
|
|
|
$AWK -v tmp="$tmp" \
|
|
|
|
`$verbose "-v verbose=1"` \
|
2001-03-30 20:49:36 +08:00
|
|
|
-f "$tmp/finalize.awk" <$tmp/configure >&4 ||
|
|
|
|
{ test -f "$tmp/finalize.err" && cat "$tmp/finalize.err" >&2
|
|
|
|
(exit 1); exit; }
|
|
|
|
test -f "$tmp/finalize.err" && cat "$tmp/finalize.err" >&2
|
2000-01-29 17:22:53 +08:00
|
|
|
;; # End of the task script.
|
|
|
|
|
2000-03-13 23:31:26 +08:00
|
|
|
|
|
|
|
|
2000-01-29 17:54:27 +08:00
|
|
|
## -------------- ##
|
|
|
|
## Trace macros. ##
|
|
|
|
## -------------- ##
|
2000-01-29 17:22:53 +08:00
|
|
|
trace)
|
2000-11-03 00:03:58 +08:00
|
|
|
|
2000-06-09 18:00:36 +08:00
|
|
|
# trace.m4
|
|
|
|
# --------
|
|
|
|
# Routines to process formatted m4 traces.
|
2000-11-03 00:03:58 +08:00
|
|
|
sed 's/^ //' >$tmp/trace.m4 <<\EOF
|
|
|
|
divert(-1)
|
2000-03-13 23:31:26 +08:00
|
|
|
changequote([, ])
|
2000-11-03 00:03:58 +08:00
|
|
|
# _at_MODE(SEPARATOR, ELT1, ELT2...)
|
|
|
|
# ----------------------------------
|
2000-05-03 16:53:06 +08:00
|
|
|
# List the elements, separating then with SEPARATOR.
|
|
|
|
# MODE can be:
|
|
|
|
# `at' -- the elements are enclosed in brackets.
|
|
|
|
# `star' -- the elements are listed as are.
|
2000-12-06 22:05:46 +08:00
|
|
|
# `percent' -- the elements are `flattened': spaces are singled out,
|
2000-05-03 16:53:06 +08:00
|
|
|
# and no new line remains.
|
2000-11-03 00:03:58 +08:00
|
|
|
define([_at_at],
|
|
|
|
[at_ifelse([$#], [1], [],
|
|
|
|
[$#], [2], [[[$2]]],
|
|
|
|
[[[$2]][$1]$0([$1], at_shift(at_shift($@)))])])
|
|
|
|
define([_at_percent],
|
|
|
|
[at_ifelse([$#], [1], [],
|
2000-12-06 22:05:46 +08:00
|
|
|
[$#], [2], [at_flatten([$2])],
|
|
|
|
[at_flatten([$2])[$1]$0([$1], at_shift(at_shift($@)))])])
|
2000-11-03 00:03:58 +08:00
|
|
|
define([_at_star],
|
|
|
|
[at_ifelse([$#], [1], [],
|
|
|
|
[$#], [2], [[$2]],
|
|
|
|
[[$2][$1]$0([$1], at_shift(at_shift($@)))])])
|
2000-03-14 16:30:41 +08:00
|
|
|
|
2000-12-06 22:05:46 +08:00
|
|
|
# FLATTEN quotes its result.
|
|
|
|
define([at_flatten],
|
2000-11-03 00:03:58 +08:00
|
|
|
[at_patsubst(at_patsubst(at_patsubst([[[$1]]],
|
|
|
|
[\\
|
|
|
|
]),
|
|
|
|
[[
|
2000-03-14 16:30:41 +08:00
|
|
|
]+],
|
2000-11-03 00:03:58 +08:00
|
|
|
[ ]),
|
|
|
|
[^ *\(.*\) *$], [[\1]])])
|
|
|
|
|
|
|
|
define([at_args], [at_shift(at_shift(at_shift(at_shift(at_shift($@)))))])
|
|
|
|
define([at_at], [_$0([$1], at_args($@))])
|
|
|
|
define([at_percent], [_$0([$1], at_args($@))])
|
|
|
|
define([at_star], [_$0([$1], at_args($@))])
|
|
|
|
|
2000-03-13 23:31:26 +08:00
|
|
|
EOF
|
|
|
|
|
2000-11-03 00:03:58 +08:00
|
|
|
# If you trace `define', then on `define([m4_exit], defn([m4exit])' you
|
|
|
|
# will produce
|
|
|
|
#
|
|
|
|
# AT_define([m4sugar.m4], [115], [1], [define], [m4_exit], <m4exit>)
|
|
|
|
#
|
|
|
|
# Since `<m4exit>' is not quoted, the outter m4, when processing
|
|
|
|
# `trace.m4' will exit prematurely. Hence, move all the builtins to
|
|
|
|
# the `at_' name space.
|
|
|
|
echo '# Copy the builtins.' >>$tmp/trace.m4
|
|
|
|
echo "dumpdef" |
|
|
|
|
$M4 2>&1 >/dev/null |
|
|
|
|
sed 's/^\([^:]*\):.*/define([at_\1], defn([\1]))/' >>$tmp/trace.m4
|
|
|
|
echo >>$tmp/trace.m4
|
|
|
|
|
|
|
|
echo '# Disable the builtins.' >>$tmp/trace.m4
|
|
|
|
echo "dumpdef" |
|
|
|
|
$M4 2>&1 >/dev/null |
|
|
|
|
sed 's/^\([^:]*\):.*/at_undefine([\1])/' >>$tmp/trace.m4
|
|
|
|
echo >>$tmp/trace.m4
|
|
|
|
|
|
|
|
|
2000-06-09 18:02:19 +08:00
|
|
|
# trace2m4.sed
|
|
|
|
# ------------
|
|
|
|
# Transform the traces from m4 into an m4 input file.
|
|
|
|
# Typically, transform:
|
2000-11-03 00:03:58 +08:00
|
|
|
#
|
2001-01-12 17:19:59 +08:00
|
|
|
# | m4trace:configure.ac:3: -1- AC_SUBST([exec_prefix], [NONE])
|
2000-11-03 00:03:58 +08:00
|
|
|
#
|
2000-06-09 18:02:19 +08:00
|
|
|
# into
|
2000-11-03 00:03:58 +08:00
|
|
|
#
|
2001-01-12 17:19:59 +08:00
|
|
|
# | AT_AC_SUBST([configure.ac], [3], [1], [AC_SUBST], [exec_prefix], [NONE])
|
2000-11-03 00:03:58 +08:00
|
|
|
#
|
2000-06-09 18:02:19 +08:00
|
|
|
# Pay attention that the file name might include colons, if under DOS
|
|
|
|
# for instance, so we don't use `[^:][^:]*'.
|
|
|
|
# The first s/// catches multiline traces, the second, traces as above.
|
|
|
|
preamble='m4trace:\(..*\):\([0-9][0-9]*\): -\([0-9][0-9]*\)-'
|
|
|
|
cat >$tmp/trace2m4.sed <<EOF
|
|
|
|
s/^$preamble \([^(][^(]*\)(\(.*\)$/AT_\4([\1], [\2], [\3], [\4], \5/
|
|
|
|
s/^$preamble \(.*\)$/AT_\4([\1], [\2], [\3], [\4])/
|
|
|
|
EOF
|
|
|
|
|
2000-06-09 18:00:36 +08:00
|
|
|
# translate.awk
|
|
|
|
# -------------
|
|
|
|
# Translate user tracing requests into m4 macros.
|
|
|
|
cat >$tmp/translate.awk <<\EOF
|
|
|
|
function trans (arg, sep)
|
|
|
|
{
|
|
|
|
# File name.
|
|
|
|
if (arg == "f")
|
|
|
|
return "$1"
|
|
|
|
# Line number.
|
|
|
|
if (arg == "l")
|
|
|
|
return "$2"
|
|
|
|
# Depth.
|
|
|
|
if (arg == "d")
|
|
|
|
return "$3"
|
|
|
|
# Name (also available as $0).
|
|
|
|
if (arg == "n")
|
|
|
|
return "$4"
|
|
|
|
# Escaped dollar.
|
|
|
|
if (arg == "$")
|
|
|
|
return "$"
|
|
|
|
|
|
|
|
# $@, list of quoted effective arguments.
|
|
|
|
if (arg == "@")
|
2000-11-03 00:03:58 +08:00
|
|
|
return "]at_at([" (separator ? separator : ",") "], $@)["
|
2000-06-09 18:00:36 +08:00
|
|
|
# $*, list of unquoted effective arguments.
|
|
|
|
if (arg == "*")
|
2000-11-03 00:03:58 +08:00
|
|
|
return "]at_star([" (separator ? separator : ",") "], $@)["
|
2000-12-06 22:05:46 +08:00
|
|
|
# $%, list of flattened unquoted effective arguments.
|
2000-06-09 18:00:36 +08:00
|
|
|
if (arg == "%")
|
2000-11-03 00:03:58 +08:00
|
|
|
return "]at_percent([" (separator ? separator : ":") "], $@)["
|
2000-06-09 18:00:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function error (message)
|
|
|
|
{
|
|
|
|
print message | "cat >&2"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
# Accumulate the whole input.
|
|
|
|
request = request $0 "\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
END {
|
|
|
|
# Chomp.
|
|
|
|
request = substr (request, 1, length (request) - 1)
|
|
|
|
# The default request is `$f:$l:$n:$*'.
|
|
|
|
colon = index (request, ":")
|
|
|
|
macro = colon ? substr (request, 1, colon - 1) : request
|
|
|
|
request = colon ? substr (request, colon + 1) : "$f:$l:$n:$%"
|
|
|
|
|
|
|
|
res = ""
|
|
|
|
|
|
|
|
for (cp = request; cp; cp = substr (cp, 2))
|
|
|
|
{
|
|
|
|
char = substr (cp, 1, 1)
|
|
|
|
if (char == "$")
|
|
|
|
{
|
|
|
|
if (match (cp, /^\$[0-9]+/))
|
|
|
|
{
|
|
|
|
# $n -> $(n + 4)
|
|
|
|
res = res "$" (substr (cp, 2, RLENGTH - 1) + 4)
|
|
|
|
cp = substr (cp, RLENGTH)
|
|
|
|
}
|
|
|
|
else if (substr (cp, 2, 1) ~ /[fldn$@%*]/)
|
|
|
|
{
|
|
|
|
# $x, no separator given.
|
|
|
|
res = res trans(substr (cp, 2, 1))
|
|
|
|
cp = substr (cp, 2)
|
|
|
|
}
|
|
|
|
else if (substr (cp, 2, 1) == "{")
|
|
|
|
{
|
|
|
|
# ${sep}x, long separator.
|
|
|
|
end = index (cp, "}")
|
|
|
|
if (!end)
|
|
|
|
error("invalid escape: " cp)
|
|
|
|
separator = substr (cp, 3, end - 3)
|
|
|
|
if (substr (cp, end + 1, 1) ~ /[*@%]/)
|
|
|
|
res = res trans(substr (cp, end + 1, 1), separator)
|
|
|
|
else
|
|
|
|
error("invalid escape: " cp)
|
|
|
|
cp = substr (cp, end + 1)
|
|
|
|
}
|
|
|
|
else if (substr (cp, 3, 1) ~ /[*@%]/)
|
|
|
|
{
|
|
|
|
# $sx, short separator `s'.
|
|
|
|
res = res trans(substr (cp, 3, 1), substr (cp, 2, 1))
|
|
|
|
cp = substr(cp, 3)
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error("invalid escape: " substr (cp, 1, 2))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
res = res char
|
|
|
|
}
|
|
|
|
|
|
|
|
# Produce the definition of AT_<MACRO> = the translation of the request.
|
2000-11-03 00:03:58 +08:00
|
|
|
print "at_define([AT_" macro "],"
|
|
|
|
print "[[" res "]])"
|
|
|
|
print ""
|
2000-06-09 18:00:36 +08:00
|
|
|
close("cat >&2")
|
|
|
|
}
|
2000-03-13 23:31:26 +08:00
|
|
|
EOF
|
2000-11-02 01:02:34 +08:00
|
|
|
|
|
|
|
|
2000-03-13 23:31:26 +08:00
|
|
|
# Extract both the m4 program and the m4 options from TRACES.
|
2000-11-03 00:03:58 +08:00
|
|
|
echo "## ------------------------- ##" >>$tmp/trace.m4
|
|
|
|
echo "## Trace processing macros. ##" >>$tmp/trace.m4
|
|
|
|
echo "## ------------------------- ##" >>$tmp/trace.m4
|
|
|
|
echo >>$tmp/trace.m4
|
|
|
|
|
2000-03-14 01:30:32 +08:00
|
|
|
eval set dummy "$traces"
|
2000-03-13 23:31:26 +08:00
|
|
|
shift
|
|
|
|
for trace
|
|
|
|
do
|
2000-11-03 00:03:58 +08:00
|
|
|
echo "# $trace" >>$tmp/trace.m4
|
|
|
|
|
2000-03-13 23:31:26 +08:00
|
|
|
# The request may be several lines long, hence sed has to quit.
|
2000-11-02 01:02:34 +08:00
|
|
|
macro_name=`echo "$trace" | sed 's/:.*//;q'`
|
2000-11-02 23:32:23 +08:00
|
|
|
# If for instance TRACE is `define', be sure to have an empty
|
|
|
|
# TRACE_FORMAT.
|
|
|
|
case $trace in
|
|
|
|
$macro_name:* )
|
|
|
|
trace_format=`echo "$trace" | sed "1s/^$macro_name:/:/"`;;
|
|
|
|
* )
|
|
|
|
trace_format=;;
|
|
|
|
esac
|
2000-11-02 01:02:34 +08:00
|
|
|
|
|
|
|
# GNU M4 1.4's tracing of builtins is buggy. When run on this input:
|
|
|
|
#
|
|
|
|
# | divert(-1)
|
|
|
|
# | changequote([, ])
|
|
|
|
# | define([m4_eval], defn([eval]))
|
|
|
|
# | eval(1)
|
|
|
|
# | m4_eval(2)
|
|
|
|
# | undefine([eval])
|
|
|
|
# | m4_eval(3)
|
|
|
|
#
|
|
|
|
# it behaves this way:
|
|
|
|
#
|
|
|
|
# | % m4 input.m4 -da -t eval
|
|
|
|
# | m4trace: -1- eval(1)
|
|
|
|
# | m4trace: -1- m4_eval(2)
|
|
|
|
# | m4trace: -1- m4_eval(3)
|
|
|
|
# | %
|
|
|
|
#
|
|
|
|
# Conversely:
|
|
|
|
#
|
|
|
|
# | % m4 input.m4 -da -t m4_eval
|
|
|
|
# | %
|
|
|
|
#
|
|
|
|
# So we will merge them, i.e. tracing `BUILTIN' or tracing
|
|
|
|
# `m4_BUILTIN' will be the same: tracing both, but honoring the
|
|
|
|
# *last* trace specification.
|
|
|
|
# FIXME: This is not enough: in the output `$0' will be `BUILTIN'
|
|
|
|
# sometimes and `m4_BUILTIN' at others. We should render a unique name,
|
|
|
|
# the one specified by the user.
|
|
|
|
base_name=`echo "$macro_name" | sed 's/^m4_//'`
|
2000-12-06 18:53:58 +08:00
|
|
|
if echo "ifdef(\`$base_name', \`', \`m4exit(-1)')" | $M4; then
|
2000-11-02 01:02:34 +08:00
|
|
|
# BASE_NAME is a builtin.
|
|
|
|
trace_opt="$trace_opt -t $base_name -t m4_$base_name"
|
2000-11-02 22:12:18 +08:00
|
|
|
echo "$base_name$trace_format" |
|
2000-11-02 01:02:34 +08:00
|
|
|
$AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
|
|
|
|
{ (exit 1); exit; }
|
2000-11-02 22:12:18 +08:00
|
|
|
echo "m4_$base_name$trace_format" |
|
2000-11-02 01:02:34 +08:00
|
|
|
$AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
|
|
|
|
{ (exit 1); exit; }
|
|
|
|
else
|
|
|
|
# MACRO_NAME is not a builtin.
|
|
|
|
trace_opt="$trace_opt -t $macro_name"
|
|
|
|
echo "$trace" |
|
|
|
|
$AWK -f $tmp/translate.awk >>$tmp/trace.m4 ||
|
|
|
|
{ (exit 1); exit; }
|
|
|
|
fi
|
2000-11-03 00:03:58 +08:00
|
|
|
echo >>$tmp/trace.m4
|
2000-03-13 23:31:26 +08:00
|
|
|
done
|
2000-11-03 00:03:58 +08:00
|
|
|
|
|
|
|
echo "## ------------------- ##" >>$tmp/trace.m4
|
|
|
|
echo "## Traces to process. ##" >>$tmp/trace.m4
|
|
|
|
echo "## ------------------- ##" >>$tmp/trace.m4
|
|
|
|
echo >>$tmp/trace.m4
|
|
|
|
echo "at_divert(0)at_dnl" >>$tmp/trace.m4
|
2000-03-13 23:31:26 +08:00
|
|
|
|
|
|
|
# Do we trace the initialization?
|
2000-03-30 00:18:52 +08:00
|
|
|
# `errprint' must be silent, otherwise there can be warnings mixed
|
|
|
|
# with traces in m4's stderr.
|
2000-03-13 23:31:26 +08:00
|
|
|
if $initialization; then
|
2000-03-30 00:18:52 +08:00
|
|
|
run_m4_trace="$run_m4 $trace_opt -daflq -Derrprint"
|
2000-03-13 23:31:26 +08:00
|
|
|
else
|
2000-03-30 00:18:52 +08:00
|
|
|
run_m4_trace="$run_m4f $trace_opt -daflq -Derrprint"
|
2000-03-13 23:31:26 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Run m4 on the input file to get traces.
|
2000-07-13 21:38:45 +08:00
|
|
|
$verbose "$me: running $run_m4_trace $infile | $M4 $tmp/trace.m4" >&2
|
2000-03-13 23:31:26 +08:00
|
|
|
$run_m4_trace $infile 2>&1 >/dev/null |
|
2000-06-09 18:02:19 +08:00
|
|
|
sed -f $tmp/trace2m4.sed |
|
2000-03-30 00:18:52 +08:00
|
|
|
# Now we are ready to run m4 to process the trace file.
|
2000-11-02 23:06:02 +08:00
|
|
|
if $debug; then
|
|
|
|
cat >>$tmp/trace.m4
|
|
|
|
$M4 $tmp/trace.m4
|
|
|
|
else
|
|
|
|
$M4 $tmp/trace.m4 -
|
|
|
|
fi |
|
|
|
|
# It makes no sense to try to transform __oline__.
|
|
|
|
sed '
|
|
|
|
s/@<:@/[/g
|
|
|
|
s/@:>@/]/g
|
|
|
|
s/@S|@/$/g
|
|
|
|
s/@%:@/#/g
|
2000-11-03 00:03:58 +08:00
|
|
|
' >&4 ||
|
|
|
|
{
|
|
|
|
echo "$me: tracing failed" >&2
|
|
|
|
(exit 1); exit
|
|
|
|
}
|
2000-01-29 17:22:53 +08:00
|
|
|
;;
|
|
|
|
|
2000-01-29 17:54:27 +08:00
|
|
|
|
|
|
|
## ------------ ##
|
|
|
|
## Unknown task ##
|
|
|
|
## ------------ ##
|
|
|
|
|
2000-11-16 16:33:46 +08:00
|
|
|
*) echo "$me: internal error: unknown task: $task" >&2
|
2000-08-11 16:51:34 +08:00
|
|
|
(exit 1); exit
|
2000-01-29 17:22:53 +08:00
|
|
|
esac
|
1994-09-16 02:34:35 +08:00
|
|
|
|
2000-08-11 16:51:34 +08:00
|
|
|
(exit $status); exit
|