autoupdate.m4 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # This file is part of Autoconf. -*- Autoconf -*-
  2. # Interface with autoupdate.
  3. # Copyright (C) 1992-1996, 1998-2001, 2003-2004, 2006, 2009-2012 Free
  4. # Software Foundation, Inc.
  5. # This file is part of Autoconf. This program is free
  6. # software; you can redistribute it and/or modify it under the
  7. # terms of the GNU General Public License as published by the
  8. # Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  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.
  15. #
  16. # Under Section 7 of GPL version 3, you are granted additional
  17. # permissions described in the Autoconf Configure Script Exception,
  18. # version 3.0, as published by the Free Software Foundation.
  19. #
  20. # You should have received a copy of the GNU General Public License
  21. # and a copy of the Autoconf Configure Script Exception along with
  22. # this program; see the files COPYINGv3 and COPYING.EXCEPTION
  23. # respectively. If not, see <http://www.gnu.org/licenses/>.
  24. # Written by David MacKenzie, with help from
  25. # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
  26. # Roland McGrath, Noah Friedman, david d zuhn, and many others.
  27. ## ---------------------------------- ##
  28. ## Macros to define obsolete macros. ##
  29. ## ---------------------------------- ##
  30. # AU_DEFINE(NAME, CODE)
  31. # ---------------------
  32. # Define the macro NAME so that it expand to CODE only when
  33. # autoupdate is running. This is achieved with traces in
  34. # autoupdate itself, so this macro expands to nothing.
  35. #
  36. m4_define([AU_DEFINE], [])
  37. # AU_DEFUN(NAME, NEW-CODE, [MESSAGE])
  38. # -----------------------------------
  39. # Declare that the macro NAME is now obsoleted, and should be replaced
  40. # by NEW-CODE. Tell the user she should run autoupdate, and when
  41. # autoupdate is run, emit MESSAGE as a warning and include it in
  42. # the updated configure.ac file.
  43. #
  44. # Also define NAME as a macro which code is NEW-CODE.
  45. #
  46. # This allows sharing the same code for both supporting obsoleted macros,
  47. # and to update a configure.ac.
  48. # See the end of `autoupdate.in' for a longer description.
  49. m4_define([AU_DEFUN],
  50. [# This is what autoupdate's m4 run will expand. It fires
  51. # the warning (with _au_warn_XXX), outputs it into the
  52. # updated configure.ac (with AC_DIAGNOSE), and then outputs
  53. # the replacement expansion.
  54. AU_DEFINE([$1],
  55. [m4_ifval([$3], [_au_warn_$1([$3])AC_DIAGNOSE([obsolete], [$3])d[]nl
  56. ])dnl
  57. $2])
  58. # This is an auxiliary macro that is also run when
  59. # autoupdate runs m4. It simply calls m4_warning, but
  60. # we need a wrapper so that each warning is emitted only
  61. # once. We break the quoting in m4_warning's argument in
  62. # order to expand this macro's arguments, not AU_DEFUN's.
  63. AU_DEFINE([_au_warn_$1],
  64. [m4_warning($][@)dnl
  65. m4_define([_au_warn_$1], [])])
  66. # Finally, this is the expansion that is picked up by
  67. # autoconf. It tells the user to run autoupdate, and
  68. # then outputs the replacement expansion. We do not care
  69. # about autoupdate's warning because that contains
  70. # information on what to do *after* running autoupdate.
  71. AC_DEFUN([$1],
  72. [AC_DIAGNOSE([obsolete], [The macro `$1' is obsolete.
  73. You should run autoupdate.])dnl
  74. $2])])
  75. # AU_ALIAS(OLD-NAME, NEW-NAME)
  76. # ----------------------------
  77. # The OLD-NAME is no longer used, just use NEW-NAME instead. There is
  78. # little difference with using AU_DEFUN but the fact there is little
  79. # interest in running the test suite on both OLD-NAME and NEW-NAME.
  80. # This macro makes it possible to distinguish such cases.
  81. #
  82. # Do not use `defn' since then autoupdate would replace an old macro
  83. # call with the new macro body instead of the new macro call.
  84. #
  85. # Moreover, we have to take care that calls without parameters are
  86. # expanded to calls without parameters, not with one empty parameter.
  87. # This is not only an aesthetic improvement of autoupdate, it also
  88. # matters with poorly written macros which test for $# = 0.
  89. #
  90. m4_define([AU_ALIAS],
  91. [AU_DEFUN([$1], _AU_ALIAS_BODY([$], [$2]))])
  92. # The body for the AU_DEFUN above should look like:
  93. # [m4_if($#, 0, [NEW-NAME], [NEW-NAME($@)])]
  94. # Thus the helper macro is:
  95. m4_define([_AU_ALIAS_BODY], [[m4_if($1#, 0, [$2], [$2($1@)])]])