[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fyi-ac-arg-var.patch
From: |
Akim Demaille |
Subject: |
fyi-ac-arg-var.patch |
Date: |
Sun, 17 Jun 2001 20:15:48 +0200 |
Index: ChangeLog
from Akim Demaille <address@hidden>
* acgeneral.m4 (_AC_ARG_VAR_VALIDATE): Be sure to cache the
current values of the precious variables, not the previously
cached values.
Pass precious variables which are set to config.status.
* doc/autoconf.texi (Setting Output Variables): Document AC_ARG_VAR.
* tests/torture.at (AC_ARG_VAR): New.
Index: NEWS
--- NEWS Mon, 04 Jun 2001 18:29:01 +0200 akim (ace/31_NEWS 1.41 644)
+++ NEWS Sun, 17 Jun 2001 14:17:55 +0200 akim (ace/31_NEWS 1.41 644)
@@ -5,6 +5,12 @@
** Bug fixes
- Mostly in the test suite.
- Invocation of GNU M4 now robust to POSIXLY_CORRECT.
+
+- AC_ARG_VAR: The latest value of precious variables is saved, instead
+ of the first one.
+- AC_ARG_VAR is documented.
+- AC_ARG_VAR properly propagates precious variables inherited from the
+ environment to ./config.status.
* Major changes in Autoconf 2.50
Index: acgeneral.m4
--- acgeneral.m4 Mon, 04 Jun 2001 18:29:01 +0200 akim (ace/27_acgeneral.
1.169.8.134 644)
+++ acgeneral.m4 Sun, 17 Jun 2001 15:52:56 +0200 akim (ace/27_acgeneral.
1.169.8.134 644)
@@ -1497,6 +1497,19 @@ m4_define([_AC_ARG_VAR_PRECIOUS],
# _AC_ARG_VAR_VALIDATE
# --------------------
+# The precious variables are saved twice at the beginning of
+# configure. E.g., PRECIOUS, is saved as `ac_env_PRECIOUS_SET' and
+# `ac_env_PRECIOUS_VALUE' on the one hand and `ac_cv_env_PRECIOUS_SET'
+# and `ac_cv_env_PRECIOUS_VALUE' on the other hand.
+#
+# Now the cache has just been load, so `ac_cv_env_' represents the
+# content of the cached values, while `ac_env_' represents that of the
+# current values.
+#
+# So we check that `ac_env_' and `ac_cv_env_' are consistant. But if
+# they aren't, be sure to update the `ac_cv_env_' values with the
+# `ac_env_' ones, otherwise, we would save again the old values in the
+# cache.
m4_define([_AC_ARG_VAR_VALIDATE],
[# Check that the precious variables saved in the cache have kept the same
# value.
@@ -1523,6 +1536,23 @@ m4_define([_AC_ARG_VAR_VALIDATE],
ac_suggest_removing_cache=:
fi;;
esac
+ # Synchronize cached values with current values.
+ eval ac_cv_env_${ac_var}_set=\${$ac_var+set}
+ eval ac_cv_env_${ac_var}_value=\$${ac_var}
+ # Pass precious variables to config.status. It doesn't matter if
+ # we pass it a second time (in addition to the command line arguments).
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+dnl If you change this globbing pattern, test it on an old shell --
+dnl it's sensitive. Putting any kind of quote in it causes syntax errors.
+[ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)]
+ ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"`
+ ac_configure_args="$ac_configure_args '$ac_arg'"
+ ;;
+ *) ac_configure_args="$ac_configure_args $ac_var=$ac_new_val"
+ ;;
+ esac
+ fi
done
if $ac_suggest_removing_cache; then
AC_MSG_WARN([changes in the environment can compromise the build])
Index: doc/autoconf.texi
--- doc/autoconf.texi Mon, 04 Jun 2001 18:29:01 +0200 akim (ace/16_autoconf.t
1.61.2.109 644)
+++ doc/autoconf.texi Sun, 17 Jun 2001 15:59:21 +0200 akim (ace/16_autoconf.t
1.61.2.109 644)
@@ -1569,17 +1569,18 @@ @node Input, Output, Notices, Setup
@defmac AC_CONFIG_AUX_DIR (@var{dir})
@maindex CONFIG_AUX_DIR
-Use the @file{install-sh}, @file{config.sub}, @file{config.guess}, and
-Cygnus @code{configure} scripts that are in directory @var{dir}. These
-are auxiliary files used in configuration. @var{dir} can be either
-absolute or relative to @address@hidden The default is
+Use the auxiliary build tools (e.g., @file{install-sh},
address@hidden, @file{config.guess}, Cygnus @code{configure},
+Automake and Libtool scripts etc.) that are in directory @var{dir}.
+These are auxiliary files used in configuration. @var{dir} can be
+either absolute or relative to @address@hidden The default is
@address@hidden or @address@hidden/..} or
@address@hidden/../..}, whichever is the first that contains
@file{install-sh}. The other files are not checked for, so that using
@code{AC_PROG_INSTALL} does not automatically require distributing the
other auxiliary files. It checks for @file{install.sh} also, but that
-name is obsolete because some @code{make} programs have a rule that
-creates @file{install} from it if there is no @file{Makefile}.
+name is obsolete because some @command{make} have a rule that creates
address@hidden from it if there is no @file{Makefile}.
@end defmac
@@ -1678,7 +1679,7 @@ @node Configuration Actions, Configurati
Shell commands output @emph{unquoted} near the beginning of
@file{config.status}, and executed each time @file{config.status} runs
(regardless of the tag). Because they are unquoted, for example,
address@hidden will be output as the value of @var{var}. @var{init-cmds}
address@hidden will be output as the value of @code{var}. @var{init-cmds}
is typically used by @file{configure} to give @file{config.status} some
variables it needs to run the @var{commands}.
@end table
@@ -1812,7 +1813,9 @@ @node Preset Output Variables, Installat
the descriptions for those macros. @xref{Output Variable Index}, for a
complete list of output variables. @xref{Installation Directory
Variables}, for the list of the preset ones related to installation
-directories. Below are listed the other preset ones.
+directories. Below are listed the other preset ones. They all are
+precious variables (@pxref{Setting Output Variables},
address@hidden).
@c Just say no to ASCII sorting! We're humans, not computers.
@c These variables are listed as they would be in a dictionary:
@@ -2981,19 +2984,9 @@ @node Generic Programs, , Particular Pr
$PATH:/usr/libexec:/usr/sbin:/usr/etc:etc)
@end example
address@hidden AC_CHECK_FILE (@var{file}, @ovar{action-if-found},
@ovar{action-if-not-found})
address@hidden CHECK_FILE
-Check whether file @var{file} exists on the native system. If it is
-found, execute @var{action-if-found}, otherwise do
address@hidden, if given.
address@hidden defmac
-
address@hidden AC_CHECK_FILES (@var{files}, @ovar{action-if-found},
@ovar{action-if-not-found})
address@hidden CHECK_FILES
-Executes @code{AC_CHECK_FILE} once for each file listed in @var{files}.
-Additionally, defines @address@hidden (@pxref{Standard Symbols})
-for each file found.
address@hidden defmac
+You are strongly encouraged to declare the @var{variable} passed to
address@hidden etc. as precious, @xref{Setting Output Variables},
address@hidden, for more details.
@defmac AC_CHECK_PROG (@var{variable}, @var{prog-to-check-for},
@var{value-if-found}, @ovar{value-if-not-found}, @ovar{path}, @ovar{reject})
@maindex CHECK_PROG
@@ -3066,6 +3059,28 @@ @node Generic Programs, , Particular Pr
@end defmac
address@hidden FIXME: Not the proper place for these guys.
+
+You might also need to check for the existence of files. Before using
+these macros, ask yourself whether a run time test might not be a better
+solution. Be aware that, like most Autoconf macros, they test a feature
+of the host machine, and therefore, they die when cross-compiling.
+
address@hidden AC_CHECK_FILE (@var{file}, @ovar{action-if-found},
@ovar{action-if-not-found})
address@hidden CHECK_FILE
+Check whether file @var{file} exists on the native system. If it is
+found, execute @var{action-if-found}, otherwise do
address@hidden, if given.
address@hidden defmac
+
address@hidden AC_CHECK_FILES (@var{files}, @ovar{action-if-found},
@ovar{action-if-not-found})
address@hidden CHECK_FILES
+Executes @code{AC_CHECK_FILE} once for each file listed in @var{files}.
+Additionally, defines @address@hidden (@pxref{Standard Symbols})
+for each file found.
address@hidden defmac
+
+
@node Libraries, Library Functions, Alternative Programs, Existing Tests
@section Library Files
@cindex Library, checking
@@ -7004,6 +7019,78 @@ @node Setting Output Variables, Caching
@@host_frag@@
@end example
@end defmac
+
address@hidden Previous Variable
address@hidden Variable, Precious
+Running @command{configure} in different environments can be extremely
+dangerous. If for instance the user runs @samp{CC=bizarre-cc
+./configure}, then the cache, @file{config.h} and many other output
+files will depend upon @command{bizarre-cc} being the C compiler. If
+for some reason the user runs @command{/configure} again, or if it is
+run via @samp{./config.status --recheck}, (@xref{Automatic Remaking},
+and @pxref{config.status Invocation}), then the configuration can be
+inconsistent, composed of results depending upon two different
+compilers.
+
+Such variables are named @dfn{precious variables}, and can be declared
+as such by @code{AC_ARG_VAR}.
+
address@hidden AC_ARG_VAR (@var{variable}, @var{description})
address@hidden ARG_VAR
+Declare @var{variable} is a precious variable, and include its
address@hidden in the variable section of @samp{./configure --help}.
+
+Being precious means that
address@hidden @minus
address@hidden
address@hidden is @code{AC_SUBST}'d.
+
address@hidden
address@hidden is kept in the cache including if it was not specified on
+the @samp{./configure} command line. Indeed, while @command{configure}
+can notice the definition of @code{CC} in @samp{./configure
+CC=bizarre-cc}, it is impossible to notice it in @samp{CC=bizarre-cc
+./configure}, which, unfortunately, is what most users do.
+
address@hidden
address@hidden is checked for consistency between two
address@hidden runs. For instance:
+
address@hidden
+$ ./configure --silent --config-cache
+$ CC=cc ./configure --silent --config-cache
+configure: WARNING: `CC' was not set in the previous run
+configure: WARNING: changes in the environment can compromise
+configure: WARNING: the build. consider removing config.cache
+configure: WARNING: and starting over
+$ CC=gcc ./configure --config-cache --silent
+configure: WARNING: `CC' has changed since the previous run:
+configure: WARNING: former value: cc
+configure: WARNING: current value: gcc
+configure: WARNING: changes in the environment can compromise
+configure: WARNING: the build. consider removing config.cache
+configure: WARNING: and starting over
+$ ./configure --silent --config-cache
+configure: WARNING: `CC' was set to `gcc' in the previous run
+configure: WARNING: changes in the environment can compromise
+configure: WARNING: the build. consider removing config.cache
+configure: WARNING: and starting over
address@hidden example
+
address@hidden
address@hidden is kept during automatic reconfiguration
+(@pxref{config.status Invocation}) as if it had been passed as a command
+line argument, including when no cache is used:
+
address@hidden
+$ CC=/usr/bin/cc ./configure undeclared_var=raboof --silent
+$ ./config.status --recheck
+running /bin/sh ./configure undeclared_var=raboof --silent \
+ CC=/usr/bin/cc --no-create --no-recursion
address@hidden example
address@hidden itemize
address@hidden defmac
+
@node Caching Results, Printing Messages, Setting Output Variables, Results
@section Caching Results
Index: tests/torture.at
--- tests/torture.at Mon, 04 Jun 2001 18:29:01 +0200 akim (ace/b/26_torture.m4
1.28 644)
+++ tests/torture.at Sun, 17 Jun 2001 14:51:40 +0200 akim (ace/b/26_torture.m4
1.28 644)
@@ -10,6 +10,107 @@
## ---------------------------------------------------------------- ##]])
+## ------------ ##
+## AC_ARG_VAR. ##
+## ------------ ##
+
+# Check that AC_ARG_VAR caches the latest values, diagnoses
+# inconsistances, and arms config.status.
+
+AT_SETUP([AC_ARG_VAR])
+
+# We don't want to run this test if this shell doesn't support
+# `unset'.
+AT_CHECK([
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+ exit 0
+else
+ exit 77
+fi
+])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_ARG_VAR([precious], [this variable costs a lot])
+AC_OUTPUT(file)
+]])
+
+AT_DATA([file.in],
address@hidden@'
+]])
+
+AT_CHECK_AUTOCONF
+
+# Initially unset.
+unset precious
+AT_CHECK_CONFIGURE([--config-cache])
+AT_CHECK([cat file], [], [`'
+])
+
+unset precious
+AT_CHECK([./config.status --recheck], [], [ignore])
+AT_CHECK([./config.status], [], [ignore])
+AT_CHECK([cat file], [], [`'
+])
+
+
+# Set to `diamonds'.
+export precious=diamonds
+AT_CHECK_CONFIGURE([--config-cache], [], [],
+[configure: WARNING: `precious' was not set in the previous run
+configure: WARNING: changes in the environment can compromise the build
+configure: WARNING: consider removing config.cache and starting over
+])
+AT_CHECK([cat file], [], [`diamonds'
+])
+
+unset precious
+AT_CHECK([./config.status --recheck], [], [ignore])
+AT_CHECK([./config.status], [], [ignore])
+AT_CHECK([cat file], [], [`diamonds'
+])
+
+
+# Set to `apple of my eye'.
+export precious='apple of my eye'
+AT_CHECK_CONFIGURE([--config-cache], [], [],
+[configure: WARNING: `precious' has changed since the previous run:
+configure: WARNING: former value: diamonds
+configure: WARNING: current value: apple of my eye
+configure: WARNING: changes in the environment can compromise the build
+configure: WARNING: consider removing config.cache and starting over
+])
+AT_CHECK([cat file], [], [`apple of my eye'
+])
+
+unset precious
+AT_CHECK([./config.status --recheck], [], [ignore])
+AT_CHECK([./config.status], [], [ignore])
+AT_CHECK([cat file], [], [`apple of my eye'
+])
+
+
+# Don't set at all.
+unset precious
+AT_CHECK_CONFIGURE([--config-cache], [], [],
+[configure: WARNING: `precious' was set to `apple of my eye' in the previous
run
+configure: WARNING: changes in the environment can compromise the build
+configure: WARNING: consider removing config.cache and starting over
+])
+AT_CHECK([cat file], [], [`'
+])
+
+unset precious
+AT_CHECK([./config.status --recheck], [], [ignore])
+AT_CHECK([./config.status], [], [ignore])
+AT_CHECK([cat file], [], [`'
+])
+
+
+
+AT_CLEANUP
+
+
## ---------------------------------------------- ##
## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ##
## ---------------------------------------------- ##
- fyi-ac-arg-var.patch,
Akim Demaille <=
- Re: fyi-ac-arg-var.patch, Alexandre Oliva, 2001/06/17
- Re: fyi-ac-arg-var.patch, Akim Demaille, 2001/06/18
- Re: fyi-ac-arg-var.patch, Alexandre Oliva, 2001/06/19
- Re: fyi-ac-arg-var.patch, Akim Demaille, 2001/06/19
- Re: fyi-ac-arg-var.patch, Alexandre Oliva, 2001/06/19
- Re: fyi-ac-arg-var.patch, Akim Demaille, 2001/06/19
- Re: fyi-ac-arg-var.patch, Akim Demaille, 2001/06/19
- Re: fyi-ac-arg-var.patch, Pavel Roskin, 2001/06/20
- Re: fyi-ac-arg-var.patch, Akim Demaille, 2001/06/21
- AC_SYS_RESTARTABLE_SYSCALLS (was: fyi-ac-arg-var.patch), Pavel Roskin, 2001/06/22