免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5255 | 回复: 1
打印 上一主题 下一主题

一个GCC问题,-MMD的 [复制链接]

论坛徽章:
2
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:53:17
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-06-19 11:25 |只看该作者 |倒序浏览
一个project的Makefile中,有这么几行:
  1.   9 .c.o:
  2. 10         $(CC) $(CFLAGS) -MMD -o $@ -c $<
  3. 11         @cp $*.d $*.P; \
  4. 12          sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$//' \
  5. 13              -e '/^$/ d' -e 's/$/ :/' < $*.d >> $*.P; \
  6. 14         rm -f $*.d
  7. 15
复制代码
当$@是 AMD/MSR-K6时, gcc有时在当前目录产生MSR-K6.d文件,有时产生AMD/MSR-K6.d文件。 RHEL5/Fedora8是第一种情况,而有人说Fedora12、13是第二种情况。

这就导致第11行的cp命令没法写。  如果指定cp的源文件是$*.d,则在F8、RHEL上出错; 如果指定$(*F).d,则在F12、F13上出错。


有没有办法,强制gcc产生AMD/MSR-K6.d?  也就是说,即使指定了-o选项,也要gcc采用 输入文件的pathname、只是把*.c换成*.d?


man gcc这么说的:

       -MD -MD is equivalent to -M -MF file, except that -E is not implied.  The driver determines file based on whether an -o
           option is given.  If it is, the driver uses its argument but with a suffix of .d, otherwise it take the basename of the
           input file and applies a .d suffix.

           If -MD is used in conjunction with -E, any -o switch is understood to specify the dependency output file (but
           @pxref{dashMF,,-MF}), but if used without -E, each -o is understood to specify a target object file.

           Since -E is not implied, -MD can be used to generate a dependency output file as a side-effect of the compilation pro-
           cess.

       -MMD
           Like -MD except mention only user header files, not system header files.

论坛徽章:
2
摩羯座
日期:2013-10-10 14:29:04天蝎座
日期:2014-01-03 09:14:49
2 [报告]
发表于 2010-06-19 20:06 |只看该作者
或者可以考虑在cp之前,加一条判断语句
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP