AC_USE_SYSTEM_EXTENSIONS: Remove stray TR in doc
[autoconf.git] / tests / mktests.sh
blob8b72281cfd5fc65de58898c406b698c89e4b5102
1 #! /bin/sh
3 # Build some of the Autoconf test files.
5 # Copyright (C) 2000-2016 Free Software Foundation, Inc.
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 3 of the License, or
10 # (at your option) any later version.
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.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # If we fail, clean up, but touch the output files. We probably failed
21 # because we used some non-portable tool.
23 as_me=`echo "$0" | sed 's|.*[\\/]||'`
25 outdir=tests
26 acdefuns=$outdir/acdefuns.tmp
27 audefuns=$outdir/audefuns.tmp
28 requires=$outdir/requires.tmp
30 trap 'echo "'"$as_me"': failed." >&2
31 rm -f $acdefuns $audefuns $requires $outdir/*.tat
32 trap "" 0
33 exit 1' \
34 0 1 2 15
36 # If ever something goes wrong, fail, so that the trap is launched.
37 set -e
39 # We need arguments.
40 test $# != 0
42 # We need these arguments.
43 src="$@"
45 # Set locale to C so that `sort' behaves in a uniform way.
46 LANGUAGE=C; export LANGUAGE
47 LANG=C; export LANG
48 LC_ALL=C export LC_ALL
51 # requires
52 # --------
53 # Get the list of macros that are required: there is little interest
54 # in testing them since they will be run by the guy who requires them.
55 sed -n 's/dnl.*//;s/.*AC_REQUIRE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' $src |
56 sort -u >$requires
59 # exclude_list
60 # ------------
61 # Macros which must not be checked at all (not with AT_CHECK_MACRO nor
62 # AT_CHECK_AU_MACRO).
63 exclude_list='
64 # Not a macro name at all.
65 /^$/ {next}
67 # Not macros, just mapping from old variable name to a new one.
68 /^ac_cv_prog_(gcc|gxx|g77)$/ {next}
72 # ac_exclude_list
73 # ---------------
74 # We try to test all the Autoconf macros with AT_CHECK_MACRO to check
75 # for syntax problems, etc. Not every macros can be run without
76 # arguments, and some are already tested elsewhere. AC_EXCLUDE_LIST
77 # filters out the macros we don't want to test.
78 ac_exclude_list='
79 # Internal macros are used elsewhere.
80 /^_?_AC_/ {next}
82 # Used in many places.
83 /^AC_.*_IFELSE$/ {next}
84 /^AC_LANG/ {next}
85 /^AC_RUN_LOG$/ {next}
86 /^AC_TRY/ {next}
88 # Need an argument.
89 /^AC_(CANONICALIZE|PREFIX_PROGRAM|PREREQ)$/ {next}
90 /^AC_(SEARCH_LIBS|REPLACE_FUNCS)$/ {next}
91 /^AC_(CACHE_CHECK|COMPUTE)_INT$/ {next}
92 /^AC_ARG_VAR$/ {next}
93 /^AC_REQUIRE_SHELL_FN$/ {next}
95 # Performed in the semantics tests.
96 /^AC_CHECK_(ALIGNOF|DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|(TARGET_)?TOOL|TYPE)S?$/ {next}
97 /^AC_PATH_PROGS_FEATURE_CHECK$/ {next}
99 # Fail when the source does not exist.
100 /^AC_CONFIG/ {next}
102 # AU defined to nothing.
103 /^AC_(CYGWIN|CYGWIN32|EMXOS2|MING32|EXEEXT|OBJEXT)$/ {next}
105 # Produce "= val" because $1, the variable used to store the result,
106 # is empty.
107 /^AC_(F77|FC)_FUNC$/ {next}
108 /^AC_FC_(PP_)?SRCEXT$/ {next}
109 /^AC_PATH_((TARGET_)?TOOL|PROG)S?$/ {next}
111 # Is a number.
112 /^AC_FD_CC$/ {next}
114 # Obsolete, but needs to be AC_DEFUNed.
115 /^AC_FOREACH$/ {next}
117 # Require a file that is not shipped with Autoconf. But it should.
118 /^AC_FUNC_(GETLOADAVG|FNMATCH_GNU)$/ {next}
119 /^AC_REPLACE_FNMATCH$/ {next}
121 # Obsolete, checked in semantics.
122 /^AC_FUNC_WAIT3$/ {next}
123 /^AC_FUNC_SETVBUF_REVERSED$/ {next}
124 /^AC_SYS_RESTARTABLE_SYSCALLS$/ {next}
126 # Not intended to be invoked at the top level.
127 /^AC_INCLUDES_DEFAULT$/ {next}
129 # AC_INIT includes all the AC_INIT macros.
130 # There is an infinite m4 recursion if AC_INIT is used twice.
131 /^AC_INIT/ {next}
133 # Checked in semantics.
134 /^AC_(PROG_CC|C_CONST|C_VOLATILE)$/ {next}
135 /^AC_PATH_XTRA$/ {next}
137 # Requires a working C++ compiler, which is not a given.
138 /^AC_PROG_CXX_C_O$/ {next}
140 # Already tested by AT_CHECK_MACRO.
141 /^AC_OUTPUT$/ {next}
143 # Tested alongside m4_divert_text.
144 /^AC_PRESERVE_HELP_ORDER$/ {next}
148 # ac_exclude_script
149 # -----------------
150 # Build a single awk script out of the above.
151 ac_exclude_script="$exclude_list $ac_exclude_list {print}"
154 # au_exclude_list
155 # ---------------
156 # Check all AU_DEFUN'ed macros with AT_CHECK_AU_MACRO, except these.
157 au_exclude_list='
158 # Empty.
159 /^AC_(C_CROSS|PROG_CC_(C[89]9|STDC))$/ {next}
161 # Use AC_REQUIRE.
162 /^AC_(CYGWIN|MINGW32|EMXOS2)$/ {next}
164 # Already in configure.ac.
165 /^AC_(INIT|OUTPUT)$/ {next}
167 # AC_LANG_SAVE needs user interaction to be removed.
168 # AC_LANG_RESTORE cannot be used alone.
169 /^AC_LANG_(SAVE|RESTORE)$/ {next}
171 # Need arguments and are tested elsewhere.
172 /^AC_(LINK_FILES|PREREQ)$/ {next}
175 # au_exclude_script
176 # -----------------
177 # Build a single awk script out of the above.
178 au_exclude_script="$exclude_list $au_exclude_list {print}"
181 ## ------------------------- ##
182 ## Creating the test files. ##
183 ## ------------------------- ##
185 for file in $src
187 base=`echo "$file" | sed 's|.*[\\/]||;s|\..*||'`
188 acbase=$outdir/ac$base
189 # Get the list of macros which are defined in Autoconf level.
190 # Get rid of the macros we are not interested in.
191 sed -n -e 's/^AC_DEFUN(\[*\([a-zA-Z0-9_]*\).*$/\1/p' \
192 -e 's/^AC_DEFUN_ONCE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' $file |
193 awk "$ac_exclude_script" |
194 sort -u >$acdefuns
196 # Get the list of macros which are defined in Autoupdate level.
197 sed -n 's/^AU_DEFUN(\[*\([a-zA-Z][a-zA-Z0-9_]*\).*$/\1/p' $file |
198 awk "$au_exclude_script" |
199 sort -u >$audefuns
201 # Filter out required macros.
203 sed 's/^ *//' <<MK_EOF
204 # Generated by $as_me. -*- Autotest -*-
206 ## --------------------- ##
207 ## Do not edit by hand. ##
208 ## --------------------- ##
210 # Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
211 # 2010 Free Software Foundation, Inc.
213 AT_BANNER([Testing autoconf/$base macros.])
215 MK_EOF
217 echo "# Modern macros."
218 comm -23 $acdefuns $requires | sed 's/.*/AT_CHECK_MACRO([&])/'
219 echo
220 echo "# Obsolete macros."
221 comm -23 $audefuns $requires | sed 's/.*/AT_CHECK_AU_MACRO([&])/'
222 } >$acbase.tat
224 # In one atomic step so that if something above fails, the trap
225 # preserves the old version of the file. If there is nothing to
226 # check, output /rien du tout/[1].
227 if grep AT_CHECK $acbase.tat >/dev/null 2>&1; then
228 mv -f $acbase.tat $acbase.at
229 else
230 rm -f $acbase.tat $acbase.at
231 touch $acbase.at
233 # Help people not to update these files by hand.
234 chmod a-w $acbase.at
235 done
237 rm -f $acdefuns $audefuns $requires
239 trap '' 0
240 exit 0
242 # [1] En franc,ais dans le texte.