autoconf/tests/mktests.sh

201 lines
5.3 KiB
Bash
Raw Normal View History

#! /bin/sh
# Build some of the Autoconf test files.
# Copyright (C) 2000 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# If we fail, clean up, but touch the output files. We probably failed
# because we used some non portable tool, but we just don't care: this
# shell script is a maintainer tool, and we do expect good tools.
trap 'echo "'$0': failed. To proceed run make check." >&2
rm -f acdefuns audefuns requires syntax.tm4 update.tm4
touch syntax.m4
touch update.m4
trap 0
exit 1' \
0 1 2 15
# If ever something goes wrong, fail, so that the trap be launched.
set -e
# We need arguments.
test $# != 0
# We need these arguments.
src="$@"
# Set locale to C so that `sort' behaves in a uniform way.
export LANGUAGE; LANGUAGE=C
export LANG; LANG=C
export LC_ALL; LC_ALL=C
# --------- #
# syntax.m4 #
# --------- #
# syntax_exclude_list
# -------------------
# The test `syntax.m4' tries to run all the macros of Autoconf to check
# for syntax problems, etc. Not all the macros can be run without argument,
# and some are already tested elsewhere. EGREP_EXCLUDE must filter out
# the macros we don't want to test in syntax.m4.
#
# - AC_CANONICALIZE, AC_PREFIX_PROGRAM, AC_PREREQ
# Need an argument.
# - AC_CHECK decl, file, func, header, lib, member, prog, sizeof, type
# Performed in the semantics tests.
# - AC_CONFIG
# They fail when the source does not exist.
# - AC_INIT
# AC_INIT includes all the AC_INIT macros. Note that there is an
# infinite m4 recursion if AC_INIT it used twice.
# - AC_LANG*
# Heavily used by other macros.
# - AC_PATH_PROGS?, AC_F77_FUNC
# They produce `= val' because $1, the variable used to store the result,
# is empty.
# - AC_TRY, AC_.*_IFELSE
# Used in many places.
# - _AC_
# Internal macros are used elsewhere.
# - AC_OUTPUT
# Already tested by `AT_CHECK_MACRO'.
# - AC_FD_CC
# Is a number.
# - AC_PROG_CC, AC_C_(CONST|INLINE|VOLATILE)
# Checked in semantics.
# - AC_CYGWIN, AC_CYGWIN32, AC_EMXOS2, AC_MING32, AC_EXEEXT, AC_OBJEXT
# AU defined to nothing.
syntax_exclude_list='^AC_ARG_VAR$
^AC_CANONICALIZE|AC_PREFIX_PROGRAM|AC_PREREQ$
^AC_CHECK_(DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|TOOL|TYPE)S?$
^AC_CONFIG
^AC_F77_FUNC$
^AC_INIT
^AC_LANG
^AC_LINKER_OPTION$
^AC_LINK_FILES$
^AC_LIST_MEMBER_OF$
^AC_OUTPUT$
^AC_PATH_(TOOL|PROG)S?$
^AC_REPLACE_FUNCS$
^AC_SEARCH_LIBS$
^AC_TRY
^AC_.*_IFELSE$
^AC_FD_CC$
^(AC_(PROG_CC|C_CONST|C_INLINE|C_VOLATILE))$
^AC_(CYGWIN|CYGWIN32|EMXOS2|MING32|EXEEXT|OBJEXT)$
_AC_'
# syntax_exclude_egrep --
# Build a single egrep pattern out of filter_macros_list.
# Sed is used to get rid of the trailing `|' coming from the trailing
# `\n' from `echo'.
syntax_exclude_egrep=`echo "$syntax_exclude_list" | tr '
' '|' | sed 's/.$//'`
sed 's/^ *//' >syntax.tm4 <<MK_EOF
# Generated by mktests.sh, do not edit by hand. -*- autoconf -*-
cat <<\EOF
Syntax of macros and completeness of header templates.
EOF
MK_EOF
# Get the list of macros which are defined in Autoconf level.
# Get rid of the macros we are not interested in.
cat $src |
sed -ne 's/^A[CU]_DEFUN\(_ONCE\)\?(\[*\([a-zA-Z0-9_]*\).*$/\2/p' |
sort |
uniq |
egrep -v "$syntax_exclude_egrep" >acdefuns
# Get the list of macros that are required: there is little interest
# in testing them since they will be run but the guy who requires
# them.
cat $src |
sed -ne 's/dnl.*//;s/.*AC_REQUIRE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' |
sort |
uniq >requires
# Filter out.
for macro in `cat acdefuns`; do
if fgrep "$macro" requires >/dev/null 2>&1; then :; else
echo "AT_CHECK_MACRO([$macro])" >>syntax.tm4
fi
done
mv syntax.tm4 syntax.m4
# --------- #
# update.m4 #
# --------- #
# update_exclude_list
# -------------------
# AC_LANG_RESTORE
# cannot be used alone.
# AC_LINK_FILES, AC_PREREQ
# need arguments and are tested elsewhere.
# AC_INIT and AC_OUTPUT
# are already in `configure.in'.
update_exclude_list='^AC_LANG_RESTORE$
^AC_LINK_FILES|AC_PREREQ$
^AC_(INIT|OUTPUT)$'
# syntax_exclude_egrep --
# Build a single egrep pattern out of filter_macros_list.
# Sed is used to get rid of the trailing `|' coming from the trailing
# `\n' from `echo'.
update_exclude_egrep=`echo "$update_exclude_list" | tr '
' '|' | sed 's/.$//'`
sed 's/^ *//' >update.tm4 <<MK_EOF
# Generated by mktests.sh, do not edit by hand. -*- autoconf -*-
cat <<EOF
Checking that autoupdated configure.in are sane.
EOF
MK_EOF
# Get the list of macros which are defined in Autoupdate level.
cat $src |
sed -ne 's/^AU_DEFUN(\[*\([a-zA-Z][a-zA-Z0-9_]*\).*$/\1/p' |
sort |
uniq |
egrep -v "$update_exclude_egrep" |
sed 's/.*/AT_CHECK_UPDATE([&])/' >>update.tm4
mv update.tm4 update.m4
2000-10-12 20:45:16 +08:00
rm -f acdefuns audefuns requires
trap 0
exit 0