Fix typo in previous patch.
[autoconf.git] / tests / mktests.sh
blobfe59be2c3304ce75a0983262631b3bdc2b24e909
1 #! /bin/sh
3 # Build some of the Autoconf test files.
5 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
6 # 2009, 2010 Free Software Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # If we fail, clean up, but touch the output files. We probably failed
22 # because we used some non-portable tool.
24 as_me=`echo "$0" | sed 's|.*[\\/]||'`
26 trap 'echo "'"$as_me"': failed." >&2
27 rm -f acdefuns audefuns requires *.tat
28 trap "" 0
29 exit 1' \
30 0 1 2 15
32 # If ever something goes wrong, fail, so that the trap is launched.
33 set -e
35 # We need arguments.
36 test $# != 0
38 # We need these arguments.
39 src="$@"
41 # Set locale to C so that `sort' behaves in a uniform way.
42 LANGUAGE=C; export LANGUAGE
43 LANG=C; export LANG
44 LC_ALL=C export LC_ALL
47 # requires
48 # --------
49 # Get the list of macros that are required: there is little interest
50 # in testing them since they will be run by the guy who requires them.
51 sed -n 's/dnl.*//;s/.*AC_REQUIRE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' $src |
52 sort -u >requires
55 # exclude_list
56 # ------------
57 # Macros which must not be checked at all (not with AT_CHECK_MACRO nor
58 # AT_CHECK_AU_MACRO).
59 exclude_list='
60 # Not a macro name at all.
61 /^$/ {next}
63 # Not macros, just mapping from old variable name to a new one.
64 /^ac_cv_prog_(gcc|gxx|g77)$/ {next}
68 # ac_exclude_list
69 # ---------------
70 # We try to test all the Autoconf macros with AT_CHECK_MACRO to check
71 # for syntax problems, etc. Not every macros can be run without
72 # arguments, and some are already tested elsewhere. AC_EXCLUDE_LIST
73 # filters out the macros we don't want to test.
74 ac_exclude_list='
75 # Internal macros are used elsewhere.
76 /^_?_AC_/ {next}
78 # Used in many places.
79 /^AC_.*_IFELSE$/ {next}
80 /^AC_LANG/ {next}
81 /^AC_RUN_LOG$/ {next}
82 /^AC_TRY/ {next}
84 # Need an argument.
85 /^AC_(CANONICALIZE|PREFIX_PROGRAM|PREREQ)$/ {next}
86 /^AC_(SEARCH_LIBS|REPLACE_FUNCS)$/ {next}
87 /^AC_(CACHE_CHECK|COMPUTE)_INT$/ {next}
88 /^AC_ARG_VAR$/ {next}
89 /^AC_REQUIRE_SHELL_FN$/ {next}
91 # Performed in the semantics tests.
92 /^AC_CHECK_(ALIGNOF|DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|(TARGET_)?TOOL|TYPE)S?$/ {next}
93 /^AC_PATH_PROGS_FEATURE_CHECK$/ {next}
95 # Fail when the source does not exist.
96 /^AC_CONFIG/ {next}
98 # AU defined to nothing.
99 /^AC_(CYGWIN|CYGWIN32|EMXOS2|MING32|EXEEXT|OBJEXT)$/ {next}
101 # Produce "= val" because $1, the variable used to store the result,
102 # is empty.
103 /^AC_(F77|FC)_FUNC$/ {next}
104 /^AC_FC_SRCEXT$/ {next}
105 /^AC_PATH_((TARGET_)?TOOL|PROG)S?$/ {next}
107 # Requires the current language to be Fortran, not C.
108 /^AC_FC_FREEFORM$/ {next}
110 # Is a number.
111 /^AC_FD_CC$/ {next}
113 # Obsolete, but needs to be AC_DEFUNed.
114 /^AC_FOREACH$/ {next}
116 # Require a file that is not shipped with Autoconf. But it should.
117 /^AC_FUNC_(GETLOADAVG|FNMATCH_GNU)$/ {next}
118 /^AC_REPLACE_FNMATCH$/ {next}
120 # Obsolete, checked in semantics.
121 /^AC_FUNC_WAIT3$/ {next}
122 /^AC_FUNC_SETVBUF_REVERSED$/ {next}
123 /^AC_SYS_RESTARTABLE_SYSCALLS$/ {next}
125 # Not intended to be invoked at the top level.
126 /^AC_INCLUDES_DEFAULT$/ {next}
128 # AC_INIT includes all the AC_INIT macros.
129 # There is an infinite m4 recursion if AC_INIT is used twice.
130 /^AC_INIT/ {next}
132 # Checked in semantics.
133 /^AC_(PROG_CC|C_CONST|C_VOLATILE)$/ {next}
134 /^AC_PATH_XTRA$/ {next}
136 # Requires a working C++ compiler, which is not a given.
137 /^AC_PROG_CXX_C_O$/ {next}
139 # Already tested by AT_CHECK_MACRO.
140 /^AC_OUTPUT$/ {next}
142 # Tested alongside m4_divert_text.
143 /^AC_PRESERVE_HELP_ORDER$/ {next}
147 # ac_exclude_script
148 # -----------------
149 # Build a single awk script out of the above.
150 ac_exclude_script="$exclude_list $ac_exclude_list {print}"
153 # au_exclude_list
154 # ---------------
155 # Check all AU_DEFUN'ed macros with AT_CHECK_AU_MACRO, except these.
156 au_exclude_list='
157 # Empty.
158 /^AC_(C_CROSS|PROG_CC_STDC)$/ {next}
160 # Use AC_REQUIRE.
161 /^AC_(CYGWIN|MINGW32|EMXOS2)$/ {next}
163 # Already in configure.ac.
164 /^AC_(INIT|OUTPUT)$/ {next}
166 # AC_LANG_SAVE needs user interaction to be removed.
167 # AC_LANG_RESTORE cannot be used alone.
168 /^AC_LANG_(SAVE|RESTORE)$/ {next}
170 # Need arguments and are tested elsewhere.
171 /^AC_(LINK_FILES|PREREQ)$/ {next}
174 # au_exclude_script
175 # -----------------
176 # Build a single awk script out of the above.
177 au_exclude_script="$exclude_list $au_exclude_list {print}"
180 ## ------------------------- ##
181 ## Creating the test files. ##
182 ## ------------------------- ##
184 for file in $src
186 base=`echo "$file" | sed 's|.*[\\/]||;s|\..*||'`
187 # Get the list of macros which are defined in Autoconf level.
188 # Get rid of the macros we are not interested in.
189 sed -n -e 's/^AC_DEFUN(\[*\([a-zA-Z0-9_]*\).*$/\1/p' \
190 -e 's/^AC_DEFUN_ONCE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' $file |
191 awk "$ac_exclude_script" |
192 sort -u >acdefuns
194 # Get the list of macros which are defined in Autoupdate level.
195 sed -n 's/^AU_DEFUN(\[*\([a-zA-Z][a-zA-Z0-9_]*\).*$/\1/p' $file |
196 awk "$au_exclude_script" |
197 sort -u >audefuns
199 # Filter out required macros.
201 sed 's/^ *//' <<MK_EOF
202 # Generated by $as_me. -*- Autotest -*-
204 ## --------------------- ##
205 ## Do not edit by hand. ##
206 ## --------------------- ##
208 # Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
209 # 2010 Free Software Foundation, Inc.
211 AT_BANNER([Testing autoconf/$base macros.])
213 MK_EOF
215 echo "# Modern macros."
216 comm -23 acdefuns requires | sed 's/.*/AT_CHECK_MACRO([&])/'
217 echo
218 echo "# Obsolete macros."
219 comm -23 audefuns requires | sed 's/.*/AT_CHECK_AU_MACRO([&])/'
220 } >ac$base.tat
222 # In one atomic step so that if something above fails, the trap
223 # preserves the old version of the file. If there is nothing to
224 # check, output /rien du tout/[1].
225 if grep AT_CHECK ac$base.tat >/dev/null 2>&1; then
226 mv -f ac$base.tat ac$base.at
227 else
228 rm -f ac$base.tat ac$base.at
229 touch ac$base.at
231 # Help people not to update these files by hand.
232 chmod a-w ac$base.at
233 done
235 rm -f acdefuns audefuns requires
237 trap '' 0
238 exit 0
240 # [1] En franc,ais dans le texte.