How the Kernel compile .c files for Kernel Module
来源:互联网 发布:阿里云服务器怎么升级 编辑:程序博客网 时间:2024/05/17 22:07
在scripts目录下有 Makefile.build文件
中间有
%.o: %.c FORCE
这个规则是 用来编译 .c文件的
主要是这句
$(call if_changed_rule, cc_o_c)
if_changed_rule在 Kbuild.include中
# Usage: $(call if_changed_rule,foo)
# Will check if $(cmd_foo) or any of the prerequisites changed,
# and if so will execute $(rule_foo).
if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), /
@set -e; /
$(rule_$(1)))
那就是说 如果文件变化,就执行 rule_cc_o_c
define rule_cc_o_c
echo "---" 这里加上这句话,就会把整个语句全都打出来了
$(call echo-cmd,checksrc) $(cmd_checksrc) /
$(call echo-cmd,cc_o_c) $(cmd_cc_o_c); /
$(cmd_modversions) /
scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > /
$(dot-target).tmp; /
rm -f $(depfile); /
mv -f $(dot-target).tmp $(dot-target).cmd
endef
最后发现是 @set -e这句话在作怪
把 @符号去掉,所有的都可以打出来了。。。。 再研究一下。。。
是因为@的作用范围是这一行,用/ 和 define出来的东东都在一行 所以都不输出所执行的命令了。。。
现在我把 rule_cc_o_c 改成这样, 这条规则应该是适应所有c文件的。不仅仅是对kernel module的
define rule_cc_o_c
$(call echo-cmd,checksrc) $(cmd_checksrc) /
$(call echo-cmd,cc_o_c)
$(cmd_cc_o_c)
@set -e; /
$(cmd_modversions) /
scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > /
$(dot-target).tmp; /
rm -f $(depfile); /
mv -f $(dot-target).tmp $(dot-target).cmd
endef
这样 就向平时一样,可以显示 gcc 的选项 编译的文件 等了。。。
补充说一点。。。,用逗号代替分号 也可以有如此的效果,经过测试,这样加逗号很容易出错
尤其是在 kernel的makefile中
。。。。而这条规则貌似是只对kernel module起作用
如
cmd_link_multi-m = echo "",$(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps)
#yw changed
原本这个link的命令是没有输出内容的, 调用之前有一个@符号的
我加了 echo "", 强行将这句话分开了。 就可以输出了。。。。
- How the Kernel compile .c files for Kernel Module
- How to compile a kernel module outside the kernel
- How to compile kernel modules for the kernel 2.6
- Cross compile the kernel module
- How to Compile the Linux Kernel
- how to compile the linux kernel
- how to compile kernel
- how to compile kernel
- Compile the mainline Linux kernel for Ubuntu
- How to read/write files within a Linux kernel module?
- How To Compile A Kernel - The Ubuntu Way
- How To Compile A Kernel - The Ubuntu Way
- How To Compile A Kernel - The Ubuntu Way
- how to compile uClinux kernel
- How to compile your kernel
- Compile for old-kernel Linux
- linux kernel Module compile about "Hello, altercrazy"
- HOWTO compile kernel modules for the kernel 2.6: (编译linux2.6版本内核)
- apache与iis的优劣对比
- Got an exception - java.lang.RuntimeException: Unable to get class information for @throws tag 'XXXException'.
- vb.net InputBox用法
- Android文档(二)-应用基础(1)应用组件(Application Components)
- SOA需要ESB吗?
- How the Kernel compile .c files for Kernel Module
- winform 刷新父窗体
- Apache+Tomcat集群和负载均衡安装配置笔记
- windows日志
- 位图缩放
- 我带你去哪里 VIII
- eclipse不能保存js文件解决方法
- eclipse代码提示快捷键
- 解决页面乱码问题(2009-08-20)