gnu制作“删除中间文件" [英] gnu make "Removing intermediate files"

查看:112
本文介绍了gnu制作“删除中间文件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下规则

define compile_c
$(ECHO) "CC $<"
$(Q)$(CC) $(CFLAGS) -c -MD -o $@ $<
@# The following fixes the dependency file.
@# See http://make.paulandlesley.org/autodep.html for details.
@# Regex adjusted from the above to play better with Windows paths, etc.
@$(CP) $(@:.o=.d) $(@:.o=.P); \
  $(SED) -e 's/#.*//' -e 's/^.*:  *//' -e 's/ *\\$$//' \
      -e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \
  $(RM) -f $(@:.o=.d)
endef

vpath %.c . $(TOP)
$(BUILD)/%.o: %.c $(BUILD)/%.pp
    $(call compile_c)

vpath %.c . $(TOP)

$(BUILD)/%.pp: %.c
    $(ECHO) "PreProcess $<"
    $(Q)$(CC) $(CFLAGS) -E -Wp,-C,-dD,-dI -o $@ $<

构建完成后,GNU make说
Removing intermediate files...并删除我不需要不需要的所有.pp文件.

When the build finishes, GNU make says
Removing intermediate files... and deletes all the .pp files which I do NOT want.

为什么要这样做?
如何停止?

Why is it doing this?
How do I stop it?

推荐答案

如果搜索"gnu生成中间文件",您会立即在GNU make手册部分内隐规则链.

If you search for "gnu make intermediate files" you'll immediately find the answer as to why it's happening, in the GNU make manual section Chains of Implicit Rules.

它还告诉您如何避免它:如果文件在makefile中作为目标或先决条件被提及,则该文件不能是中间文件.

It also tells you how to avoid it: a file cannot be intermediate if it is mentioned in the makefile as a target or prerequisite.

因此,只需在某处列出您的.pp文件作为某些规则的前提即可.不必一定是曾经被调用过的规则.您没有在此处提供足够的makefile以便我们提供完整的答案,但这将是这样的:

So, just list your .pp files as a prerequisite of some rule, somewhere. It doesn't have to be a rule that's ever invoked. You don't give enough of your makefile here for us to provide a complete answer, but it would be something like:

all_pps: $(ALL_OBJECTS:.o=.pp)

假设您有一个包含所有.o文件的变量ALL_OBJECTS.

assuming you had a variable ALL_OBJECTS containing all your .o files.

这篇关于gnu制作“删除中间文件"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