makefile with directory tree creation suitable for parallel (-j ) build

后端 未结 3 766
臣服心动
臣服心动 2020-12-31 16:11

My project needs temporary directories which are created during the build using mkdir -p similarly to this:

all: dirtree $(OBJFILES)

dirtree: 
  @mkdir -p $         


        
3条回答
  •  时光说笑
    2020-12-31 16:40

    I'm not sure I fully understand your question. However, I can say this: if your build breaks when you add parallelism, then it's an indication that you haven't defined the dependencies correctly. Ask yourself, "Do the directories need to exist before the object files are generated?" If the answer is "yes", then the directories should be listed as prerequisites of the object files. In other words:

    ${OBJFILES}: dirtree
    

    And yes, that is pretty much the standard way to do this :)

提交回复
热议问题