Suppose I am creating Makefiles for some project using autotools, and I am frequently changing the configure.ac
file. After that, I have to update the build files:
/path/to/project/dir$ autoreconf -vfi
...
/path/to/project/dir$ ./configure --prefix=/home/user/.local
...
/path/to/project/dir$
Can I avoid specifying the --prefix
argument each time I ran autoreconf
? If I simply omit it the next time I run ./configure
, the installation prefix is reset to /usr/local
, but I want it to keep the value /home/user/.local
I speciified on the first run of ./configure
.
Note: Of course, I could create an alias in my .bashrc
file:
alias configure="./configure --prefix=/home/user/.local
but, that way, I would have to edit the .bashrc
file every time I want to change the prefix path of the project.
Note 2: I observed that skipping re-running ./configure
makes make
run some config.status
script, so this should be possible !
I am frequently changing the
configure.ac
file. After that, I have to update the build files
Well no, not necessarily. At least, not manually. If you have already configured the project at least once, and you still have the generated Makefile and other configuration results, then each time you make
, the build system will automatically rebuild itself and reconfigure the project if needed.
I observed that skipping re-running
./configure
makesmake
run someconfig.status
script, so this should be possible !
Indeed, config.status
is written by configure
. It memorializes the configure
arguments and the results of its tests, and it is the component that actually builds output files such as makefiles. It includes support for re-running configure
with the same arguments as were used for the previous configure
run (when config.status
itself was built).
If you're satisfied to use all the same configure
arguments (including precious environment variables) when you reconfigure after making changes then the easiest thing to do is just let make
handle it. This will cover you in many cases. However, if you have removed your Makefile
, or, especially, your config.status
, then the needed information is no longer available. In addition to removing those files manually, you will also remove them if you make distclean
or make maintainer-clean
.
Of course, this does not help if you need to add, remove, or modify any configure
arguments, nor if you otherwise run configure
directly. if you want to cover such cases then I see no alternative to an approach along the general lines of the alias alternative you suggested. I would include in that class options such as creating a wrapper or environment configuration script in the project, or using the alias
command manually to add an alias that is scoped to the current shell execution context only.