How to adding pathes to dependencies in rules of `.d` files

"ljh" <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Message-ID <[email protected]>
Hi community,

I managed to do out-of-source build.

I use `CPPFLAGS += -MMD -MP` to generate `.d` files. 
The `.d` files and the source files are not in the same directory now.
`make` addes path the the target `.o` part, 
but not the prerequisites parts `.c`, `.h`.

So, the rules in `.d` files will not take effect.
Now, If I `touch` my `.h` files, it will not re-build the source files.

Is there a way to inform `make` to add path to the prerequisites too?

Thanks

$ cat build/build/foo/foo.d 
/home/ljh/Documents/make/src/build/build/foo/foo.o: foo.c foo.h
foo.h:
$ 

$ tree --charset C
.
|-- build
|   `-- build
|       |-- foo
|       |   |-- foo
|       |   |-- foo.d
|       |   |-- foo.o
|       |   `-- libfoo.so
|       `-- main
|           |-- main
|           |-- main.d
|           `-- main.o
|-- foo
|   |-- foo.c
|   |-- foo.h
|   `-- Makefile
|-- main
|   |-- main.c
|   `-- Makefile
`-- Makefile

$
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.