Passing environment variables to autoconf's `./configure`
Asked Answered
H

1

8

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?

Hamforrd answered 12/12, 2012 at 20:37 Comment(0)
T
9

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.

Titulary answered 12/12, 2012 at 20:50 Comment(1)
See also the definition of precious variables in the documentation for AC_ARG_VAR. That's the way configure keeps track of which environment variable should be preserved for --recheck, or whose change should invalidate any configure cache used.Waterworks

© 2022 - 2024 — McMap. All rights reserved.