I'm building a program by running
./configure --example-option-1 --example-option-2 --etc
then
make && make install
Is there a way to save those ./configure options so that next time I run ./configure they are applied by default?
That is, later on I might want to run
./configure --example-option-3
And have previously-saved options also apply. Or better yet, add --example-option-3 to the same "options file" then just run ./configure again.
You can achieve that by means of xargs which takes the arguments for the command to be executed from the standard input.
For saving the configuration into the file config:
echo --example-option-1 --example-option-2 --etc | tee config | xargs ./configure
That is, the file config will contain the arguments that were given at echo's command line:
$ cat config
--example-option-1 --example-option-2 --etc
For retrieving the saved configuration from this file config:
cat config | xargs ./configure
That is, ./configure will be executed with the arguments obtained at the standard input by means of xargs.
If later, you want to apply that saved configuration and an additional option, --example-option-3, then:
cat config | xargs ./configure --example-option-3
You don't say exactly why you are re-running configure, but just to point out that configure creates a config.status script. That script will recreate all the templated files using the configuration options you provided originally.
You can also use the config.status --recheck command to re-run configure using the same set of command-line options as was originally provided.
And of course, if you use automake the generated makefiles will contain rules to automatically update all these files whenever any template, or configure.ac, is modified so you don't have to do it by hand; just run make.
So if you have a configured directory already you don't need anything special to redo the configuration using the same arguments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With