Is it possible to manage indirect .h dependencies with 'touch' command?

136 Views Asked by At

It is advised to use -MM option to manage indirect dependencies in headers. Why we don't use touch command. Am I missing anything here, or just it's because it's a hack and we want to keep the real last modification of timestamp (look like intrusive method).

Example: - stack.h, stack.c, array.h, array.c array depend on stack

array.o: array.c

array.c: array.h

stack.o: stack.c

stack.c: stack.h

stack.h: array.h
    touch stack.h

Another thing: files need to be entirely reparsed each time with -MM option, right ? And not with this touch method and be an advantage if I don't miss anything, no ?

1

There are 1 best solutions below

0
On BEST ANSWER

You can use touch. But it's painful for anything but relatively trivial environments, because you have to ensure that your header file include dependencies are accurately reflected in the makefile otherwise you can get build failures or worse, mysterious crashes.

Regarding files need to be entirely reparsed each time, you should look into the modern auto-dependency generation methods. These do the dependency generation as a side-effect of the compilation, so it doesn't cost anything extra.