| 1 |
#! /bin/sh |
| 2 |
|
| 3 |
# Build some of the Autoconf test files. |
| 4 |
# Copyright 2021,2023 Thomas E. Dickey |
| 5 |
# Copyright 2000 Free Software Foundation, Inc. |
| 6 |
|
| 7 |
# This program is free software; you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation; either version 2, or (at your option) |
| 10 |
# any later version. |
| 11 |
|
| 12 |
# This program is distributed in the hope that it will be useful, |
| 13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
|
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with this program; if not, write to the Free Software |
| 19 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 20 |
# 02111-1307, USA. |
| 21 |
|
| 22 |
# If we fail, clean up, but touch the output files. We probably failed |
| 23 |
# because we used some non portable tool, but we just don't care: this |
| 24 |
# shell script is a maintainer tool, and we do expect good tools. |
| 25 |
|
| 26 |
as_me=`echo "$0" | sed 's,.*[\\/],,'` |
| 27 |
|
| 28 |
trap 'echo "'"$as_me"': failed. To proceed run make check." >&2 |
| 29 |
rm -f acdefuns audefuns requires *.tat |
| 30 |
for file in "$@" |
| 31 |
do |
| 32 |
touch `echo "$file" | sed "s,.*[\\/],,;s/\..*/.at/"` |
| 33 |
done |
| 34 |
trap 0 |
| 35 |
exit 1' \ |
| 36 |
0 1 2 15 |
| 37 |
|
| 38 |
# If ever something goes wrong, fail, so that the trap be launched. |
| 39 |
set -e |
| 40 |
|
| 41 |
# We need arguments. |
| 42 |
test $# != 0 |
| 43 |
|
| 44 |
# We need these arguments. |
| 45 |
src="$@" |
| 46 |
|
| 47 |
# Set locale to C so that `sort' behaves in a uniform way. |
| 48 |
export LANGUAGE; LANGUAGE=C |
| 49 |
export LANG; LANG=C |
| 50 |
export LC_ALL; LC_ALL=C |
| 51 |
|
| 52 |
|
| 53 |
# requires |
| 54 |
# -------- |
| 55 |
# Get the list of macros that are required: there is little interest |
| 56 |
# in testing them since they will be run but the guy who requires |
| 57 |
# them. |
| 58 |
cat $src | |
| 59 |
sed -n 's/dnl.*//;s/.*AC_REQUIRE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' | |
| 60 |
sort | |
| 61 |
uniq >requires |
| 62 |
|
| 63 |
|
| 64 |
# exclude_list |
| 65 |
# ------------ |
| 66 |
# Macros which must not be checked at all (not by ac-macros.at, nor |
| 67 |
# au-macros.at). |
| 68 |
# The trailing new line is meant. |
| 69 |
# |
| 70 |
# - ac_cv_prog_gcc, gxx, g77 |
| 71 |
# Not macros, just mapping from old variable name to a new one. |
| 72 |
exclude_list='^ac_cv_prog_(gcc|gxx|g77)$ |
| 73 |
' |
| 74 |
|
| 75 |
|
| 76 |
# ac_exclude_list |
| 77 |
# --------------- |
| 78 |
# The test `ac-macros.at' tries to run all the macros of Autoconf to check |
| 79 |
# for syntax problems, etc. Not all the macros can be run without argument, |
| 80 |
# and some are already tested elsewhere. EGREP_EXCLUDE must filter out |
| 81 |
# the macros we don't want to test in ac-macros.at. |
| 82 |
# |
| 83 |
# - AC_CANONICALIZE, AC_PREFIX_PROGRAM, AC_PREREQ |
| 84 |
# Need an argument. |
| 85 |
# - AC_CHECK decl, file, func, header, lib, member, prog, sizeof, type |
| 86 |
# Performed in the semantics tests. |
| 87 |
# - AC_CONFIG |
| 88 |
# They fail when the source does not exist. |
| 89 |
# - AC_INIT |
| 90 |
# AC_INIT includes all the AC_INIT macros. Note that there is an |
| 91 |
# infinite m4 recursion if AC_INIT it used twice. |
| 92 |
# - AC_LANG* |
| 93 |
# Heavily used by other macros. |
| 94 |
# - AC_PATH_PROGS?, AC_F77_FUNC |
| 95 |
# They produce `= val' because $1, the variable used to store the result, |
| 96 |
# is empty. |
| 97 |
# - AC_TRY, AC_.*_IFELSE, AC_RUN_LOG. |
| 98 |
# Used in many places. |
| 99 |
# - _AC_ |
| 100 |
# Internal macros are used elsewhere. |
| 101 |
# - AC_OUTPUT |
| 102 |
# Already tested by `AT_CHECK_MACRO'. |
| 103 |
# - AC_FD_CC |
| 104 |
# Is a number. |
| 105 |
# - AC_PROG_CC, AC_C_(CONST|INLINE|VOLATILE), AC_PATH_XTRA |
| 106 |
# Checked in semantics. |
| 107 |
# - AC_CYGWIN, AC_CYGWIN32, AC_EMXOS2, AC_MING32, AC_EXEEXT, AC_OBJEXT |
| 108 |
# AU defined to nothing. |
| 109 |
# - AC_PATH_XTRA |
| 110 |
# Checked in semantics. |
| 111 |
# - AC_SYS_RESTARTABLE_SYSCALLS, AC_FUNC_WAIT3 |
| 112 |
# Obsolete, checked in semantics. |
| 113 |
# |
| 114 |
ac_exclude_list='^AC_ARG_VAR$ |
| 115 |
^AC_CANONICALIZE|AC_PREFIX_PROGRAM|AC_PREREQ$ |
| 116 |
^AC_CHECK_(DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|TOOL|TYPE)S?$ |
| 117 |
^AC_CONFIG |
| 118 |
^AC_F77_FUNC$ |
| 119 |
^AC_INIT |
| 120 |
^AC_LANG |
| 121 |
^AC_LINKER_OPTION$ |
| 122 |
^AC_LINK_FILES$ |
| 123 |
^AC_LIST_MEMBER_OF$ |
| 124 |
^AC_OUTPUT$ |
| 125 |
^AC_PATH_(TOOL|PROG)S?$ |
| 126 |
^AC_REPLACE_FUNCS$ |
| 127 |
^AC_SEARCH_LIBS$ |
| 128 |
^(AC_TRY.*|AC_RUN_LOG)$ |
| 129 |
^AC_.*_IFELSE$ |
| 130 |
^AC_FD_CC$ |
| 131 |
^(AC_(PROG_CC|C_CONST|C_INLINE|C_VOLATILE))$ |
| 132 |
^AC_(CYGWIN|CYGWIN32|EMXOS2|MING32|EXEEXT|OBJEXT)$ |
| 133 |
^AC_PATH_XTRA$ |
| 134 |
^AC_SYS_RESTARTABLE_SYSCALLS$ |
| 135 |
^AC_FUNC_WAIT3$ |
| 136 |
_AC_' |
| 137 |
|
| 138 |
|
| 139 |
# ac_exclude_egrep |
| 140 |
# ---------------- |
| 141 |
# Build a single egrep pattern out of filter_macros_list. |
| 142 |
# Sed is used to get rid of the trailing `|' coming from the trailing |
| 143 |
# `\n' from `echo'. |
| 144 |
ac_exclude_egrep=`echo "$exclude_list$ac_exclude_list" | tr ' |
| 145 |
' '|' | sed 's/.$//'` |
| 146 |
|
| 147 |
|
| 148 |
# au_exclude_list |
| 149 |
# --------------- |
| 150 |
# AC_LANG_RESTORE |
| 151 |
# cannot be used alone. |
| 152 |
# AC_LINK_FILES, AC_PREREQ |
| 153 |
# need arguments and are tested elsewhere. |
| 154 |
# AC_INIT and AC_OUTPUT |
| 155 |
# are already in `configure.ac'. |
| 156 |
# AC_CYGWIN, AC_MINGW32, AC_EMXOS2 |
| 157 |
# are using AC_REQUIRE. |
| 158 |
au_exclude_list='^AC_LANG_RESTORE$ |
| 159 |
^AC_LINK_FILES|AC_PREREQ$ |
| 160 |
^AC_(INIT|OUTPUT)$ |
| 161 |
^AC_(CYGWIN|MINGW32|EMXOS2)$' |
| 162 |
|
| 163 |
|
| 164 |
# au_exclude_egrep |
| 165 |
# ---------------- |
| 166 |
# Build a single egrep pattern out of filter_macros_list. |
| 167 |
# Sed is used to get rid of the trailing `|' coming from the trailing |
| 168 |
# `\n' from `echo'. |
| 169 |
au_exclude_egrep=`echo "$exclude_list$au_exclude_list" | tr ' |
| 170 |
' '|' | sed 's/.$//'` |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
## ------------------------- ## |
| 175 |
## Creating the test files. ## |
| 176 |
## ------------------------- ## |
| 177 |
|
| 178 |
for file in $src |
| 179 |
do |
| 180 |
base=`echo "$file" | sed 's,.*[\\/],,;s/\..*//'` |
| 181 |
# Get the list of macros which are defined in Autoconf level. |
| 182 |
# Get rid of the macros we are not interested in. |
| 183 |
cat $file | |
| 184 |
sed -n -e 's/^AC_DEFUN(\[*\([a-zA-Z0-9_]*\).*$/\1/p' \ |
| 185 |
-e 's/^AC_DEFUN_ONCE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' | |
| 186 |
sort | |
| 187 |
uniq | |
| 188 |
# Watch out we are `set -e': don't fail. |
| 189 |
( @EGREP@ -v "$ac_exclude_egrep" || true) >acdefuns |
| 190 |
|
| 191 |
# Get the list of macros which are defined in Autoupdate level. |
| 192 |
cat $file | |
| 193 |
sed -n 's/^AU_DEFUN(\[*\([a-zA-Z][a-zA-Z0-9_]*\).*$/\1/p' | |
| 194 |
sort | |
| 195 |
uniq | |
| 196 |
( @EGREP@ -v "$au_exclude_egrep" || true) > audefuns |
| 197 |
|
| 198 |
# Filter out required macros. |
| 199 |
{ |
| 200 |
sed 's/^ *//' <<MK_EOF |
| 201 |
# Generated by $as_me, do not edit by hand. -*- autoconf -*- |
| 202 |
|
| 203 |
AT_BANNER([Testing $base macros.]) |
| 204 |
|
| 205 |
MK_EOF |
| 206 |
|
| 207 |
echo "# Modern macros." |
| 208 |
for macro in `cat acdefuns`; do |
| 209 |
if @FGREP@ "$macro" requires >/dev/null 2>&1; then :; else |
| 210 |
echo "AT_CHECK_MACRO([$macro])" |
| 211 |
fi |
| 212 |
done |
| 213 |
echo |
| 214 |
echo "# Obsolete macros." |
| 215 |
for macro in `cat audefuns`; do |
| 216 |
if @FGREP@ "$macro" requires >/dev/null 2>&1; then :; else |
| 217 |
echo "AT_CHECK_AU_MACRO([$macro])" |
| 218 |
fi |
| 219 |
done |
| 220 |
} >$base.tat |
| 221 |
|
| 222 |
# In one atomic step so that if something above fails, the trap |
| 223 |
# preserves the old version of the file. |
| 224 |
mv -f $base.tat $base.at |
| 225 |
done |
| 226 |
|
| 227 |
rm -f acdefuns audefuns requires |
| 228 |
|
| 229 |
trap 0 |
| 230 |
exit 0 |