]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Namespace cleanup.
authorEric Blake <ebb9@byu.net>
Fri, 12 Oct 2007 16:34:27 +0000 (10:34 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 12 Oct 2007 16:34:27 +0000 (10:34 -0600)
* lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE)
(_AC_OUTPUT_HEADERS_PREPARE): Convert here-doc delimiters into
autoconf namespace.
* doc/autoconf.texi (Programming in M4sugar, Forbidden Patterns)
(Programming in M4sh, Macro Names): Beef up description of
namespaces reserved for autoconf.
* configure: Regenerate.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
configure
doc/autoconf.texi
lib/autoconf/status.m4

index 2fc0a0bfb9214379ff53c62e7447d0d1c69ad68f..c1d5c0dca7af9796ac6c0076fb0d53dbb0fffad8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-10-12  Eric Blake  <ebb9@byu.net>
+
+       Namespace cleanup.
+       * lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE)
+       (_AC_OUTPUT_HEADERS_PREPARE): Convert here-doc delimiters into
+       autoconf namespace.
+       * doc/autoconf.texi (Programming in M4sugar, Forbidden Patterns)
+       (Programming in M4sh, Macro Names): Beef up description of
+       namespaces reserved for autoconf.
+       * configure: Regenerate.
+
 2007-10-12  Eric Blake  <ebb9@byu.net>
        and Paolo Bonzini  <bonzini@gnu.org>
 
index a7a7eb15a1c9709e16c205072e29078b4c41e2a1..bccfc0a4cb27f9a678dab738c010b037bc6d020f 100755 (executable)
--- a/configure
+++ b/configure
@@ -3574,7 +3574,7 @@ done
 rm -f conf$$subs.sh
 
 cat >>$CONFIG_STATUS <<_ACEOF
-cat >>"\$tmp/subs1.awk" <<\CEOF
+cat >>"\$tmp/subs1.awk" <<\_ACAWK
 _ACEOF
 sed -n '
 h
@@ -3621,8 +3621,8 @@ t delim
 ' >>$CONFIG_STATUS
 rm -f conf$$subs.awk
 cat >>$CONFIG_STATUS <<_ACEOF
-CEOF
-cat >>"\$tmp/subs1.awk" <<CEOF
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK
   for (key in S) S_is_set[key] = 1
   FS = "\a"
 
@@ -3647,7 +3647,7 @@ cat >>"\$tmp/subs1.awk" <<CEOF
   print line
 }
 
-CEOF
+_ACAWK
 sed "s/\$ac_cr\\\$//; s/\$ac_cr/\$ac_cs_awk_cr/g" < "\$tmp/subs1.awk" > "\$tmp/subs.awk"
 _ACEOF
 
index faeb9fc36b61ecb7f06cf1da413ac43a812319ac..74295b6554d248bb07fdda64f48e2add4386212c 100644 (file)
@@ -10073,6 +10073,10 @@ macros.  M4sugar introduces additional generic macros.  Its name was
 coined by Lars J. Aas: ``Readability And Greater Understanding Stands 4
 M4sugar''.
 
+M4sugar reserves the macro namespace @samp{^_m4_} for internal use, and
+the macro namespace @samp{^m4_} for M4sugar macros.  You should not
+define your own macros into these namespaces.
+
 @menu
 * Redefined M4 Macros::         M4 builtins changed in M4sugar
 * Conditional constructs::      Conditions in M4
@@ -10554,7 +10558,9 @@ instance, if an Autoconf @file{configure} script includes tokens such as
 @samp{AC_DEFINE}, or @samp{dnl}, then most probably something went
 wrong (typically a macro was not evaluated because of overquotation).
 
-M4sugar forbids all the tokens matching @samp{^m4_} and @samp{^dnl$}.
+M4sugar forbids all the tokens matching @samp{^_?m4_} and @samp{^dnl$}.
+Additional layers, such as M4sh and Autoconf, add additional forbidden
+patterns to the list.
 
 @defmac m4_pattern_forbid (@var{pattern})
 @msindex{pattern_forbid}
