Linux内核---8.filechk函数分析
来源:互联网 发布:淘宝店能放音乐吗 编辑:程序博客网 时间:2024/05/30 22:51
filechk是定义在linux-2.6.30.4/scripts/Kbuild.include中
点击(此处)折叠或打开
- 49 define filechk
- 50 $(Q)set -e; \
- 51 $(kecho) ' CHK $@'; \
- 52 mkdir -p $(dir $@); \
- 53 $(filechk_$(1)) < $< > $@.tmp; \
- 54 if [ -r $@ ] && cmp -s $@ $@.tmp; then \
- 55 rm -f $@.tmp; \
- 56 else \
- 57 $(kecho) ' UPD $@'; \
- 58 mv -f $@.tmp $@; \
- 59 fi
- 60 endef
这样调用filechk函数的:
点击(此处)折叠或打开
- linux-2.6.30.4/Makefile
- 714 include/linux/version.h: $(srctree)/Makefile FORCE
- 715 $(call filechk,version.h)
调用时打印如下:
点击(此处)折叠或打开
- set -e; : ' CHK include/linux/version.h'; mkdir -p include/linux/; (echo \#define LINUX_VERSION_CODE 132638; echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';) < /root/kernel/linux-2.6.30.4/Makefile > include/linux/version.h.tmp; if [ -r include/linux/version.h ] && cmp -s include/linux/version.h include/linux/version.h.tmp; then rm -f include/linux/version.h.tmp; else : ' UPD include/linux/version.h'; mv -f include/linux/version.h.tmp include/linux/version.h; fi
$@ // 目标是 include/linux/version.h
$< // 依赖是 $(srctree)/Makefile
L53 $(filechk_$(1)) < $< > $@.tmp; //$(1)是Makefile中函数的第一个参数的写法,此处是version.h
//$(file_chk_version.h) < /root/kernel/linux-2.6.30.4/Makefile > include/linux/versin.h.tmp
//这个地方不是很明白为什么要把 /root/kernel/linux-2.6.30.4/Makefile重定向为输入,去掉之后是没有问题的。
//$(file_chk_version.h)是在linux-2.6.30.4/Makefile中定义的
点击(此处)折叠或打开
- 708 define filechk_version.h
- 709 (echo \#define LINUX_VERSION_CODE $(shell \
- 710 expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
- 711 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
- 712 endef
将下面这两句写入到include/linux/version.h.tmp中
#define LINUX_VERSION_CODE 132638#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
L55 if [ -r $@ ] && cmp -s $@ $@.tmp; //如果 include/linux/version.h存在并且与version.h.tmp按字节比较不一样,就用version.h.tmp覆盖version.h。
//假设Makefile中定义的版本号与version.h不一致,则以Makefile中的版本号为准。
还有一处调用filechk
点击(此处)折叠或打开
- 699 uts_len := 64
- 700 define filechk_utsrelease.h
- 701 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
- 702 echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
- 703 exit 1; \
- 704 fi; \
- 705 (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\";)
- 706 endef
- 717 include/linux/utsrelease.h: include/config/kernel.release FORCE
- 718$(call filechk,utsrelease.h)
0 0
- Linux内核---8.filechk函数分析
- linux makefile filechk
- linux内核schedule函数分析
- linux内核--wait_event_interruptible_timeout()函数分析
- linux内核分析之signal.c函数
- Linux内核中mktime()函数算法分析
- Linux内核中start_kernel函数的分析
- Linux内核中mktime()函数算法分析
- linux内核启动第二阶段分析-setup_arch()函数
- linux内核calibrate_delay函数实现分析
- Linux-0.12内核sleep_on函数分析
- linux内核启动第二阶段分析-setup_arch()函数
- Linux内核0.11版本schedule()函数分析
- Linux内核0.11版本sys_waitpid()函数分析
- linux内核中2410_gpio_cfgpin函数分析
- Linux内核分析课程3_start_kernel()函数分析
- 《Linux内核分析》-函数调用模型与堆栈分析
- Linux内核延时研究与函数代码分析
- shell 脚本的基础
- 1016 ProblemP
- 使用DOM4J解析xml
- (1)MySQL语句规范
- 探索linux管道的容量
- Linux内核---8.filechk函数分析
- 运维小技巧:使用ss命令代替 netstat,和netstat说再见
- Codeforces Round #360 (Div. 2) D. Remainders Game
- NYOJ86找球号(一)
- Android开发Calendar的基本使用
- 聊聊同步、异步、阻塞与非阻塞
- HDU-1054 Strategic Game(二分图最小顶点覆盖)
- 关于stm32 HardFault_Handler 异常的处理 死机
- mingW 编译 vlc-2.2.4 configure.ac:1: error: possibly undefined macro: dnl 错误.