Jason Gross
Jason Gross

Reputation: 6128

Passing environment variables to autoconf's `./configure`

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?

Upvotes: 8

Views: 6852

Answers (1)

William Pursell
William Pursell

Reputation: 212238

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.

Upvotes: 10

Related Questions