From: Akim Demaille Date: Tue, 14 Nov 2000 11:06:37 +0000 (+0000) Subject: A single m4_require is enough. X-Git-Tag: autoconf-2.50~423 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e56675bc8d98814eeeb9427bfc37faf9769efe2;p=thirdparty%2Fautoconf.git A single m4_require is enough. * m4sugar.m4 (_m4_require): $2 defaults to $1. Rename as... (m4_require): this. * acgeneral.m4 (_AC_REQUIRE): Remove, use m4_require if you want to get into the gory details. --- diff --git a/ChangeLog b/ChangeLog index 0e4565162..2035b7ac0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2000-11-14 Akim Demaille + + A single m4_require is enough. + + * m4sugar.m4 (_m4_require): $2 defaults to $1. + Rename as... + (m4_require): this. + * acgeneral.m4 (_AC_REQUIRE): Remove, use m4_require if you want + to get into the gory details. + 2000-11-14 Akim Demaille * acgeneral.m4 (_AC_INIT_DEFAULTS_ENVIRONMENT): Rename as... diff --git a/acgeneral.m4 b/acgeneral.m4 index 6f9987fe3..d9effa7a9 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -167,20 +167,14 @@ m4_pushdef([_m4_divert_diversion], _m4_divert([KILL])) ## Defining macros in autoconf::. ## ## ------------------------------- ## -# `AC_DEFUN' is basically `define' but it equips the macro with the -# needed machinery for `AC_REQUIRE'. A macro must be AC_DEFUN'd if -# either it is AC_REQUIRE'd, or it AC_REQUIRE's. # AC_DEFUN(NAME, EXPANSION) # ------------------------- -# Define a macro which automatically provides itself. Add machinery -# so the macro automatically switches expansion to the diversion -# stack if it is not already using it. In this case, once finished, -# it will bring back all the code accumulated in the diversion stack. -# This, combined with AC_REQUIRE, achieves the topological ordering of -# macros. We don't use this macro to define some frequently called -# macros that are not involved in ordering constraints, to save m4 -# processing. +# Same as `m4_define' but equip the macro with the needed machinery +# for `AC_REQUIRE'. +# +# We don't use this macro to define some frequently called macros that +# are not involved in ordering constraints, to save m4 processing. m4_define([AC_DEFUN], [m4_defun([$1], [$2[]AC_PROVIDE([$1])])]) @@ -213,44 +207,12 @@ m4_define([AC_BEFORE], [AC_PROVIDE_IFELSE([$2], [AC_DIAGNOSE([syntax], [$2 was called before $1])])]) -# _AC_REQUIRE(NAME-TO-CHECK, BODY-TO-EXPAND) -# ------------------------------------------ -# If NAME-TO-CHECK has never been expanded (actually, if it is not -# AC_PROVIDE'd), expand BODY-TO-EXPAND *before* the current macro -# expansion. Once expanded, emit it in _m4_divert_dump. Keep track -# of the AC_REQUIRE chain in _AC_EXPANSION_STACK. -# -# The normal cases are: -# -# - NAME-TO-CHECK == BODY-TO-EXPAND -# Which you can use for regular macros with or without arguments, e.g., -# _AC_REQUIRE([AC_PROG_CC], [AC_PROG_CC]) -# _AC_REQUIRE([AC_CHECK_HEADERS(limits.h)], [AC_CHECK_HEADERS(limits.h)]) -# -# - BODY-TO-EXPAND == m4_indir([NAME-TO-CHECK]) -# In the case of macros with irregular names. For instance: -# _AC_REQUIRE([AC_LANG_COMPILER(C)], [m4_indir([AC_LANG_COMPILER(C)])]) -# which means `if the macro named `AC_LANG_COMPILER(C)' (the parens are -# part of the name, it is not an argument) has not been run, then -# call it.' -# Had you used -# _AC_REQUIRE([AC_LANG_COMPILER(C)], [AC_LANG_COMPILER(C)]) -# then _AC_REQUIRE would have tried to expand `AC_LANG_COMPILER(C)', i.e., -# call the macro `AC_LANG_COMPILER' with `C' as argument. -# -# You could argue that `AC_LANG_COMPILER', when it receives an argument -# such as `C' should dispatch the call to `AC_LANG_COMPILER(C)'. But this -# `extension' prevents `AC_LANG_COMPILER' from having actual arguments that -# it passes to `AC_LANG_COMPILER(C)'. -m4_define([_AC_REQUIRE], -[_m4_require($@)]) - - # AC_REQUIRE(STRING) # ------------------ -# If STRING has never been AC_PROVIDE'd, then expand it. +# If STRING has never been AC_PROVIDE'd, then expand it. A macro must +# be AC_DEFUN'd if either it is AC_REQUIRE'd, or it AC_REQUIRE's. m4_define([AC_REQUIRE], -[m4_require($@)]) +[m4_require([$1])]) # AC_EXPAND_ONCE(TEXT) diff --git a/aclang.m4 b/aclang.m4 index 3ef150498..6ae8effff 100644 --- a/aclang.m4 +++ b/aclang.m4 @@ -508,8 +508,8 @@ _AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # ------------------------ # Ensure we have a compiler for the current LANG. AC_DEFUN([AC_LANG_COMPILER_REQUIRE], -[_AC_REQUIRE([AC_LANG_COMPILER(]_AC_LANG[)], - [AC_LANG_COMPILER])]) +[m4_require([AC_LANG_COMPILER(]_AC_LANG[)], + [AC_LANG_COMPILER])]) # _AC_LANG_COMPILER_WORKS @@ -570,8 +570,8 @@ _AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # ----------------------- # Ensure we have a preprocessor for the current language. AC_DEFUN([AC_LANG_PREPROC_REQUIRE], -[_AC_REQUIRE([AC_LANG_PREPROC(]_AC_LANG[)], - [AC_LANG_PREPROC])]) +[m4_require([AC_LANG_PREPROC(]_AC_LANG[)], + [AC_LANG_PREPROC])]) # AC_REQUIRE_CPP diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index 3ef150498..6ae8effff 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -508,8 +508,8 @@ _AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # ------------------------ # Ensure we have a compiler for the current LANG. AC_DEFUN([AC_LANG_COMPILER_REQUIRE], -[_AC_REQUIRE([AC_LANG_COMPILER(]_AC_LANG[)], - [AC_LANG_COMPILER])]) +[m4_require([AC_LANG_COMPILER(]_AC_LANG[)], + [AC_LANG_COMPILER])]) # _AC_LANG_COMPILER_WORKS @@ -570,8 +570,8 @@ _AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # ----------------------- # Ensure we have a preprocessor for the current language. AC_DEFUN([AC_LANG_PREPROC_REQUIRE], -[_AC_REQUIRE([AC_LANG_PREPROC(]_AC_LANG[)], - [AC_LANG_PREPROC])]) +[m4_require([AC_LANG_PREPROC(]_AC_LANG[)], + [AC_LANG_PREPROC])]) # AC_REQUIRE_CPP diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4 index 3ef150498..6ae8effff 100644 --- a/lib/autoconf/fortran.m4 +++ b/lib/autoconf/fortran.m4 @@ -508,8 +508,8 @@ _AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # ------------------------ # Ensure we have a compiler for the current LANG. AC_DEFUN([AC_LANG_COMPILER_REQUIRE], -[_AC_REQUIRE([AC_LANG_COMPILER(]_AC_LANG[)], - [AC_LANG_COMPILER])]) +[m4_require([AC_LANG_COMPILER(]_AC_LANG[)], + [AC_LANG_COMPILER])]) # _AC_LANG_COMPILER_WORKS @@ -570,8 +570,8 @@ _AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # ----------------------- # Ensure we have a preprocessor for the current language. AC_DEFUN([AC_LANG_PREPROC_REQUIRE], -[_AC_REQUIRE([AC_LANG_PREPROC(]_AC_LANG[)], - [AC_LANG_PREPROC])]) +[m4_require([AC_LANG_PREPROC(]_AC_LANG[)], + [AC_LANG_PREPROC])]) # AC_REQUIRE_CPP diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 6f9987fe3..d9effa7a9 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -167,20 +167,14 @@ m4_pushdef([_m4_divert_diversion], _m4_divert([KILL])) ## Defining macros in autoconf::. ## ## ------------------------------- ## -# `AC_DEFUN' is basically `define' but it equips the macro with the -# needed machinery for `AC_REQUIRE'. A macro must be AC_DEFUN'd if -# either it is AC_REQUIRE'd, or it AC_REQUIRE's. # AC_DEFUN(NAME, EXPANSION) # ------------------------- -# Define a macro which automatically provides itself. Add machinery -# so the macro automatically switches expansion to the diversion -# stack if it is not already using it. In this case, once finished, -# it will bring back all the code accumulated in the diversion stack. -# This, combined with AC_REQUIRE, achieves the topological ordering of -# macros. We don't use this macro to define some frequently called -# macros that are not involved in ordering constraints, to save m4 -# processing. +# Same as `m4_define' but equip the macro with the needed machinery +# for `AC_REQUIRE'. +# +# We don't use this macro to define some frequently called macros that +# are not involved in ordering constraints, to save m4 processing. m4_define([AC_DEFUN], [m4_defun([$1], [$2[]AC_PROVIDE([$1])])]) @@ -213,44 +207,12 @@ m4_define([AC_BEFORE], [AC_PROVIDE_IFELSE([$2], [AC_DIAGNOSE([syntax], [$2 was called before $1])])]) -# _AC_REQUIRE(NAME-TO-CHECK, BODY-TO-EXPAND) -# ------------------------------------------ -# If NAME-TO-CHECK has never been expanded (actually, if it is not -# AC_PROVIDE'd), expand BODY-TO-EXPAND *before* the current macro -# expansion. Once expanded, emit it in _m4_divert_dump. Keep track -# of the AC_REQUIRE chain in _AC_EXPANSION_STACK. -# -# The normal cases are: -# -# - NAME-TO-CHECK == BODY-TO-EXPAND -# Which you can use for regular macros with or without arguments, e.g., -# _AC_REQUIRE([AC_PROG_CC], [AC_PROG_CC]) -# _AC_REQUIRE([AC_CHECK_HEADERS(limits.h)], [AC_CHECK_HEADERS(limits.h)]) -# -# - BODY-TO-EXPAND == m4_indir([NAME-TO-CHECK]) -# In the case of macros with irregular names. For instance: -# _AC_REQUIRE([AC_LANG_COMPILER(C)], [m4_indir([AC_LANG_COMPILER(C)])]) -# which means `if the macro named `AC_LANG_COMPILER(C)' (the parens are -# part of the name, it is not an argument) has not been run, then -# call it.' -# Had you used -# _AC_REQUIRE([AC_LANG_COMPILER(C)], [AC_LANG_COMPILER(C)]) -# then _AC_REQUIRE would have tried to expand `AC_LANG_COMPILER(C)', i.e., -# call the macro `AC_LANG_COMPILER' with `C' as argument. -# -# You could argue that `AC_LANG_COMPILER', when it receives an argument -# such as `C' should dispatch the call to `AC_LANG_COMPILER(C)'. But this -# `extension' prevents `AC_LANG_COMPILER' from having actual arguments that -# it passes to `AC_LANG_COMPILER(C)'. -m4_define([_AC_REQUIRE], -[_m4_require($@)]) - - # AC_REQUIRE(STRING) # ------------------ -# If STRING has never been AC_PROVIDE'd, then expand it. +# If STRING has never been AC_PROVIDE'd, then expand it. A macro must +# be AC_DEFUN'd if either it is AC_REQUIRE'd, or it AC_REQUIRE's. m4_define([AC_REQUIRE], -[m4_require($@)]) +[m4_require([$1])]) # AC_EXPAND_ONCE(TEXT) diff --git a/lib/autoconf/lang.m4 b/lib/autoconf/lang.m4 index 3ef150498..6ae8effff 100644 --- a/lib/autoconf/lang.m4 +++ b/lib/autoconf/lang.m4 @@ -508,8 +508,8 @@ _AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # ------------------------ # Ensure we have a compiler for the current LANG. AC_DEFUN([AC_LANG_COMPILER_REQUIRE], -[_AC_REQUIRE([AC_LANG_COMPILER(]_AC_LANG[)], - [AC_LANG_COMPILER])]) +[m4_require([AC_LANG_COMPILER(]_AC_LANG[)], + [AC_LANG_COMPILER])]) # _AC_LANG_COMPILER_WORKS @@ -570,8 +570,8 @@ _AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # ----------------------- # Ensure we have a preprocessor for the current language. AC_DEFUN([AC_LANG_PREPROC_REQUIRE], -[_AC_REQUIRE([AC_LANG_PREPROC(]_AC_LANG[)], - [AC_LANG_PREPROC])]) +[m4_require([AC_LANG_PREPROC(]_AC_LANG[)], + [AC_LANG_PREPROC])]) # AC_REQUIRE_CPP diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4 index 742fe1bc9..7b8f560c0 100644 --- a/lib/m4sugar/m4sugar.m4 +++ b/lib/m4sugar/m4sugar.m4 @@ -1097,8 +1097,8 @@ m4_define([m4_before], [m4_warn([syntax], [$2 was called before $1])])]) -# _m4_require(NAME-TO-CHECK, BODY-TO-EXPAND) -# ------------------------------------------ +# m4_require(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK]) +# ----------------------------------------------------------- # If NAME-TO-CHECK has never been expanded (actually, if it is not # m4_provide'd), expand BODY-TO-EXPAND *before* the current macro # expansion. Once expanded, emit it in _m4_divert_dump. Keep track @@ -1108,35 +1108,38 @@ m4_define([m4_before], # # - NAME-TO-CHECK == BODY-TO-EXPAND # Which you can use for regular macros with or without arguments, e.g., -# _m4_require([AC_PROG_CC], [AC_PROG_CC]) -# _m4_require([AC_CHECK_HEADERS(limits.h)], [AC_CHECK_HEADERS(limits.h)]) +# m4_require([AC_PROG_CC], [AC_PROG_CC]) +# m4_require([AC_CHECK_HEADERS(limits.h)], [AC_CHECK_HEADERS(limits.h)]) +# which is just the same as +# m4_require([AC_PROG_CC]) +# m4_require([AC_CHECK_HEADERS(limits.h)]) # # - BODY-TO-EXPAND == m4_indir([NAME-TO-CHECK]) # In the case of macros with irregular names. For instance: -# _m4_require([AC_LANG_COMPILER(C)], [indir([AC_LANG_COMPILER(C)])]) +# m4_require([AC_LANG_COMPILER(C)], [indir([AC_LANG_COMPILER(C)])]) # which means `if the macro named `AC_LANG_COMPILER(C)' (the parens are # part of the name, it is not an argument) has not been run, then # call it.' # Had you used -# _m4_require([AC_LANG_COMPILER(C)], [AC_LANG_COMPILER(C)]) -# then _m4_require would have tried to expand `AC_LANG_COMPILER(C)', i.e., +# m4_require([AC_LANG_COMPILER(C)], [AC_LANG_COMPILER(C)]) +# then m4_require would have tried to expand `AC_LANG_COMPILER(C)', i.e., # call the macro `AC_LANG_COMPILER' with `C' as argument. # # You could argue that `AC_LANG_COMPILER', when it receives an argument # such as `C' should dispatch the call to `AC_LANG_COMPILER(C)'. But this # `extension' prevents `AC_LANG_COMPILER' from having actual arguments that # it passes to `AC_LANG_COMPILER(C)'. -m4_define([_m4_require], +m4_define([m4_require], [m4_pushdef([_m4_expansion_stack], m4_location[: $1 is required by...])dnl ifdef([_m4_expanding($1)], - [m4_fatal([m4_require: circular dependency of $1])])dnl + [m4_fatal([$0: circular dependency of $1])])dnl ifndef([_m4_divert_dump], - [m4_fatal([m4_require: cannot be used outside of an m4_defun'd macro])])dnl + [m4_fatal([$0: cannot be used outside of an m4_defun'd macro])])dnl m4_provide_ifelse([$1], [], [m4_divert_push(m4_eval(_m4_divert_diversion - 1))dnl -$2 +m4_default([$2], [$1]) divert(_m4_divert_dump)undivert(_m4_divert_diversion)dnl m4_divert_pop()])dnl m4_provide_ifelse([$1], @@ -1147,13 +1150,6 @@ m4_popdef([_m4_expansion_stack])dnl ]) -# m4_require(STRING) -# ------------------ -# If STRING has never been m4_provide'd, then expand it. -m4_define([m4_require], -[_m4_require([$1], [$1])]) - - # m4_expand_once(TEXT) # -------------------- # If TEXT has never been expanded, expand it *here*. diff --git a/m4sugar.m4 b/m4sugar.m4 index 742fe1bc9..7b8f560c0 100644 --- a/m4sugar.m4 +++ b/m4sugar.m4 @@ -1097,8 +1097,8 @@ m4_define([m4_before], [m4_warn([syntax], [$2 was called before $1])])]) -# _m4_require(NAME-TO-CHECK, BODY-TO-EXPAND) -# ------------------------------------------ +# m4_require(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK]) +# ----------------------------------------------------------- # If NAME-TO-CHECK has never been expanded (actually, if it is not # m4_provide'd), expand BODY-TO-EXPAND *before* the current macro # expansion. Once expanded, emit it in _m4_divert_dump. Keep track @@ -1108,35 +1108,38 @@ m4_define([m4_before], # # - NAME-TO-CHECK == BODY-TO-EXPAND # Which you can use for regular macros with or without arguments, e.g., -# _m4_require([AC_PROG_CC], [AC_PROG_CC]) -# _m4_require([AC_CHECK_HEADERS(limits.h)], [AC_CHECK_HEADERS(limits.h)]) +# m4_require([AC_PROG_CC], [AC_PROG_CC]) +# m4_require([AC_CHECK_HEADERS(limits.h)], [AC_CHECK_HEADERS(limits.h)]) +# which is just the same as +# m4_require([AC_PROG_CC]) +# m4_require([AC_CHECK_HEADERS(limits.h)]) # # - BODY-TO-EXPAND == m4_indir([NAME-TO-CHECK]) # In the case of macros with irregular names. For instance: -# _m4_require([AC_LANG_COMPILER(C)], [indir([AC_LANG_COMPILER(C)])]) +# m4_require([AC_LANG_COMPILER(C)], [indir([AC_LANG_COMPILER(C)])]) # which means `if the macro named `AC_LANG_COMPILER(C)' (the parens are # part of the name, it is not an argument) has not been run, then # call it.' # Had you used -# _m4_require([AC_LANG_COMPILER(C)], [AC_LANG_COMPILER(C)]) -# then _m4_require would have tried to expand `AC_LANG_COMPILER(C)', i.e., +# m4_require([AC_LANG_COMPILER(C)], [AC_LANG_COMPILER(C)]) +# then m4_require would have tried to expand `AC_LANG_COMPILER(C)', i.e., # call the macro `AC_LANG_COMPILER' with `C' as argument. # # You could argue that `AC_LANG_COMPILER', when it receives an argument # such as `C' should dispatch the call to `AC_LANG_COMPILER(C)'. But this # `extension' prevents `AC_LANG_COMPILER' from having actual arguments that # it passes to `AC_LANG_COMPILER(C)'. -m4_define([_m4_require], +m4_define([m4_require], [m4_pushdef([_m4_expansion_stack], m4_location[: $1 is required by...])dnl ifdef([_m4_expanding($1)], - [m4_fatal([m4_require: circular dependency of $1])])dnl + [m4_fatal([$0: circular dependency of $1])])dnl ifndef([_m4_divert_dump], - [m4_fatal([m4_require: cannot be used outside of an m4_defun'd macro])])dnl + [m4_fatal([$0: cannot be used outside of an m4_defun'd macro])])dnl m4_provide_ifelse([$1], [], [m4_divert_push(m4_eval(_m4_divert_diversion - 1))dnl -$2 +m4_default([$2], [$1]) divert(_m4_divert_dump)undivert(_m4_divert_diversion)dnl m4_divert_pop()])dnl m4_provide_ifelse([$1], @@ -1147,13 +1150,6 @@ m4_popdef([_m4_expansion_stack])dnl ]) -# m4_require(STRING) -# ------------------ -# If STRING has never been m4_provide'd, then expand it. -m4_define([m4_require], -[_m4_require([$1], [$1])]) - - # m4_expand_once(TEXT) # -------------------- # If TEXT has never been expanded, expand it *here*.