gcc依赖生成不同的输出目录 [英] gcc dependency generation for a different output directory

查看:361
本文介绍了gcc依赖生成不同的输出目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用gcc生成依赖文件,但是我的构建规则将输出放在子目录中。有没有办法告诉gcc把我的子目录前缀放在为我生成的依赖文件中?

I'm using gcc to generate a dependency file but my build rules put the output into a subdirectory. Is there a way to tell gcc to put my subdirectory prefix in the dependency file it generates for me?

gcc $(INCLUDES) -E -MM $(CFLAGS) $(SRC) >>$(DEP)


推荐答案

答案是在 GCC手册:使用 -MT 标志。


-MT target

更改依赖关系生成发出的规则的目标。默认情况下,CPP采用主输入文件的名称,删除任何目录组件和任何文件后缀,如 .c ,并附加平台的常用对象后缀。结果是目标。

Change the target of the rule emitted by dependency generation. By default CPP takes the name of the main input file, deletes any directory components and any file suffix such as .c, and appends the platform's usual object suffix. The result is the target.

-MT 选项将目标设置为您指定的字符串。如果您想要多个目标,您可以将它们指定为 -MT 的单个参数,或者使用多个 -MT 选项

An -MT option will set the target to be exactly the string you specify. If you want multiple targets, you can specify them as a single argument to -MT, or use multiple -MT options.

例如, -MT'$(objpfx)foo.o'可能会给

$(objpfx)foo.o: foo.c


这篇关于gcc依赖生成不同的输出目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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