[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recompiling all sources when the makefile changes

From: R. Diez
Subject: Re: Recompiling all sources when the makefile changes
Date: Fri, 10 Oct 2014 08:52:44 +0100

> While it's your project and you can do this if you want, making
> all objects depend on the makefile sounds like a really silly idea.
> Nobody wants to spend 30 minutes recompiling because they added one
> source file to a library, or because they added an additional test
> case.
> I suggest choosing some specific features to test, and make things depend
> on THAT.  For example, you could rebuild if CFLAGS are changed by storing
> the previous setting of CFLAGS in a file, update that file if the current
> setting differs, then add prerequisites on THAT file.

That is not so easy. First of all, each build type will have its own flags. For 
example, C will use CPPFLAGS and CFLAGS, C++ will use CPPFLAGS and CXXFLAGS, 
and the assembler, linker and librarian have different flags too. And that is 
just for a C/C++/asm project.

Then it may happen that each target uses its own flags. I think Automake allows 
this. I am not sure if you can specify different flags for a single .cpp file, 
but you can do that per program or library.

Furthermore, CFLAGS and co are probably not the only things that matter. The 
autotools most like choose other compiler arguments based on other macros or 
options. For example, AM_SILENT_RULES only changes the arguments passed to GNU 
Make, and that sort of change may be enough to justify a recompile.

Your example is valid: if you add a C++ source file to a program, there is no 
need to recompile any other files. The problem is how you figure out which 
changes to the makefile should trigger a recompile, which ones only need a 
relink, and what modifications do not actually affect the build. You could 
argue that this is just a rebuild optimisation problem, and rebuilding 
everything after any little makefile change is always the safest way.

The main reason why I am using the autotools is not portability, but automatic 
dependency handling. However, it turns out that I need to manually care about 
makefile and compiler flag dependencies. So I feel the autotools (in this case 
Automake) are letting me down.

If I change some property in a Microsoft Visual Studio C++ project, the 
development environment automatically knows what needs to be rebuilt and what 
does not. I miss that kind of intelligence in the autotools. At the very least, 
I would expect a safe flag/option that makes sure the outcome is always 
correct, even it it means rebuilding too often.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]