@@ -10563,8 +10569,9 @@ Comments are not checked; this can be a problem if, for instance, you
 have some macro left unexpanded after an @samp{#include}.  No consensus
 is currently found in the Autoconf community, as some people consider it
 should be valid to name macros in comments (which doesn't make sense to
-the author of this documentation, as @samp{#}-comments should document
-the output, not the input, documented by @samp{dnl} comments).
+the authors of this documentation: input, such as macros, should be
+documented by @samp{dnl} comments; reserving @samp{#}-comments to
+document the output).
 @end defmac
 
 Of course, you might encounter exceptions to these generic rules, for
@@ -10606,6 +10613,13 @@ A mess; trouble.  [Obs.] --Beau.@: & Fl.
 
 For the time being, it is not mature enough to be widely used.
 
+M4sh reserves the M4 macro namespace @samp{^_AS_} for internal use, and
+the namespace @samp{^AS_} for M4sh macros.  It also reserves the shell
+and environment variable namespace @samp{^as_}, and the here-doc
+delimiter namespace @samp{^_AS[A-Z]} in the output file.  You should not
+define your own macros or output shell code that conflicts with these
+namespaces.
+
 M4sh provides portable alternatives for some common shell constructs
 that unfortunately are not portable in practice.
 
@@ -10851,14 +10865,36 @@ that produce no output, such as @code{AC_REQUIRE}.
 @node Macro Names
 @section Macro Names
 
-All of the Autoconf macros have all-uppercase names starting with
-@samp{AC_} to prevent them from accidentally conflicting with other
-text.  All shell variables that they use for internal purposes have
-mostly-lowercase names starting with @samp{ac_}.  To ensure that your
-macros don't conflict with present or future Autoconf macros, you should
-prefix your own macro names and any shell variables they use with some
-other sequence.  Possibilities include your initials, or an abbreviation
-for the name of your organization or software package.
+All of the public Autoconf macros have all-uppercase names in the
+namespace @samp{^AC_} to prevent them from accidentally conflicting with
+other text; Autoconf also reserves the namespace @samp{^_AC_} for
+internal macros.  All shell variables that they use for internal
+purposes have mostly-lowercase names starting with @samp{ac_}.  Autoconf
+also uses here-doc delimiters in the namespace @samp{^_AC[A-Z]}.  During
+@command{configure}, files produced by Autoconf make heavy use of the
+file system namespace @samp{^conf}.
+
+Since Autoconf is built on top of M4sugar (@pxref{Programming in
+M4sugar}) and M4sh (@pxref{Programming in M4sh}), you must also be aware
+of those namespaces (@samp{^_?\(m4\|AS\)_}).  And since
+@file{configure.ac} is also designed to be scanned by Autoheader,
+Autoscan, Autoupdate, and Automake, you should be aware of the
+@samp{^_?A[HNUM]_} namespaces.  In general, you @emph{should not use}
+the namespace of a package that does not own the macro or shell code you
+are writing.
+
+To ensure that your macros don't conflict with present or future
+Autoconf macros, you should prefix your own macro names and any shell
+variables they use with some other sequence.  Possibilities include your
+initials, or an abbreviation for the name of your organization or
+software package.  Historically, people have not always followed the
+rule of using a namespace appropriate for their package, and this has
+made it difficult for determining the origin of a macro (and where to
+report bugs about that macro), as well as difficult for the true
+namespace owner to add new macros without interference from pre-existing
+uses of third-party macros.  Perhaps the best example of this confusion
+is the @code{AM_GNU_GETTEXT} macro, which belongs, not to Automake, but
+to Gettext.
 
 Most of the Autoconf macros' names follow a structured naming convention
 that indicates the kind of feature check by the name.  The macro names
@@ -10867,7 +10903,8 @@ general to most specific.  The names of their cache variables use the
 same convention (@pxref{Cache Variable Names}, for more information on
 them).
 
-The first word of the name after @samp{AC_} usually tells the category
+The first word of the name after the namepace initials (such as
+@samp{AC_}) usually tells the category
 of the feature being tested.  Here are the categories used in Autoconf for
 specific test macros, the kind of macro that you are more likely to
 write.  They are also used for cache variables, in all-lowercase.  Use
index 0c00af20159f1d38cd877a2d9125660669eb0809..1511aae2d4edce3d333862b332bceda99e81fc95 100644 (file)
@@ -387,9 +387,9 @@ m4_ifdef([_AC_SUBST_FILES],
 [# Create commands to substitute file output variables.
 {
   echo "cat >>$CONFIG_STATUS <<_ACEOF"
-  echo 'cat >>"\$tmp/subs1.awk" <<\CEOF'
+  echo 'cat >>"\$tmp/subs1.awk" <<\_ACAWK'
   echo "$ac_subst_files" | sed 's/.*/F@<:@"&"@:>@="$&"/'
-  echo "CEOF"
+  echo "_ACAWK"
   echo "_ACEOF"
 } >conf$$files.sh
 . ./conf$$files.sh
@@ -444,7 +444,7 @@ dnl - Writing `$ 0' prevents expansion by both the shell and m4 here.
 dnl
 dnl m4-double-quote most of the scripting for readability.
 [cat >>$CONFIG_STATUS <<_ACEOF
-cat >>"\$tmp/subs1.awk" <<\CEOF
+cat >>"\$tmp/subs1.awk" <<\_ACAWK
 _ACEOF
 sed -n '
 h
@@ -491,8 +491,8 @@ t delim
 ' >>$CONFIG_STATUS
 rm -f conf$$subs.awk
 cat >>$CONFIG_STATUS <<_ACEOF
-CEOF
-cat >>"\$tmp/subs1.awk" <<CEOF
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK
   for (key in S) S_is_set[key] = 1
   FS = "\a"
 ]m4_ifdef([_AC_SUBST_FILES],
@@ -526,7 +526,7 @@ cat >>"\$tmp/subs1.awk" <<CEOF
 }
 ]m4_ifdef([_AC_SUBST_FILES],
 [\$ac_cs_awk_pipe_fini])[
-CEOF
+_ACAWK
 sed "s/\$ac_cr\\\$//; s/\$ac_cr/\$ac_cs_awk_cr/g" < "\$tmp/subs1.awk" > "\$tmp/subs.awk"
 _ACEOF
 ]dnl end of double-quoted part
@@ -586,13 +586,13 @@ m4_ifndef([AC_DATAROOTDIR_CHECKED],
 # FIXME: This hack should be removed a few years after 2.60.
 ac_datarootdir_hack=; ac_datarootdir_seen=
 m4_define([_AC_datarootdir_vars],
-          [datadir, docdir, infodir, localedir, mandir])
+         [datadir, docdir, infodir, localedir, mandir])
 case `sed -n '/datarootdir/ {
   p
   q
 }
 m4_foreach([_AC_Var], m4_defn([_AC_datarootdir_vars]),
-           [/@_AC_Var@/p
+          [/@_AC_Var@/p
 ])' $ac_file_inputs` in
 *datarootdir*) ac_datarootdir_seen=yes;;
 *@[]m4_join([@*|*@], _AC_datarootdir_vars)@*)
@@ -601,7 +601,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
   ac_datarootdir_hack='
   m4_foreach([_AC_Var], m4_defn([_AC_datarootdir_vars]),
-               [s&@_AC_Var@&$_AC_Var&g
+              [s&@_AC_Var@&$_AC_Var&g
   ])dnl
   s&\\\${datarootdir}&$datarootdir&g' ;;
 esac
@@ -688,7 +688,7 @@ m4_define([_AC_OUTPUT_HEADERS_PREPARE],
 # No need to generate them if there are no CONFIG_HEADERS.
 # This happens for instance with `./config.status Makefile'.
 if test -n "$CONFIG_HEADERS"; then
-cat >"$tmp/defines.awk" <<\_CEOF
+cat >"$tmp/defines.awk" <<\_ACAWK
 BEGIN {
 _ACEOF
 
@@ -807,7 +807,7 @@ cat >>$CONFIG_STATUS <<_ACEOF
 }
 { print }
 ]dnl End of double-quoted section
-_CEOF
+_ACAWK
 _ACEOF
 
 cat >>$CONFIG_STATUS <<\_ACEOF