删除依赖关系文件 [英] make deleting dependency files
问题描述
我正在使用-MM和-MD选项来生成依赖关系我正在使用的单元测试框架的规则。具体来说:
$(TEST_OBJ_DIR)/%。d:$(TEST_SRC_DIR)/%。cpp
@ $ CPPC)-MM -MD $< -o $ @
@sed -i -e's | \(。* \)\.o:| $(OBJ_DIR)/\1.o $(TEST_OBJ_DIR)/ \1。 d $(TEST_OBJ_DIR)/\1.o:|'$ @
-include $(TEST_DEP_FILES)
当我运行 make
,所有的二进制文件链接(正确)后,我会在make退出之前看到以下额外的(不明原因的) p>
rm test / obj / dice.d test / obj / regex.o test / obj / inventoryContainer.d test / obj / color- string.d test / obj / dice.o test / obj / inventoryContainer.o test / obj / color-string.o test / obj / regex.d
从那时起是 rm
命令来了?唯一的地方 - 任何地方 - 我的makefile中有一个 rm
命令在clean指令
test-clean:
rm -f $(TEST_BIN_FILES)
rm -f $(TEST_OBJ_DIR)/ *。{a,d,o}
任何想法?
make会自动创建中间文件,如有必要链接两个规则在一起,但它会在构建结束时删除它们。您可以使用 .PRECIOUS 特殊目标来防止它从中删除他们
I'm not sure if it's gmake or gcc that I don't understand here.
I'm using the -MM and -MD options to generate dependency rules for the Unit Testing framework I'm using. Specifically:
$(TEST_OBJ_DIR)/%.d: $(TEST_SRC_DIR)/%.cpp
@$(CPPC) -MM -MD $< -o $@
@sed -i -e 's|\(.*\)\.o:|$(OBJ_DIR)/\1.o $(TEST_OBJ_DIR)/\1.d $(TEST_OBJ_DIR)/\1.o:|' $@
-include $(TEST_DEP_FILES)
When I run make
, after all binaries are linked (properly), I see the following extra (unexplained) line before make exits
rm test/obj/dice.d test/obj/regex.o test/obj/inventoryContainer.d test/obj/color-string.d test/obj/dice.o test/obj/inventoryContainer.o test/obj/color-string.o test/obj/regex.d
From whence is that rm
command coming? The only place - anywhere - that I have an rm
command in my makefile is in the clean directive
test-clean:
rm -f $(TEST_BIN_FILES)
rm -f $(TEST_OBJ_DIR)/*.{a,d,o}
Any ideas?
make will automatically create intermediate files if necessary to chain two rules together, but it will delete them at the end of the build. You can use the .PRECIOUS special target to prevent it from removing them
这篇关于删除依赖关系文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!