1995-02-07 07:31:34 +08:00
|
|
|
#! /bin/sh
|
1993-08-02 06:27:47 +08:00
|
|
|
# autoheader -- create `config.h.in' from `configure.in'
|
1996-05-27 07:43:22 +08:00
|
|
|
# Copyright (C) 1992, 1993, 1994, 1996 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.
|
|
|
|
|
1994-05-05 01:34:32 +08:00
|
|
|
usage="\
|
1996-05-27 07:43:22 +08:00
|
|
|
Usage: autoheader [-h] [--help] [-m dir] [--macrodir=dir]
|
|
|
|
[-l dir] [--localdir=dir] [--version] [template-file]"
|
1993-08-02 06:27:47 +08:00
|
|
|
|
|
|
|
# NLS nuisances.
|
1994-05-04 22:44:23 +08:00
|
|
|
# Only set `LANG' and `LC_ALL' to "C" if already set.
|
1993-08-02 06:27:47 +08:00
|
|
|
# These must not be set unconditionally because not all systems understand
|
|
|
|
# e.g. LANG=C (notably SCO).
|
1994-05-05 23:49:35 +08:00
|
|
|
if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
|
|
|
|
if test "${LANG+set}" = set; then LANG=C; export LANG; fi
|
1993-08-02 06:27:47 +08:00
|
|
|
|
|
|
|
test -z "${AC_MACRODIR}" && AC_MACRODIR=@datadir@
|
|
|
|
test -z "${M4}" && M4=@M4@
|
1994-05-03 07:48:08 +08:00
|
|
|
case "${M4}" in
|
|
|
|
/*) # Handle the case that m4 has moved since we were configured.
|
|
|
|
# It may have been found originally in a build directory.
|
|
|
|
test -f "${M4}" || M4=m4 ;;
|
|
|
|
esac
|
1993-08-02 06:27:47 +08:00
|
|
|
|
1994-09-16 02:34:35 +08:00
|
|
|
localdir=.
|
1994-09-01 12:59:32 +08:00
|
|
|
show_version=no
|
1994-09-16 02:34:35 +08:00
|
|
|
|
1993-08-02 06:27:47 +08:00
|
|
|
while test $# -gt 0 ; do
|
1996-05-27 07:43:22 +08:00
|
|
|
case "${1}" in
|
1994-09-16 02:34:35 +08:00
|
|
|
-h | --help | --h* )
|
1993-08-02 06:27:47 +08:00
|
|
|
echo "${usage}"; exit 0 ;;
|
1994-09-16 02:34:35 +08:00
|
|
|
--localdir=* | --l*=* )
|
|
|
|
localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
|
|
|
|
shift ;;
|
|
|
|
-l | --localdir | --l*)
|
|
|
|
shift
|
|
|
|
test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
|
|
|
|
localdir="${1}"
|
|
|
|
shift ;;
|
|
|
|
--macrodir=* | --m*=* )
|
1993-08-02 06:27:47 +08:00
|
|
|
AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
|
|
|
|
shift ;;
|
1996-05-27 07:43:22 +08:00
|
|
|
-m | --macrodir | --m* )
|
1993-08-02 06:27:47 +08:00
|
|
|
shift
|
|
|
|
test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
|
|
|
|
AC_MACRODIR="${1}"
|
|
|
|
shift ;;
|
1994-09-16 02:34:35 +08:00
|
|
|
--version | --v* )
|
1994-09-01 12:59:32 +08:00
|
|
|
show_version=yes; shift ;;
|
1994-09-16 02:34:35 +08:00
|
|
|
-- ) # Stop option processing
|
1993-08-02 06:27:47 +08:00
|
|
|
shift; break ;;
|
1994-09-16 02:34:35 +08:00
|
|
|
- ) # Use stdin as input.
|
1993-08-02 06:27:47 +08:00
|
|
|
break ;;
|
1994-09-16 02:34:35 +08:00
|
|
|
-* )
|
1993-08-02 06:27:47 +08:00
|
|
|
echo "${usage}" 1>&2; exit 1 ;;
|
|
|
|
* )
|
|
|
|
break ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
1994-09-01 12:59:32 +08:00
|
|
|
if test $show_version = yes; then
|
|
|
|
version=`sed -n 's/define.AC_ACVERSION.[ ]*\([0-9.]*\).*/\1/p' \
|
|
|
|
$AC_MACRODIR/acgeneral.m4`
|
|
|
|
echo "Autoconf version $version"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
1993-08-02 06:27:47 +08:00
|
|
|
TEMPLATES="${AC_MACRODIR}/acconfig.h"
|
1996-11-10 06:19:24 +08:00
|
|
|
# Disabled until I figure out whether it's really right.
|
|
|
|
#if test "$localdir" != .; then
|
|
|
|
# When running autoheader from autoreconf, this is how we get
|
|
|
|
# subdirectories' acconfig.h files.
|
|
|
|
test -r ./acconfig.h && TEMPLATES="${TEMPLATES} ./acconfig.h"
|
|
|
|
#fi
|
1994-09-16 02:34:35 +08:00
|
|
|
test -r $localdir/acconfig.h && TEMPLATES="${TEMPLATES} $localdir/acconfig.h"
|
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 ;;
|
|
|
|
*) echo "$usage" >&2; exit 1 ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
config_h=config.h
|
|
|
|
syms=
|
1994-04-20 02:14:23 +08:00
|
|
|
types=
|
1993-08-02 06:27:47 +08:00
|
|
|
funcs=
|
|
|
|
headers=
|
|
|
|
libs=
|
|
|
|
|
1994-09-16 02:34:35 +08:00
|
|
|
if test "$localdir" != .; then
|
1994-09-16 05:16:59 +08:00
|
|
|
use_localdir="-I$localdir -DAC_LOCALDIR=$localdir"
|
1994-09-16 02:34:35 +08:00
|
|
|
else
|
|
|
|
use_localdir=
|
|
|
|
fi
|
|
|
|
|
1994-08-31 04:24:50 +08:00
|
|
|
# Use the frozen version of Autoconf if available.
|
|
|
|
r= f=
|
|
|
|
# Some non-GNU m4's don't reject the --help option, so give them /dev/null.
|
|
|
|
case `$M4 --help < /dev/null 2>&1` in
|
|
|
|
*reload-state*) test -r $AC_MACRODIR/autoheader.m4f && { r=--reload f=f; } ;;
|
|
|
|
*traditional*) ;;
|
1994-08-31 04:30:03 +08:00
|
|
|
*) echo Autoconf requires GNU m4 1.1 or later >&2; exit 1 ;;
|
1994-08-31 04:24:50 +08:00
|
|
|
esac
|
|
|
|
|
|
|
|
# Extract assignments of SYMS, TYPES, FUNCS, HEADERS, and LIBS from the
|
1993-08-02 06:27:47 +08:00
|
|
|
# modified autoconf processing of the input file. The sed hair is
|
|
|
|
# necessary to win for multi-line macro invocations.
|
1994-09-16 02:34:35 +08:00
|
|
|
eval "`$M4 -I$AC_MACRODIR $use_localdir $r autoheader.m4$f $infile |
|
1994-08-23 23:04:53 +08:00
|
|
|
sed -n -e '
|
1993-08-02 06:27:47 +08:00
|
|
|
: again
|
|
|
|
/^@@@.*@@@$/s/^@@@\(.*\)@@@$/\1/p
|
|
|
|
/^@@@/{
|
|
|
|
s/^@@@//p
|
|
|
|
n
|
|
|
|
s/^/@@@/
|
|
|
|
b again
|
|
|
|
}'`"
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
syms="`for sym in $syms; do echo $sym; done | sort | uniq | sed 's@^@ @'`"
|
1993-08-02 06:27:47 +08:00
|
|
|
|
|
|
|
if test $# -eq 0; then
|
|
|
|
tmpout=autoh$$
|
1994-03-18 15:58:56 +08:00
|
|
|
trap "rm -f $tmpout; exit 1" 1 2 15
|
1993-08-02 06:27:47 +08:00
|
|
|
exec > $tmpout
|
|
|
|
fi
|
|
|
|
|
1994-08-10 02:35:50 +08:00
|
|
|
# Support "outfile[:infile]", defaulting infile="outfile.in".
|
|
|
|
case "$config_h" in
|
|
|
|
*:*) config_h_in=`echo "$config_h"|sed 's%.*:%%'`
|
|
|
|
config_h=`echo "$config_h"|sed 's%:.*%%'` ;;
|
|
|
|
*) config_h_in="${config_h}.in" ;;
|
|
|
|
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.
|
1996-11-10 06:19:24 +08:00
|
|
|
cat <<EOF
|
|
|
|
/* ${config_h_in}. Generated automatically from $infile by autoheader. */
|
|
|
|
|
|
|
|
#ifndef _CONFIG_H
|
|
|
|
#define _CONFIG_H
|
|
|
|
EOF
|
1993-08-02 06:27:47 +08:00
|
|
|
|
1994-08-10 02:35:50 +08:00
|
|
|
test -r ${config_h}.top && cat ${config_h}.top
|
1994-09-16 02:34:35 +08:00
|
|
|
test -r $localdir/acconfig.h &&
|
|
|
|
grep @TOP@ $localdir/acconfig.h >/dev/null &&
|
|
|
|
sed '/@TOP@/,$d' $localdir/acconfig.h
|
1994-03-25 07:10:53 +08:00
|
|
|
|
1994-08-09 22:46:16 +08:00
|
|
|
# This puts each template paragraph on its own line, separated by @s.
|
1993-08-02 06:27:47 +08:00
|
|
|
if test -n "$syms"; then
|
|
|
|
# Make sure the boundary of template files is also the boundary
|
|
|
|
# of the paragraph. Extra newlines don't hurt since they will
|
|
|
|
# be removed.
|
|
|
|
for t in $TEMPLATES; do cat $t; echo; echo; done |
|
|
|
|
# The sed script is suboptimal because it has to take care of
|
|
|
|
# some broken seds (e.g. AIX) that remove '\n' from the
|
|
|
|
# pattern/hold space if the line is empty. (junio@twinsun.com).
|
|
|
|
sed -n -e '
|
|
|
|
/^[ ]*$/{
|
|
|
|
x
|
|
|
|
s/\n/@/g
|
|
|
|
p
|
|
|
|
s/.*/@/
|
|
|
|
x
|
|
|
|
}
|
|
|
|
H' | sed -e 's/@@*/@/g' |
|
|
|
|
# Select each paragraph that refers to a symbol we picked out above.
|
1996-05-27 07:43:22 +08:00
|
|
|
# Some fgrep's have limits on the number of lines that can be in the
|
|
|
|
# pattern on the command line, so use a temporary file containing the
|
|
|
|
# pattern.
|
|
|
|
(fgrep_tmp=${TMPDIR-/tmp}/autoh$$
|
|
|
|
trap "rm -f $fgrep_tmp; exit 1" 1 2 15
|
|
|
|
cat > $fgrep_tmp <<EOF
|
|
|
|
$syms
|
|
|
|
EOF
|
|
|
|
fgrep -f $fgrep_tmp
|
|
|
|
rm -f $fgrep_tmp) |
|
1993-08-02 06:27:47 +08:00
|
|
|
tr @ \\012
|
|
|
|
fi
|
|
|
|
|
1994-04-20 02:14:23 +08:00
|
|
|
echo "$types" | tr , \\012 | sort | uniq | while read ctype; do
|
|
|
|
test -z "$ctype" && continue
|
1995-11-18 05:55:25 +08:00
|
|
|
sym="`echo "${ctype}" | tr 'abcdefghijklmnopqrstuvwxyz *' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_P'`"
|
1994-04-20 02:14:23 +08:00
|
|
|
echo "
|
|
|
|
/* The number of bytes in a ${ctype}. */
|
|
|
|
#undef SIZEOF_${sym}"
|
|
|
|
done
|
|
|
|
|
1994-09-01 12:59:32 +08:00
|
|
|
# /bin/sh on the Alpha gives `for' a random value if $funcs is empty.
|
|
|
|
if test -n "$funcs"; then
|
|
|
|
for func in `for x in $funcs; do echo $x; done | sort | uniq`; do
|
1995-11-18 05:55:25 +08:00
|
|
|
sym="`echo ${func} | sed 's/[^a-zA-Z0-9_]/_/g' | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`"
|
1994-09-01 12:59:32 +08:00
|
|
|
echo "
|
1994-07-19 22:44:16 +08:00
|
|
|
/* Define if you have the ${func} function. */
|
1993-08-02 06:27:47 +08:00
|
|
|
#undef HAVE_${sym}"
|
1994-09-01 12:59:32 +08:00
|
|
|
done
|
|
|
|
fi
|
1993-08-02 06:27:47 +08:00
|
|
|
|
1994-09-01 12:59:32 +08:00
|
|
|
if test -n "$headers"; then
|
|
|
|
for header in `for x in $headers; do echo $x; done | sort | uniq`; do
|
1995-11-18 05:55:25 +08:00
|
|
|
|
|
|
|
sym="`echo ${header} | sed 's/[^a-zA-Z0-9_]/_/g' | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`"
|
1994-09-01 12:59:32 +08:00
|
|
|
echo "
|
1993-08-02 06:27:47 +08:00
|
|
|
/* Define if you have the <${header}> header file. */
|
|
|
|
#undef HAVE_${sym}"
|
1994-09-01 12:59:32 +08:00
|
|
|
done
|
|
|
|
fi
|
1993-08-02 06:27:47 +08:00
|
|
|
|
1994-09-01 12:59:32 +08:00
|
|
|
if test -n "$libs"; then
|
|
|
|
for lib in `for x in $libs; do echo $x; done | sort | uniq`; do
|
1995-11-18 05:55:25 +08:00
|
|
|
sym="`echo ${lib} | sed 's/[^a-zA-Z0-9_]/_/g' | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`"
|
1994-09-01 12:59:32 +08:00
|
|
|
echo "
|
1993-08-02 06:27:47 +08:00
|
|
|
/* Define if you have the ${lib} library (-l${lib}). */
|
1994-03-18 10:55:23 +08:00
|
|
|
#undef HAVE_LIB${sym}"
|
1994-09-01 12:59:32 +08:00
|
|
|
done
|
|
|
|
fi
|
1993-08-02 06:27:47 +08:00
|
|
|
|
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 &&
|
1995-02-22 04:39:40 +08:00
|
|
|
sed -n '/@BOTTOM@/,${/@BOTTOM@/!p;}' $localdir/acconfig.h
|
1994-05-03 07:48:08 +08:00
|
|
|
test -f ${config_h}.bot && cat ${config_h}.bot
|
|
|
|
|
1996-11-10 06:19:24 +08:00
|
|
|
echo '#endif /* _CONFIG_H */'
|
|
|
|
|
1993-08-02 06:27:47 +08:00
|
|
|
status=0
|
|
|
|
|
1994-09-18 11:32:50 +08:00
|
|
|
if test -n "$syms"; then
|
|
|
|
for sym in $syms; do
|
|
|
|
if fgrep $sym $TEMPLATES >/dev/null; then
|
|
|
|
: # All is well.
|
|
|
|
else
|
|
|
|
echo "$0: Symbol \`${sym}' is not covered by $TEMPLATES" >&2
|
|
|
|
status=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
1993-08-02 06:27:47 +08:00
|
|
|
|
|
|
|
if test $# -eq 0; then
|
|
|
|
if test $status -eq 0; then
|
1994-08-10 02:35:50 +08:00
|
|
|
if cmp -s $tmpout ${config_h_in}; then
|
1994-04-05 08:13:00 +08:00
|
|
|
rm -f $tmpout
|
|
|
|
else
|
1994-08-10 02:35:50 +08:00
|
|
|
mv -f $tmpout ${config_h_in}
|
1994-04-05 08:13:00 +08:00
|
|
|
fi
|
1993-08-02 06:27:47 +08:00
|
|
|
else
|
|
|
|
rm -f $tmpout
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit $status
|