How to check dependencies when calling a sub-layout to create when there are changes?

If I have a makefile that calls another makefile, how do I get the makefile wizard to check if the dependencies of the makefile subfile have changed?

For example, if I have a rule

server:
     @cd $(SERVERDIR) && $(MAKE)

This calls make in the subdirectory in which I create the executable "server". However, if I change one of the files that make up the server, the parent make does not see the changes and refuses to rebuild the server - "make: server" is updated. "

How can I make the master makefile correctly detect when there is a change in one of the dependent files (for example, $ (SERVERDIR) /server.c?

+3
source share
3

,

.PHONY: server
server:
     @cd $(SERVERDIR) && $(MAKE)

Phony , makefile, , , , server.

+7

Makefile.

, server, :

server:
    $(MAKE) -C server

, server , .

:

srv:
    $(MAKE) -C server

, srv.

+1

:

But yes, if you have no choice, for example. because you do not control the sub file, the target .PHONYis what you are looking for.

+1
source

Source: https://habr.com/ru/post/1703350/


All Articles