1998-09-03 08:32:51 +08:00
|
|
|
#! @SHELL@
|
1993-08-02 06:27:47 +08:00
|
|
|
# autoheader -- create `config.h.in' from `configure.in'
|
2000-02-10 21:12:04 +08:00
|
|
|
# Copyright (C) 1992-94, 96, 98, 99, 2000 Free Software Foundation, Inc.
|
1993-08-02 06:27:47 +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-08-02 06:27:47 +08:00
|
|
|
|
|
|
|
# Written by Roland McGrath.
|
|
|
|
|
|
|
|
# If given no args, create `config.h.in' from template file `configure.in'.
|
|
|
|
# With one arg, create a header file 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="\
|
2000-02-10 21:12:04 +08:00
|
|
|
Usage: $0 [OPTION] ... [TEMPLATE-FILE]
|
1999-01-08 11:38:59 +08:00
|
|
|
|
|
|
|
Create a template file of C \`#define' statements for \`configure' to
|
|
|
|
use. To this end, scan TEMPLATE-FILE, or \`configure.in' if none
|
|
|
|
given.
|
|
|
|
|
2000-05-03 19:22:50 +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 \`aclocal.m4' and \`acconfig.h'
|
|
|
|
-W, --warnings=CATEGORY report the warnings falling in CATEGORY
|
|
|
|
|
|
|
|
Warning categories include:
|
|
|
|
\`obsolete' obsolete constructs
|
|
|
|
\`all' all the warnings
|
|
|
|
\`error' warnings are error
|
1999-01-08 11:38:59 +08:00
|
|
|
Report bugs to <bug-autoconf@gnu.org>."
|
1993-08-02 06:27:47 +08:00
|
|
|
|
2000-01-10 18:11:57 +08:00
|
|
|
version="\
|
|
|
|
autoheader (GNU @PACKAGE@) @VERSION@
|
|
|
|
Written by Roland McGrath.
|
|
|
|
|
2000-02-10 21:12:04 +08:00
|
|
|
Copyright (C) 1992-94, 96, 98, 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-08-02 06:27:47 +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-08-02 06:27:47 +08:00
|
|
|
|
2000-03-14 01:26:21 +08:00
|
|
|
# Variables.
|
|
|
|
: ${AC_MACRODIR=@datadir@}
|
2000-02-09 01:23:25 +08:00
|
|
|
debug=false
|
2000-03-14 01:26:21 +08:00
|
|
|
localdir=.
|
2000-03-31 16:20:09 +08:00
|
|
|
tmp=
|
2000-03-14 01:26:21 +08:00
|
|
|
verbose=:
|
2000-05-03 19:22:50 +08:00
|
|
|
warning_all=false
|
|
|
|
warning_error=false
|
|
|
|
warning_obsolete=false
|
1994-09-16 02:34:35 +08:00
|
|
|
|
1993-08-02 06:27:47 +08:00
|
|
|
while test $# -gt 0 ; do
|
2000-03-14 01:26:21 +08:00
|
|
|
case "$1" in
|
|
|
|
--version | --vers* | -V )
|
|
|
|
echo "$version" ; exit 0 ;;
|
|
|
|
--help | --h* | -h )
|
|
|
|
echo "$usage"; exit 0 ;;
|
|
|
|
|
|
|
|
--debug | --d* | -d )
|
|
|
|
debug=:; shift ;;
|
|
|
|
--verbose | --verb* | -v )
|
|
|
|
verbose=echo
|
|
|
|
shift;;
|
|
|
|
|
|
|
|
--localdir=* | --l*=* )
|
|
|
|
localdir=`echo "$1" | sed -e 's/^[^=]*=//'`
|
|
|
|
shift ;;
|
|
|
|
--localdir | --l* | -l )
|
|
|
|
shift
|
|
|
|
test $# = 0 && { echo "$help" >&2; exit 1; }
|
|
|
|
localdir=$1
|
|
|
|
shift ;;
|
|
|
|
|
|
|
|
--macrodir=* | --m*=* )
|
|
|
|
AC_MACRODIR=`echo "$1" | sed -e 's/^[^=]*=//'`
|
|
|
|
shift ;;
|
|
|
|
--macrodir | --m* | -m )
|
|
|
|
shift
|
|
|
|
test $# = 0 && { echo "$help" >&2; exit 1; }
|
|
|
|
AC_MACRODIR=$1
|
|
|
|
shift ;;
|
|
|
|
|
2000-05-03 19:22:50 +08:00
|
|
|
--warnings | -W )
|
|
|
|
shift
|
|
|
|
test $# = 0 && { echo "$help" >&2; exit 1; }
|
|
|
|
warnings="$warnings "`echo $1 | sed -e 's/,/ /g'`
|
|
|
|
shift ;;
|
|
|
|
--warnings=* )
|
|
|
|
warnings="$warnings "`echo "$1" | sed -e 's/^[^=]*=//;s/,/ /g'`
|
|
|
|
shift ;;
|
|
|
|
-W* ) # People are used to -Wall, -Werror etc.
|
|
|
|
warnings="$warnings "`echo "$1" | sed -e 's/^-W//;s/,/ /g'`
|
|
|
|
shift ;;
|
|
|
|
|
2000-03-14 01:26:21 +08:00
|
|
|
-- ) # Stop option processing
|
|
|
|
shift; break ;;
|
|
|
|
- ) # Use stdin as input.
|
|
|
|
break ;;
|
|
|
|
-* )
|
|
|
|
exec >&2
|
|
|
|
echo "$me: invalid option $1"
|
|
|
|
echo "$help"
|
|
|
|
exit 1 ;;
|
|
|
|
* )
|
|
|
|
break ;;
|
|
|
|
esac
|
1993-08-02 06:27:47 +08:00
|
|
|
done
|
|
|
|
|
2000-05-03 19:22:50 +08:00
|
|
|
# Decode `$warnings'.
|
|
|
|
for i in :$warnings
|
|
|
|
do
|
|
|
|
test "$i" = : && continue
|
|
|
|
eval "warning_$i=:"
|
|
|
|
done
|
|
|
|
|
2000-03-31 16:20:09 +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
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create a (secure) tmp directory for tmp files.
|
|
|
|
: ${TMPDIR=/tmp}
|
|
|
|
{
|
|
|
|
tmp=`(umask 077 && mktemp -d -q "$TMPDIR/ahXXXXXX") 2>/dev/null` &&
|
|
|
|
test -n "$tmp"
|
|
|
|
} ||
|
|
|
|
{
|
|
|
|
tmp=$TMPDIR/ah$$ && (umask 077 && mkdir $tmp)
|
|
|
|
} ||
|
|
|
|
{
|
|
|
|
echo "$me: cannot create a temporary directory in $TMPDIR" >&2
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
2000-05-03 19:22:50 +08:00
|
|
|
# Preach.
|
|
|
|
if ($warning_all || $warning_obsolete) &&
|
|
|
|
(test -f $config_h.top ||
|
|
|
|
test -f $config_h.bot ||
|
|
|
|
test -f $localdir/acconfig.h); then
|
2000-05-19 21:21:05 +08:00
|
|
|
sed -e "s/^ //;s/^/$me: WARNING: /" >&2 <<\EOF
|
2000-05-03 19:22:50 +08:00
|
|
|
Using auxiliary files such as `acconfig.h', `config.h.bot'
|
|
|
|
and `config.h.top', to define templates for `config.h.in'
|
|
|
|
is deprecated and discouraged.
|
|
|
|
|
|
|
|
Using the third argument of `AC_DEFINE' and
|
|
|
|
`AC_DEFINE_UNQUOTED' allows to define a template without
|
|
|
|
`acconfig.h':
|
|
|
|
|
|
|
|
AC_DEFINE([NEED_MAIN], 1,
|
|
|
|
[Define if a function `main' is needed.])
|
|
|
|
|
|
|
|
More sophisticated templates can also be produced, see the
|
|
|
|
documentation.
|
|
|
|
EOF
|
|
|
|
$warning_error && exit 1
|
|
|
|
fi
|
|
|
|
|
2000-01-29 17:24:30 +08:00
|
|
|
acconfigs=
|
2000-02-08 19:39:46 +08:00
|
|
|
test -r $localdir/acconfig.h && acconfigs="$acconfigs $localdir/acconfig.h"
|
1993-08-02 06:27:47 +08:00
|
|
|
|
2000-03-14 01:26:21 +08:00
|
|
|
# Find the input file.
|
1993-08-02 06:27:47 +08:00
|
|
|
case $# in
|
1994-09-01 12:59:32 +08:00
|
|
|
0) infile=configure.in ;;
|
1993-08-02 06:27:47 +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 ;;
|
1993-08-02 06:27:47 +08:00
|
|
|
esac
|
|
|
|
|
2000-03-14 01:26:21 +08:00
|
|
|
# Well, work now!
|
|
|
|
config_h=
|
|
|
|
syms=
|
|
|
|
|
2000-03-30 00:48:00 +08:00
|
|
|
# Source what the traces are trying to tell us.
|
2000-05-03 19:00:46 +08:00
|
|
|
autoconf=`echo "$0" | sed -e 's,[^/]*$,autoconf,'`
|
2000-03-30 00:48:00 +08:00
|
|
|
test -n "$localdir" && autoconf="$autoconf -l $localdir"
|
|
|
|
export AC_MACRODIR
|
2000-05-03 19:00:46 +08:00
|
|
|
$autoconf \
|
|
|
|
--trace AC_CONFIG_HEADERS:'config_h="$1"' \
|
|
|
|
--trace AH_OUTPUT:'ac_verbatim_$1="\
|
2000-05-03 16:53:06 +08:00
|
|
|
$2"' \
|
2000-05-03 19:00:46 +08:00
|
|
|
--trace AC_DEFINE:'syms="$$syms $1"' \
|
|
|
|
--trace AC_DEFINE_UNQUOTED:'syms="$$syms $1"' \
|
|
|
|
$infile >$tmp/traces.sh || exit 1
|
2000-03-31 16:20:09 +08:00
|
|
|
. $tmp/traces.sh
|
1993-08-02 06:27:47 +08:00
|
|
|
|
|
|
|
# Make SYMS newline-separated rather than blank-separated, and remove dups.
|
1994-08-09 22:46:16 +08:00
|
|
|
# Start each symbol with a blank (to match the blank after "#undef")
|
|
|
|
# to reduce the possibility of mistakenly matching another symbol that
|
|
|
|
# is a substring of it.
|
2000-05-03 19:00:46 +08:00
|
|
|
# Beware that some of the symbols might actually be macro with arguments:
|
|
|
|
# keep only their name.
|
|
|
|
syms=`for sym in $syms; do echo $sym; done |
|
|
|
|
sed -e 's/(.*//' |
|
|
|
|
sort |
|
|
|
|
uniq |
|
|
|
|
sed -e 's@^@ @'`
|
1993-08-02 06:27:47 +08:00
|
|
|
|
2000-03-30 00:48:00 +08:00
|
|
|
|
|
|
|
# We template only the first CONFIG_HEADER.
|
|
|
|
config_h=`echo "$config_h" | sed -e 's/ .*//'`
|
1994-08-10 02:35:50 +08:00
|
|
|
# Support "outfile[:infile]", defaulting infile="outfile.in".
|
|
|
|
case "$config_h" in
|
2000-02-08 19:39:46 +08:00
|
|
|
"") echo "$me: error: AC_CONFIG_HEADERS not found in $infile" >&2; exit 1 ;;
|
|
|
|
*:*) config_h_in=`echo "$config_h" | sed 's/.*://'`
|
|
|
|
config_h=`echo "$config_h" | sed 's/:.*//'` ;;
|
|
|
|
*) config_h_in="$config_h.in" ;;
|
1994-08-10 02:35:50 +08:00
|
|
|
esac
|
|
|
|
|
1993-08-02 06:27:47 +08:00
|
|
|
# Don't write "do not edit" -- it will get copied into the
|
|
|
|
# config.h, which it's ok to edit.
|
2000-05-03 16:53:06 +08:00
|
|
|
cat <<EOF >$tmp/config.hin
|
2000-02-08 19:39:46 +08:00
|
|
|
/* $config_h_in. Generated automatically from $infile by autoheader. */
|
1996-11-10 06:19:24 +08:00
|
|
|
EOF
|
1993-08-02 06:27:47 +08:00
|
|
|
|
2000-05-03 19:22:50 +08:00
|
|
|
# Dump the top.
|
|
|
|
test -r $config_h.top && cat $config_h.top >>$tmp/config.hin
|
1994-03-25 07:10:53 +08:00
|
|
|
|
2000-05-03 19:22:50 +08:00
|
|
|
# Dump `acconfig.h' but its bottom.
|
|
|
|
test -r $localdir/acconfig.h &&
|
|
|
|
sed -e '/@BOTTOM@/,$d' -e 's/@TOP@//' $localdir/acconfig.h >>$tmp/config.hin
|
1993-08-02 06:27:47 +08:00
|
|
|
|
2000-05-03 19:22:50 +08:00
|
|
|
# Dump the templates from `configure.in'.
|
2000-05-03 23:43:40 +08:00
|
|
|
for verb in `(set) 2>&1 | sed -n -e '/^ac_verbatim/s/^\([^=]*\)=.*$/\1/p' | sort`; do
|
2000-05-03 16:53:06 +08:00
|
|
|
echo >>$tmp/config.hin
|
|
|
|
eval echo '"${'$verb'}"' >>$tmp/config.hin
|
1994-04-20 02:14:23 +08:00
|
|
|
done
|
|
|
|
|
1995-02-22 04:39:40 +08:00
|
|
|
# Handle the case where @BOTTOM@ is the first line of acconfig.h.
|
1994-09-16 02:34:35 +08:00
|
|
|
test -r $localdir/acconfig.h &&
|
|
|
|
grep @BOTTOM@ $localdir/acconfig.h >/dev/null &&
|
2000-05-03 16:53:06 +08:00
|
|
|
sed -n '/@BOTTOM@/,${/@BOTTOM@/!p;}' $localdir/acconfig.h >>$tmp/config.hin
|
2000-05-03 19:22:50 +08:00
|
|
|
test -f $config_h.bot && cat $config_h.bot >>$tmp/config.hin
|
1994-05-03 07:48:08 +08:00
|
|
|
|
1993-08-02 06:27:47 +08:00
|
|
|
|
2000-03-25 17:16:53 +08:00
|
|
|
# Check that all the symbols have a template.
|
|
|
|
status=0
|
|
|
|
# Regexp for a white space.
|
|
|
|
w='[ ]'
|
1994-09-18 11:32:50 +08:00
|
|
|
if test -n "$syms"; then
|
|
|
|
for sym in $syms; do
|
2000-05-03 16:53:06 +08:00
|
|
|
if egrep "^#$w*[a-z]*$w$w*$sym($w*|$w.*)$" $tmp/config.hin >/dev/null; then
|
1994-09-18 11:32:50 +08:00
|
|
|
: # All is well.
|
|
|
|
else
|
2000-05-03 19:22:50 +08:00
|
|
|
echo "$me: No template for symbol \`$sym'" >&2
|
1994-09-18 11:32:50 +08:00
|
|
|
status=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
1993-08-02 06:27:47 +08:00
|
|
|
|
2000-03-25 17:16:53 +08:00
|
|
|
|
1999-10-30 22:17:20 +08:00
|
|
|
# If the run was successful, output the result.
|
2000-03-14 01:26:21 +08:00
|
|
|
if test $status = 0; then
|
|
|
|
if test $# = 0; then
|
1999-10-30 22:17:20 +08:00
|
|
|
# Output is a file
|
2000-05-03 16:53:06 +08:00
|
|
|
if test -f $config_h_in && cmp -s $tmp/config.hin $config_h_in; then
|
2000-01-10 18:06:51 +08:00
|
|
|
# File didn't change, so don't update its mod time.
|
2000-05-03 19:22:50 +08:00
|
|
|
echo "$me: $config_h_in is unchanged" >&2
|
1994-04-05 08:13:00 +08:00
|
|
|
else
|
2000-05-03 16:53:06 +08:00
|
|
|
mv -f $tmp/config.hin $config_h_in
|
1994-04-05 08:13:00 +08:00
|
|
|
fi
|
1993-08-02 06:27:47 +08:00
|
|
|
else
|
1999-10-30 22:17:20 +08:00
|
|
|
# Output is stdout
|
2000-05-03 16:53:06 +08:00
|
|
|
cat $tmp/config.hin
|
1993-08-02 06:27:47 +08:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit $status
|