]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
AC_SUBST: document and test previous patch
authorEric Blake <eblake@redhat.com>
Thu, 16 Aug 2012 04:17:49 +0000 (22:17 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 16 Aug 2012 04:23:04 +0000 (22:23 -0600)
Test that: invalid variable names are detected, that the variable
name does not get macro expanded, that assignment to the variable
works whether as part of AC_SUBST or independently, that the last
assignment wins.

* doc/autoconf.texi (Setting Output Variables) <AC_SUBST>: Mention
that variable does not overlap with macros.
* tests/base.at (AC_SUBST): New test.

Signed-off-by: Eric Blake <eblake@redhat.com>
doc/autoconf.texi
tests/base.at

index c4ebe1132b55b4f0fe021307cb8b567716979137..b3f7a2388c4246add078e9eeee5c4f1dd505556f 100644 (file)
@@ -9876,7 +9876,8 @@ output file may contain @code{|#_!!_#|}.)
 If @var{value} is given, in addition assign it to @var{variable}.
 
 The string @var{variable} is passed to @code{m4_pattern_allow}
-(@pxref{Forbidden Patterns}).
+(@pxref{Forbidden Patterns}).  @var{variable} is not further expanded,
+even if there is another macro by the same name.
 @end defmac
 
 @defmac AC_SUBST_FILE (@var{variable})
index 79794133a1fa2e7968d6a91fdd08fbf653f2fc75..d8550df758ccdf1b79e64a6e15fb299891154c3a 100644 (file)
@@ -708,3 +708,62 @@ libdir=${exec_prefix}/lib
 ]])
 
 AT_CLEANUP
+
+## ---------- ##
+## AC_SUBST.  ##
+## ---------- ##
+
+AT_SETUP([AC_SUBST])
+AT_KEYWORDS([AS@&t@_IDENTIFIER_IF])
+
+# Check that a valid variable name is used.
+AT_DATA([configure.ac],
+[[AC_INIT([test], [1])
+AC_SUBST([1], [bar])
+AC_OUTPUT
+]])
+AT_CHECK_AUTOCONF([], [1], [], [stderr])
+AT_CHECK([grep 'not a valid shell variable' stderr], [], [ignore])
+
+AT_DATA([configure.ac],
+[[AC_INIT([test], [1])
+AC_SUBST([], [bar])
+AC_OUTPUT
+]])
+AT_CHECK_AUTOCONF([], [1], [], [stderr])
+AT_CHECK([grep 'not a valid shell variable' stderr], [], [ignore])
+
+AT_DATA([configure.ac],
+[[AC_INIT([test], [1])
+AC_SUBST([*], [bar])
+AC_OUTPUT
+]])
+AT_CHECK_AUTOCONF([], [1], [], [stderr])
+AT_CHECK([grep 'not a valid shell variable' stderr], [], [ignore])
+
+# Make sure AC_SUBST handles variables as expected.
+AT_DATA([file.in],
+[[@FOO@
+@BAR@
+FOO
+]])
+AT_DATA([configure.ac],
+[[AC_INIT([test], [0])
+m4_define([FOO], [baz])
+AC_SUBST([FOO], [bar])
+BAR=one
+AC_SUBST([B@&t@AR])
+BAR=two
+AC_CONFIG_FILES([file])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF([], [], [], [stderr])
+AT_CHECK_CONFIGURE
+AT_CHECK([cat file], [],
+[[bar
+two
+FOO
+]])
+
+AT_CLEANUP