1998-09-03 08:47:24 +08:00
|
|
|
#! @SHELL@
|
1993-06-17 04:15:11 +08:00
|
|
|
# autoconf -- create `configure' using m4 macros
|
2000-03-13 23:31:26 +08:00
|
|
|
# Copyright (C) 1992, 93, 94, 96, 99, 2000 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
|
|
|
|
|
|
|
# If given no args, create `configure' from template file `configure.in'.
|
|
|
|
# With one arg, create a configure script on standard output from
|
|
|
|
# the given template file.
|
|
|
|
|
2000-02-08 19:39:46 +08:00
|
|
|
me=`echo "$0" | sed -e 's,.*/,,'`
|
|
|
|
|
1994-05-05 01:34:32 +08:00
|
|
|
usage="\
|
1999-01-08 11:38:59 +08:00
|
|
|
Usage: autoconf [OPTION] ... [TEMPLATE-FILE]
|
|
|
|
|
|
|
|
Generate a configuration script from a TEMPLATE-FILE if given, or
|
|
|
|
\`configure.in' by default. Output is sent to the standard output if
|
|
|
|
TEMPLATE-FILE is given, else into \`configure'.
|
|
|
|
|
2000-01-29 17:22:53 +08:00
|
|
|
If the option \`--trace' is used, no configuration script is created.
|
|
|
|
|
2000-03-13 23:31:26 +08:00
|
|
|
-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
|
|
|
|
-m, --macrodir=DIR directory storing Autoconf's macro files
|
|
|
|
-l, --localdir=DIR directory storing the \`aclocal.m4' file
|
|
|
|
-t, --trace=MACRO report the list of calls to MACRO
|
|
|
|
-i, --initialization also trace Autoconf's initialization process
|
|
|
|
-o, --output=FILE save output in FILE (stdout is the default)
|
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="\
|
|
|
|
autoconf (GNU @PACKAGE@) @VERSION@
|
|
|
|
Written by David J. MacKenzie.
|
|
|
|
|
2000-03-13 23:31:26 +08:00
|
|
|
Copyright (C) 1992, 93, 94, 96, 99, 2000 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."
|
|
|
|
|
1993-06-25 03:57:01 +08:00
|
|
|
# NLS nuisances.
|
1996-11-21 03:13:42 +08:00
|
|
|
# Only set these to C if already set. These must not be set unconditionally
|
|
|
|
# because not all systems understand e.g. LANG=C (notably SCO).
|
|
|
|
# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
|
|
|
|
# Non-C LC_CTYPE values break the ctype check.
|
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_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
|
|
|
|
if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; 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@}
|
2000-01-29 17:22:53 +08:00
|
|
|
case "$M4" in
|
2000-02-08 21:12:49 +08:00
|
|
|
/*) test -f "$M4" || M4=m4 ;;
|
|
|
|
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.
|
|
|
|
: ${AC_MACRODIR=@datadir@}
|
2000-02-25 02:25:03 +08:00
|
|
|
: ${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
|
1994-09-16 02:34:35 +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:
|
2000-03-29 19:09:59 +08:00
|
|
|
# - install
|
|
|
|
# Install links to the needed *.m4 extensions.
|
2000-01-29 17:22:53 +08:00
|
|
|
# - 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-02-08 21:12:49 +08:00
|
|
|
# Parse command line
|
1993-06-17 04:15:11 +08:00
|
|
|
while test $# -gt 0 ; do
|
2000-01-29 17:22:53 +08:00
|
|
|
case "$1" in
|
2000-03-03 02:17:26 +08:00
|
|
|
--version | --vers* | -V )
|
2000-02-08 21:12:49 +08:00
|
|
|
echo "$version" ; exit 0 ;;
|
2000-02-08 19:39:46 +08:00
|
|
|
--help | --h* | -h )
|
2000-01-29 17:22:53 +08:00
|
|
|
echo "$usage"; exit 0 ;;
|
2000-03-14 01:26:21 +08:00
|
|
|
|
2000-03-13 23:31:26 +08:00
|
|
|
--debug | --d* | -d )
|
|
|
|
debug=:; shift ;;
|
2000-03-14 01:26:21 +08:00
|
|
|
--verbose | --verb* | -v )
|
|
|
|
verbose=echo
|
|
|
|
shift;;
|
2000-02-15 17:10:23 +08:00
|
|
|
|
2000-01-29 17:22:53 +08:00
|
|
|
--localdir=* | --l*=* )
|
2000-01-29 17:54:27 +08:00
|
|
|
localdir=`echo "$1" | sed -e 's/^[^=]*=//'`
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
2000-02-08 19:39:46 +08:00
|
|
|
--localdir | --l* | -l )
|
2000-01-29 17:22:53 +08:00
|
|
|
shift
|
2000-03-14 01:26:21 +08:00
|
|
|
test $# = 0 && { echo "$help" >&2; exit 1; }
|
|
|
|
localdir=$1
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
2000-02-15 17:10:23 +08:00
|
|
|
|
2000-01-29 17:22:53 +08:00
|
|
|
--macrodir=* | --m*=* )
|
2000-01-29 17:54:27 +08:00
|
|
|
AC_MACRODIR=`echo "$1" | sed -e 's/^[^=]*=//'`
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
2000-02-08 19:39:46 +08:00
|
|
|
--macrodir | --m* | -m )
|
2000-01-29 17:22:53 +08:00
|
|
|
shift
|
2000-03-14 01:26:21 +08:00
|
|
|
test $# = 0 && { echo "$help" >&2; exit 1; }
|
|
|
|
AC_MACRODIR=$1
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
2000-02-15 17:10:23 +08:00
|
|
|
|
2000-01-29 17:54:27 +08:00
|
|
|
--install )
|
|
|
|
task=install
|
|
|
|
shift;;
|
2000-02-15 17:10:23 +08:00
|
|
|
|
2000-01-29 17:22:53 +08:00
|
|
|
--trace | -t )
|
|
|
|
task=trace
|
|
|
|
shift
|
2000-03-14 01:26:21 +08:00
|
|
|
test $# = 0 && { echo "$help" >&2; exit 1; }
|
2000-03-13 23:31:26 +08:00
|
|
|
traces="$traces '$1'"
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
|
|
|
--trace=* )
|
|
|
|
task=trace
|
2000-03-13 23:31:26 +08:00
|
|
|
traces="$traces '"`echo "$1" | sed -e 's/^[^=]*=//;s/:.*//'`"'"
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
2000-03-13 23:31:26 +08:00
|
|
|
--initialization | -i )
|
|
|
|
initialization=:
|
|
|
|
shift;;
|
2000-02-15 17:10:23 +08:00
|
|
|
|
2000-01-29 17:22:53 +08:00
|
|
|
--output | -o )
|
|
|
|
shift
|
2000-03-14 01:26:21 +08:00
|
|
|
test $# = 0 && { echo "$help" >&2; exit 1; }
|
|
|
|
outfile=$1
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
|
|
|
--output=* )
|
2000-01-29 17:54:27 +08:00
|
|
|
outfile=`echo "$1" | sed -e 's/^[^=]*=//'`
|
2000-01-29 17:22:53 +08:00
|
|
|
shift ;;
|
2000-02-15 17:10:23 +08:00
|
|
|
|
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-03-29 19:09:59 +08:00
|
|
|
# Trap on 0 to stop playing with `rm'.
|
|
|
|
$debug ||
|
|
|
|
{
|
|
|
|
trap 'status=$?; rm -rf $tmp && exit $status' 0
|
|
|
|
trap 'exit $?' 1 2 13 15
|
|
|
|
}
|
|
|
|
|
|
|
|
# Temporary files.
|
|
|
|
: ${TMPDIR=/tmp}
|
2000-03-30 00:15:22 +08:00
|
|
|
{
|
|
|
|
tmp=`(umask 077 && mktemp -d -q "$TMPDIR/acXXXXXX") 2>/dev/null` &&
|
|
|
|
test -n "$tmp"
|
|
|
|
} ||
|
|
|
|
{
|
|
|
|
tmp=$TMPDIR/ac$$ && (umask 077 && mkdir $tmp)
|
|
|
|
} ||
|
|
|
|
{
|
|
|
|
echo "$me: cannot create a temporary directory in $TMPDIR" >&2
|
|
|
|
exit 1;
|
|
|
|
}
|
2000-03-29 19:09:59 +08:00
|
|
|
|
2000-02-08 21:12:49 +08:00
|
|
|
# Running m4.
|
2000-03-13 23:31:26 +08:00
|
|
|
test -n "$localdir" && use_localdir="-I$localdir"
|
|
|
|
run_m4="$M4 $use_localdir -I $AC_MACRODIR autoconf.m4"
|
|
|
|
run_m4f="$M4 $use_localdir --reload $AC_MACRODIR/autoconf.m4f"
|
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-01-29 17:22:53 +08:00
|
|
|
0) infile=configure.in
|
|
|
|
test $task = script && test "x$outfile" = x && 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"
|
|
|
|
exit 1 ;;
|
1994-09-01 12:59:32 +08:00
|
|
|
esac
|
|
|
|
|
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
|
1994-09-01 12:59:32 +08:00
|
|
|
exit 1
|
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.
|
|
|
|
case "x$outfile" in
|
|
|
|
x- | x ) # Output to stdout
|
|
|
|
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
|
|
|
|
2000-02-08 21:12:49 +08:00
|
|
|
## --------------------- ##
|
|
|
|
## Generate the script. ##
|
|
|
|
## --------------------- ##
|
2000-01-29 17:22:53 +08:00
|
|
|
script)
|
2000-03-29 19:09:59 +08:00
|
|
|
$run_m4f $infile >$tmp/configure || exit 2
|
1994-08-25 11:45:07 +08:00
|
|
|
|
2000-01-29 17:22:53 +08:00
|
|
|
# You could add your own prefixes to pattern if you wanted to check for
|
|
|
|
# them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
|
|
|
|
# alternation.
|
|
|
|
pattern="A[CHM]_"
|
|
|
|
|
2000-03-29 19:09:59 +08:00
|
|
|
if grep "^[^#]*$pattern" $tmp/configure >/dev/null 2>&1; then
|
2000-03-13 23:31:26 +08:00
|
|
|
echo "$me: undefined macros:" >&2
|
2000-03-29 19:09:59 +08:00
|
|
|
sed -n "s/^[^#]*\\($pattern[_A-Za-z0-9]*\\).*/\\1/p" $tmp/configure |
|
2000-01-29 17:22:53 +08:00
|
|
|
while read macro; do
|
|
|
|
grep -n "^[^#]*$macro" $infile /dev/null
|
2000-03-14 01:26:21 +08:00
|
|
|
test $? = 1 && echo "***BUG in Autoconf--please report*** $macro"
|
2000-01-29 17:22:53 +08:00
|
|
|
done | sort -u >&2
|
|
|
|
status=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -n "$outfile"; then
|
|
|
|
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.
|
|
|
|
$AWK '
|
|
|
|
{
|
|
|
|
sub(/[ ]*$/, "")
|
|
|
|
if ($0 == "")
|
|
|
|
{
|
|
|
|
if (!duplicate)
|
|
|
|
print
|
|
|
|
duplicate = 1
|
|
|
|
next
|
|
|
|
}
|
|
|
|
duplicate = 0
|
|
|
|
oline++
|
|
|
|
while (sub(/__oline__/, oline))
|
|
|
|
continue
|
|
|
|
while (sub(/@<:@/, "["))
|
|
|
|
continue
|
|
|
|
while (sub(/@:>@/, "]"))
|
|
|
|
continue
|
|
|
|
while (sub(/@S\|@/, "$"))
|
|
|
|
continue
|
|
|
|
while (sub(/@%:@/, "#"))
|
|
|
|
continue
|
|
|
|
print
|
2000-03-29 19:09:59 +08:00
|
|
|
}' <$tmp/configure >&4
|
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-03-13 23:31:26 +08:00
|
|
|
# `errprint' must be silent when we run `m4 --trace', otherwise there
|
|
|
|
# can be warnings mixed with traces in m4's stderr.
|
2000-03-29 19:09:59 +08:00
|
|
|
cat >$tmp/silent.m4 <<\EOF
|
2000-03-13 23:31:26 +08:00
|
|
|
define(`errprint')dnl
|
|
|
|
EOF
|
|
|
|
# A program to trace m4 macros.
|
2000-03-29 19:09:59 +08:00
|
|
|
cat >$tmp/trace.m4 <<\EOF
|
2000-03-13 23:31:26 +08:00
|
|
|
divert(-1)
|
|
|
|
changequote([, ])
|
|
|
|
define([_at],
|
|
|
|
[ifelse([$#], [1], [],
|
|
|
|
[$#], [2], [[[$2]]],
|
|
|
|
[[[$2]][$1]_at([$1], shift(shift($@)))])])
|
|
|
|
define([_star],
|
|
|
|
[ifelse([$#], [1], [],
|
|
|
|
[$#], [2], [smash([$2])],
|
|
|
|
[smash([$2])[$1]_star([$1], shift(shift($@)))])])
|
2000-03-14 16:30:41 +08:00
|
|
|
|
|
|
|
# Smash quotes its result.
|
2000-03-13 23:31:26 +08:00
|
|
|
define([smash],
|
2000-03-14 16:30:41 +08:00
|
|
|
[patsubst(patsubst(patsubst([[[$1]]],
|
2000-03-13 23:31:26 +08:00
|
|
|
[\\
|
|
|
|
]),
|
2000-03-14 16:30:41 +08:00
|
|
|
[[
|
|
|
|
]+],
|
|
|
|
[ ]),
|
|
|
|
[^ *\(.*\) *$], [[\1]])])
|
2000-03-13 23:31:26 +08:00
|
|
|
define([args],
|
|
|
|
[shift(shift(shift(shift(shift($@)))))])
|
|
|
|
define([at],
|
|
|
|
[_at([$1], args($@))])
|
|
|
|
define([star],
|
|
|
|
[_star([$1], args($@))])
|
|
|
|
EOF
|
|
|
|
# A program to translate user tracing requests into m4 macros.
|
2000-03-29 19:09:59 +08:00
|
|
|
cat >$tmp/translate.awk <<\EOF
|
2000-03-14 01:30:32 +08:00
|
|
|
function trans (arg, sep)
|
|
|
|
{
|
2000-03-13 23:31:26 +08:00
|
|
|
# File name.
|
2000-03-14 01:30:32 +08:00
|
|
|
if (arg == "f")
|
|
|
|
return "$1"
|
2000-03-13 23:31:26 +08:00
|
|
|
# Line number.
|
2000-03-14 01:30:32 +08:00
|
|
|
if (arg == "l")
|
|
|
|
return "$2"
|
2000-03-13 23:31:26 +08:00
|
|
|
# Depth.
|
2000-03-14 01:30:32 +08:00
|
|
|
if (arg == "d")
|
|
|
|
return "$3"
|
2000-03-13 23:31:26 +08:00
|
|
|
# Name (also available as $0).
|
2000-03-14 01:30:32 +08:00
|
|
|
if (arg == "n")
|
|
|
|
return "$4"
|
2000-03-13 23:31:26 +08:00
|
|
|
# Escaped dollar.
|
2000-03-14 01:30:32 +08:00
|
|
|
if (arg == "$")
|
|
|
|
return "$"
|
|
|
|
|
2000-03-13 23:31:26 +08:00
|
|
|
# $@, list of quoted effective arguments.
|
2000-03-14 01:30:32 +08:00
|
|
|
if (arg == "@")
|
|
|
|
return "]at([" (separator ? separator : ",") "], $@)["
|
2000-03-13 23:31:26 +08:00
|
|
|
# $*, list of unquoted effective arguments.
|
2000-03-14 01:30:32 +08:00
|
|
|
if (arg == "*")
|
|
|
|
return "]star([" (separator ? separator : ":") "], $@)["
|
|
|
|
}
|
|
|
|
|
|
|
|
function error (message)
|
|
|
|
{
|
2000-03-25 17:17:40 +08:00
|
|
|
print message | "cat >&2"
|
2000-03-14 01:30:32 +08:00
|
|
|
exit 1
|
2000-03-13 23:31:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2000-03-20 18:30:54 +08:00
|
|
|
# Accumulate the whole input.
|
|
|
|
request = request $0 "\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
END {
|
2000-03-27 20:19:01 +08:00
|
|
|
# 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:$*"
|
|
|
|
|
2000-03-14 01:30:32 +08:00
|
|
|
res = ""
|
2000-03-13 23:31:26 +08:00
|
|
|
|
2000-03-20 18:30:54 +08:00
|
|
|
for (cp = request; cp; cp = substr (cp, 2))
|
2000-03-13 23:31:26 +08:00
|
|
|
{
|
2000-03-14 01:30:32 +08:00
|
|
|
char = substr (cp, 1, 1)
|
2000-03-13 23:31:26 +08:00
|
|
|
if (char == "$")
|
|
|
|
{
|
|
|
|
if (match (cp, /^\$[0-9]+/))
|
|
|
|
{
|
|
|
|
# $n -> $(n + 4)
|
2000-03-14 01:30:32 +08:00
|
|
|
res = res "$" (substr (cp, 2, RLENGTH - 1) + 4)
|
|
|
|
cp = substr (cp, RLENGTH)
|
2000-03-13 23:31:26 +08:00
|
|
|
}
|
|
|
|
else if (substr (cp, 2, 1) ~ /[fldn$@*]/)
|
|
|
|
{
|
2000-03-14 01:30:32 +08:00
|
|
|
# $x, no separator given.
|
|
|
|
res = res trans(substr (cp, 2, 1))
|
|
|
|
cp = substr (cp, 2)
|
2000-03-13 23:31:26 +08:00
|
|
|
}
|
2000-03-14 01:30:32 +08:00
|
|
|
else if (substr (cp, 2, 1) == "{")
|
2000-03-13 23:31:26 +08:00
|
|
|
{
|
2000-03-14 01:30:32 +08:00
|
|
|
# ${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) ~ /[$@]/)
|
2000-03-13 23:31:26 +08:00
|
|
|
{
|
2000-03-14 01:30:32 +08:00
|
|
|
# $sx, short separator `s'.
|
|
|
|
res = res trans(substr (cp, 3, 1), substr (cp, 2, 1))
|
|
|
|
cp = substr(cp, 3)
|
2000-03-13 23:31:26 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-03-14 01:30:32 +08:00
|
|
|
error("invalid escape: " substr (cp, 1, 2))
|
2000-03-13 23:31:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2000-03-14 01:30:32 +08:00
|
|
|
res = res char
|
2000-03-13 23:31:26 +08:00
|
|
|
}
|
2000-03-27 20:19:01 +08:00
|
|
|
|
|
|
|
# Produce the definition of AT_<MACRO> = the translation of the request.
|
|
|
|
print "define([AT_" macro "], [[" res "]])"
|
2000-03-25 17:17:40 +08:00
|
|
|
close("cat >&2")
|
2000-03-13 23:31:26 +08:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
# Extract both the m4 program and the m4 options from TRACES.
|
2000-03-14 01:30:32 +08:00
|
|
|
eval set dummy "$traces"
|
2000-03-13 23:31:26 +08:00
|
|
|
shift
|
|
|
|
for trace
|
|
|
|
do
|
|
|
|
# The request may be several lines long, hence sed has to quit.
|
|
|
|
trace_opt="$trace_opt -t "`echo "$trace" | sed -e 's/:.*//;q'`
|
2000-03-29 19:09:59 +08:00
|
|
|
echo "$trace" | $AWK -f $tmp/translate.awk >>$tmp/trace.m4 || exit 1
|
2000-03-13 23:31:26 +08:00
|
|
|
done
|
2000-03-29 19:09:59 +08:00
|
|
|
echo "divert(0)dnl" >>$tmp/trace.m4
|
2000-03-13 23:31:26 +08:00
|
|
|
|
|
|
|
# Do we trace the initialization?
|
|
|
|
if $initialization; then
|
2000-03-29 19:09:59 +08:00
|
|
|
run_m4_trace="$run_m4 $trace_opt -daflq $tmp/silent.m4"
|
2000-03-13 23:31:26 +08:00
|
|
|
else
|
2000-03-29 19:09:59 +08:00
|
|
|
run_m4_trace="$run_m4f $trace_opt -daflq $tmp/silent.m4"
|
2000-03-13 23:31:26 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Run m4 on the input file to get traces.
|
2000-03-29 19:09:59 +08:00
|
|
|
$verbose "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 |
|
|
|
|
sed -e 's/^m4trace:\([^:][^:]*\):\([0-9][0-9]*\): -\([0-9][0-9]*\)- \([^(][^(]*\)(\(.*\)$/AT_\4([\1], [\2], [\3], [\4], \5/' \
|
2000-03-21 20:06:30 +08:00
|
|
|
-e 's/^m4trace:\([^:][^:]*\):\([0-9][0-9]*\): -\([0-9][0-9]*\)- \(.*\)$/AT_\4([\1], [\2], [\3], [\4])/' |
|
2000-03-13 23:31:26 +08:00
|
|
|
# Now we are ready to run m4 to process the trace file.
|
2000-03-29 19:09:59 +08:00
|
|
|
$M4 $tmp/trace.m4 - |
|
2000-03-14 01:30:32 +08:00
|
|
|
# It makes no sense to try to transform __oline__.
|
2000-03-21 20:06:30 +08:00
|
|
|
sed '
|
|
|
|
s/@<:@/[/g
|
|
|
|
s/@:>@/]/g
|
|
|
|
s/@S|@/$/g
|
|
|
|
s/@%:@/#/g
|
|
|
|
' >&4
|
2000-01-29 17:22:53 +08:00
|
|
|
;;
|
|
|
|
|
2000-01-29 17:54:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## -------------------------------------------------------- ##
|
|
|
|
## Task --install. Install links to the library m4 files. ##
|
|
|
|
## -------------------------------------------------------- ##
|
|
|
|
install)
|
|
|
|
# An m4 program that reports what macros are requested, and where
|
|
|
|
# they were defined.
|
2000-03-29 19:09:59 +08:00
|
|
|
cat >$tmp/request.m4 <<\EOF
|
2000-01-29 17:54:27 +08:00
|
|
|
dnl Keep the definition of the old AC_DEFUN
|
|
|
|
define([AC_DEFUN_OLD], defn([AC_DEFUN]))
|
|
|
|
|
|
|
|
dnl Define the macro so that the first time it is expanded, it reports
|
|
|
|
dnl on stderr its name, and where it was defined.
|
|
|
|
define([AC_DEFUN],
|
|
|
|
[AC_DEFUN_OLD([$1],
|
|
|
|
[ifdef([AC_DECLARED{$1}],,
|
|
|
|
[define([AC_DECLARED{$1}])errprint(]]__file__:__line__:[[ [$1]
|
|
|
|
)])dnl
|
|
|
|
][$2])])
|
|
|
|
|
|
|
|
dnl All the includes must be disabled. If they are not, since people don't
|
|
|
|
dnl protect the first argument of AC_DEFUN, then, if read a second time
|
|
|
|
dnl this argument will be expanded, and we'll get pure junk out of m4.
|
|
|
|
define([AC_INCLUDE])
|
|
|
|
EOF
|
2000-03-29 19:09:59 +08:00
|
|
|
|
|
|
|
# Run m4 with all the library files, discard stdout, save stderr in
|
|
|
|
# $requested.
|
|
|
|
run_m4_request="$run_m4f -dipa -t m4_include -t m4_sinclude $tmp/request.m4"
|
|
|
|
$verbose $run_m4_request $localdir/*.m4 $AC_ACLOCALDIR/*.m4 $infile >&2
|
|
|
|
$run_m4_request $localdir/*.m4 $AC_ACLOCALDIR/*.m4 $infile 2>&1 >/dev/null |
|
|
|
|
# Keep only the good lines, there may be other outputs
|
|
|
|
grep '^[^: ]*:[0-9][0-9]*:[^:]*$' >$tmp/requested
|
|
|
|
|
2000-01-29 17:54:27 +08:00
|
|
|
# Extract the files that are not in the local dir, and install the links.
|
2000-03-29 19:09:59 +08:00
|
|
|
# Save in `installed' the list of installed links.
|
2000-03-13 23:31:26 +08:00
|
|
|
$verbose "Required macros:" >&2
|
2000-03-29 19:09:59 +08:00
|
|
|
$verbose "`sed -e 's/^/| /' $tmp/requested`" >&2
|
|
|
|
cat $tmp/requested |
|
2000-01-29 17:54:27 +08:00
|
|
|
while read line
|
|
|
|
do
|
|
|
|
file=`echo "$line" | sed -e 's/:.*//'`
|
|
|
|
filename=`echo "$file" | sed -e 's,.*/,,'`
|
|
|
|
macro=`echo "$line" | sed -e 's/.*:[ ]*//'`
|
|
|
|
if test -f "$file" && test "x$file" != "x$infile"; then
|
|
|
|
if test -f $localdir/$filename; then
|
2000-03-13 23:31:26 +08:00
|
|
|
$verbose "$filename already installed" >&2
|
2000-01-29 17:54:27 +08:00
|
|
|
else
|
2000-03-13 23:31:26 +08:00
|
|
|
$verbose "installing $file which provides $macro" >&2
|
2000-01-29 17:54:27 +08:00
|
|
|
ln -s "$file" "$localdir/$filename" ||
|
|
|
|
cp "$file" "$localdir/$filename" ||
|
|
|
|
{
|
2000-02-08 19:39:46 +08:00
|
|
|
echo "$me: cannot link from $file to $localdir/$filename" >&2
|
2000-01-29 17:54:27 +08:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
fi
|
2000-03-29 19:09:59 +08:00
|
|
|
echo "$localdir/$filename" >>$tmp/installed
|
2000-01-29 17:54:27 +08:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
# Now that we have installed the links, and that we know that the
|
|
|
|
# user needs the FILES, check that there is an exact correspondence.
|
|
|
|
# Use yourself to get the list of the included files.
|
|
|
|
export AC_ACLOCALDIR
|
|
|
|
export AC_MACRODIR
|
|
|
|
# Not m4_s?include, because it would catch acsite and aclocal, which
|
2000-03-13 23:31:26 +08:00
|
|
|
# we don't care about.
|
2000-03-29 19:09:59 +08:00
|
|
|
$0 -l "$localdir" -t AC_INCLUDE:'$1' $infile |
|
2000-01-29 17:54:27 +08:00
|
|
|
sort |
|
2000-03-29 19:09:59 +08:00
|
|
|
uniq >$tmp/included
|
2000-01-29 17:54:27 +08:00
|
|
|
# All the included files are needed.
|
2000-03-29 19:09:59 +08:00
|
|
|
for file in `cat $tmp/included`;
|
2000-01-29 17:54:27 +08:00
|
|
|
do
|
2000-03-29 19:09:59 +08:00
|
|
|
if fgrep "$file" $tmp/installed >/dev/null 2>&1; then :; else
|
2000-01-29 17:54:27 +08:00
|
|
|
echo "\`$file' is uselessly included" >&2
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
# All the needed files are included.
|
2000-03-29 19:09:59 +08:00
|
|
|
for file in `sort $tmp/installed | uniq`;
|
2000-01-29 17:54:27 +08:00
|
|
|
do
|
2000-03-29 19:09:59 +08:00
|
|
|
if fgrep "$file" $tmp/included >/dev/null 2>&1; then :; else
|
2000-01-29 17:54:27 +08:00
|
|
|
echo "\`$file' is not included" >&2
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## ------------ ##
|
|
|
|
## Unknown task ##
|
|
|
|
## ------------ ##
|
|
|
|
|
2000-02-08 19:39:46 +08:00
|
|
|
*)echo "$me: internal error: unknown task: $task" >&2
|
2000-01-29 17:22:53 +08:00
|
|
|
exit 1
|
|
|
|
esac
|
1994-09-16 02:34:35 +08:00
|
|
|
|
1993-06-17 04:15:11 +08:00
|
|
|
exit $status
|