A long time ago, I remember using some Solaris make, and they had an ingenious option that would automatically detect when the compiler options had changed, and rebuild all rules appropriately. For example, suppose I switch from:
g++ -O3
to
g++ -g
Then all files should be recompiled. I’m using gnu make, and haven’t found any feature like this, and was wondering whether anyone has a way of making it work.
A simple way to achieve this with
gmakeis to write thegccoptions into a file. Then, in theMakefile, read these options to a variable, use this variable in thegcccommand line, plus add the dependency for all object files to this option file (can be done in the pattern rule).