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