* lib/autoconf/programs.m4 (AC_PROG_SED): New macro to test for a
[autoconf.git] / tests / mktests.sh
blob0e928a458a8a351e5de8d8155775a1ec3fecd21c
1 #! /bin/sh
3 # Build some of the Autoconf test files.
4 # Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 # 02111-1307, USA.
21 # If we fail, clean up, but touch the output files. We probably failed
22 # because we used some non portable tool, but we just don't care: this
23 # shell script is a maintainer tool, and we do expect good tools.
25 as_me=`echo "$0" | sed 's,.*[\\/],,'`
27 trap 'echo "'"$as_me"': failed. To proceed run make check." >&2
28 rm -f acdefuns audefuns requires *.tat
29 for file in "$@"
31 touch `echo "$file" | sed "s,.*[\\/],,;s/\..*/.at/"`
32 done
33 trap 0
34 exit 1' \
35 0 1 2 15
37 # If ever something goes wrong, fail, so that the trap be launched.
38 set -e
40 # We need arguments.
41 test $# != 0
43 # We need these arguments.
44 src="$@"
46 # Set locale to C so that `sort' behaves in a uniform way.
47 export LANGUAGE; LANGUAGE=C
48 export LANG; LANG=C
49 export LC_ALL; LC_ALL=C
52 # requires
53 # --------
54 # Get the list of macros that are required: there is little interest
55 # in testing them since they will be run but the guy who requires
56 # them.
57 cat $src |
58 sed -n 's/dnl.*//;s/.*AC_REQUIRE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' |
59 sort |
60 uniq >requires
63 # exclude_list
64 # ------------
65 # Macros which must not be checked at all (not by ac-macros.at, nor
66 # au-macros.at).
67 # The trailing new line is meant.
69 # - ac_cv_prog_gcc, gxx, g77
70 # Not macros, just mapping from old variable name to a new one.
71 exclude_list='^ac_cv_prog_(gcc|gxx|g77)$
75 # ac_exclude_list
76 # ---------------
77 # The test `ac-macros.at' tries to run all the macros of Autoconf to check
78 # for syntax problems, etc. Not all the macros can be run without argument,
79 # and some are already tested elsewhere. EGREP_EXCLUDE must filter out
80 # the macros we don't want to test in ac-macros.at.
82 # - AC_CANONICALIZE, AC_PREFIX_PROGRAM, AC_PREREQ
83 # Need an argument.
85 # - AC_CHECK decl, file, func, header, lib, member, prog, sizeof, type
86 # Performed in the semantics tests.
88 # - AC_CONFIG
89 # They fail when the source does not exist.
91 # - AC_FUNC_GETLOADAVG, AC_REPLACE_FNMATCH, AC_FUNC_FNMATCH_GNU
92 # Require a file that is not shipped with Autoconf. But it should.
94 # - AC_INIT
95 # AC_INIT includes all the AC_INIT macros. Note that there is an
96 # infinite m4 recursion if AC_INIT it used twice.
98 # - AC_LANG*
99 # Heavily used by other macros.
101 # - AC_PATH_PROGS?, AC_F77_FUNC, AC_FC_FUNC, AC_FC_SRCEXT
102 # They produce `= val' because $1, the variable used to store the result,
103 # is empty.
105 # - AC_FC_FREEFORM
106 # Requires the current language to be Fortran, not C.
108 # - AC_TRY, AC_.*_IFELSE, AC_RUN_LOG.
109 # Used in many places.
111 # - _AC_
112 # Internal macros are used elsewhere.
114 # - AC_OUTPUT
115 # Already tested by `AT_CHECK_MACRO'.
117 # - AC_FD_CC
118 # Is a number.
120 # - AC_PROG_CC, AC_C_(CONST|INLINE|VOLATILE), AC_PATH_XTRA
121 # Checked in semantics.
123 # - AC_CYGWIN, AC_CYGWIN32, AC_EMXOS2, AC_MING32, AC_EXEEXT, AC_OBJEXT
124 # AU defined to nothing.
126 # - AC_PATH_XTRA
127 # Checked in semantics.
129 # - AC_SYS_RESTARTABLE_SYSCALLS, AC_FUNC_WAIT3
130 # Obsolete, checked in semantics.
132 ac_exclude_list='^AC_ARG_VAR$
133 ^AC_CANONICALIZE|AC_PREFIX_PROGRAM|AC_PREREQ$
134 ^AC_CHECK_(DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|TOOL|TYPE)S?$
135 ^AC_CONFIG
136 ^AC_(F77|FC)_FUNC$
137 ^AC_FC_(FUNC|FREEFORM|SRCEXT)$
138 ^AC_FD_CC$
139 ^AC_FUNC_(GETLOADAVG|FNMATCH_GNU|WAIT3)$
140 ^AC_INIT
141 ^AC_LANG
142 ^AC_LINKER_OPTION$
143 ^AC_LINK_FILES$
144 ^AC_LIST_MEMBER_OF$
145 ^AC_OUTPUT$
146 ^AC_PATH_(TOOL|PROG)S?$
147 ^AC_REPLACE_(FNMATCH|FUNCS)$
148 ^AC_SEARCH_LIBS$
149 ^(AC_TRY.*|AC_RUN_LOG)$
150 ^AC_.*_IFELSE$
151 ^(AC_(PROG_CC|C_CONST|C_INLINE|C_RESTRICT|C_VOLATILE))$
152 ^AC_(CYGWIN|CYGWIN32|EMXOS2|MING32|EXEEXT|OBJEXT)$
153 ^AC_PATH_XTRA$
154 ^AC_SYS_RESTARTABLE_SYSCALLS$
155 _AC_'
158 # ac_exclude_egrep
159 # ----------------
160 # Build a single extended regular expression out of filter_macros_list.
161 ac_exclude_egrep=$exclude_list$ac_exclude_list
164 # au_exclude_list
165 # ---------------
166 # AC_LANG_RESTORE
167 # cannot be used alone.
168 # AC_LINK_FILES, AC_PREREQ
169 # need arguments and are tested elsewhere.
170 # AC_INIT and AC_OUTPUT
171 # are already in `configure.ac'.
172 # AC_C_CROSS and AC_PROG_CC_STDC
173 # are empty.
174 # AC_CYGWIN, AC_MINGW32, AC_EMXOS2
175 # are using AC_REQUIRE.
176 au_exclude_list='^AC_LANG_RESTORE$
177 ^AC_LINK_FILES|AC_PREREQ$
178 ^AC_(INIT|OUTPUT)$
179 ^AC_C_CROSS|AC_PROG_CC_STDC$
180 ^AC_(CYGWIN|MINGW32|EMXOS2)$'
183 # au_exclude_egrep
184 # ----------------
185 # Build a single extended regular expression out of filter_macros_list.
186 au_exclude_egrep=$exclude_list$au_exclude_list
189 # egrep
190 # -----
191 if echo a | (grep -E '(a|b)') >/dev/null 2>&1
192 then egrep='grep -E'
193 else egrep='egrep'
197 ## ------------------------- ##
198 ## Creating the test files. ##
199 ## ------------------------- ##
201 for file in $src
203 base=`echo "$file" | sed 's,.*[\\/],,;s/\..*//'`
204 # Get the list of macros which are defined in Autoconf level.
205 # Get rid of the macros we are not interested in.
206 cat $file |
207 sed -n -e 's/^AC_DEFUN(\[*\([a-zA-Z0-9_]*\).*$/\1/p' \
208 -e 's/^AC_DEFUN_ONCE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' |
209 sort |
210 uniq |
211 # Watch out we are `set -e': don't fail.
212 ($egrep -v "$ac_exclude_egrep" || true) >acdefuns
214 # Get the list of macros which are defined in Autoupdate level.
215 cat $file |
216 sed -n 's/^AU_DEFUN(\[*\([a-zA-Z][a-zA-Z0-9_]*\).*$/\1/p' |
217 sort |
218 uniq |
219 ($egrep -v "$au_exclude_egrep" || true) > audefuns
221 # Filter out required macros.
223 sed 's/^ *//' <<MK_EOF
224 # Generated by $as_me. -*- Autotest -*-
226 ## --------------------- ##
227 ## Do not edit by hand. ##
228 ## --------------------- ##
230 # Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
232 AT_BANNER([Testing autoconf/$base macros.])
234 MK_EOF
236 echo "# Modern macros."
237 for macro in `cat acdefuns`; do
238 if grep "$macro" requires >/dev/null 2>&1; then :; else
239 echo "AT_CHECK_MACRO([$macro])"
241 done
242 echo
243 echo "# Obsolete macros."
244 for macro in `cat audefuns`; do
245 if grep "$macro" requires >/dev/null 2>&1; then :; else
246 echo "AT_CHECK_AU_MACRO([$macro])"
248 done
249 } >ac$base.tat
251 # In one atomic step so that if something above fails, the trap
252 # preserves the old version of the file. If there is nothing to
253 # check, output /rien du tout/[1].
254 if grep AT_CHECK ac$base.tat >/dev/null 2>&1; then
255 mv -f ac$base.tat ac$base.at
256 # Help people not to update these files by hand.
257 chmod a-w ac$base.at
258 else
259 rm -f ac$base.tat ac$base.at
260 touch ac$base.at
262 done
264 rm -f acdefuns audefuns requires
266 trap 0
267 exit 0
269 # [1] En franc,ais dans le texte.