Why are .PHONY implicit pattern rules not triggered?

前端 未结 3 1630
盖世英雄少女心
盖世英雄少女心 2020-12-05 13:30

I have the following recursive makefile:

.PHONY: all clean

%.subdir:
    $(MAKE) -C src $*
    $(MAKE) -C dict $*

all: all.subdir

clean: clean.subdir
         


        
3条回答
  •  臣服心动
    2020-12-05 14:02

    From this section of the make manual:

    The implicit rule search (see Implicit Rules) is skipped for .PHONY targets. This is why declaring a target as .PHONY is good for performance, even if you are not worried about the actual file existing.

    Therefore, your implicit targets are never searched for because they are phony.

    You can achieve what you are trying to do another way. Try this:

    SUBDIRS := all clean
    .PHONY: $(SUBDIRS)
    
    $(SUBDIRS):
        echo $(MAKE) -C src $@
        echo $(MAKE) -C dict $@
    

提交回复
热议问题