Parallelization of recursive jobs in GNU make

后端 未结 4 1175
长情又很酷
长情又很酷 2021-02-02 16:08

I am looking for an elegant way for the parallelization of jobs in GNU make. Here is a sample of what I did so far. Make processes the directories dir-1, dir-2 and dir-3 in a se

4条回答
  •  甜味超标
    2021-02-02 16:48

    I found that when using the :: (double-colon rule), I could not find a way to force order if there were any dependencies among app, lib, and doc. After reading much of the GNU Make manual, I came up with the following rules to enforce the dependencies at the same time as having a generic recursive make. Notice that the .PHONY rule is there to force make to enter the directory even though the directory already exists.

    SUBDIRS = app lib doc
    
    default: all
    
    app: lib
    
    .PHONY: $(SUBDIRS)
    
    $(SUBDIRS):
        $(MAKE) -C $@ $(MAKECMDGOALS)
    
    all clean install: $(SUBDIRS)
    

提交回复
热议问题