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