并行makefile需要依赖项排序

并行makefile需要依赖项排序

本文介绍了并行makefile需要依赖项排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下makefile文件:

I have the following piece of makefile:

CXXFLAGS = -std=c++0x -Wall
SRCS     = test1.cpp test2.cpp
OBJDIR   = object
OBJS     = $(SRCS:%.cpp=$(OBJDIR)/%.o)

all: test1
release: clean test1

test1: $(OBJS)
    $(CXX) -o $@ $(OBJS)

$(OBJDIR)/%.o: %.cpp
    $(CXX) $(CXXFLAGS) -MD -c -o $@ $<

-include $(SRCS:.cpp=.d)

clean:
    rm -rf $(OBJDIR)/*

.PHONY: all clean release

现在,如果我尝试调用"make -j4 release",则干净目标经常在构建文件的中间执行,这会导致编译失败.我的问题是在开始发布版本之前,如何确保清理目标已经完成.

Now if I try to invoke "make -j4 release" the clean target often gets execute in the middle of building files which causes compilation to fail. My question is how to ensure that the clean target has completed before starting the release build.

推荐答案

我的偏好是

release:
    $(MAKE) clean
    $(MAKE) test1

这将强制连续创建两个目标,而不会干扰它们的内部并行性(如果有).

This forces the two targets to be made consecutively without disturbing their inner parallelism (if any).

这篇关于并行makefile需要依赖项排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 19:49