mktests.sh 6.3 KB

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