What are the differences between FOO=bar ./configure
and ./configure FOO=bar
, where ./configure
is a script generate by autoconf from a configure.am
? I know that the former sets the environment variable FOO
to bar
before running the script ./configure
, and the latter passes the string FOO=bar
to ./configure
. I think that ./configure
interprets this (and remembers it?) as setting the variable FOO
equal to bar
, but beyond that, I don't know. In particular, are there any advantages to doing it one way or the other?
Passing environment variables to autoconf's `./configure`
Asked Answered
Passing the assignment to configure
as an argument ensures that the assignment is available in config.status
, so it will be set on config.status --recheck
. That is the primary advantage of making the assignment as an argument. Note that the current autoconf documentation recommends this over passing the assignment via the environment. Older versions of autoconf did not allow assignments to be made as arguments to configure, so it is necessary to use the older form when running old configure scripts, and habits die hard so many people continue to use the environment. However, it is a good habit to pass assignments via arguments.
© 2022 - 2024 — McMap. All rights reserved.
AC_ARG_VAR
. That's the wayconfigure
keeps track of which environment variable should be preserved for--recheck
, or whose change should invalidate any configure cache used. – Waterworks