linux 内核代码精简

#为了提高性能,文件系统一般都是以 relatime形式挂载进来的,见:/etc/fstab
#更新一下mtime,这样,编译过程中用到的文件的atime都会被更新
find . -exec touch -m {} \; && touch ../tag

make mrproper && make allnoconfig && make menuconfig
#在allnoconfig的基础下,通过menuconfig加入如下配置,以方便调试
************************************************************
General setup
  --Initial RAM filesystem and RAM disk (initramfs/initrd) support
Executable file formats / Enulations
  --Kernel support for ELF binaries
Networking support
Kernel hacking
  --Kernel debugging
  --Compile the kernel with debug info
  --Compile the kernel with frame pointers
************************************************************

make #编译,大约需要10分钟

#删除编译过程中没有用到的文件 
find . -type f ! -anewer ../tag | grep -v '/\.svn' | xargs rm

#删除所有空目录
loop=found; while [ ! -z $loop ]; do loop=$(find . -type d | grep -v '/\.svn' | while read dirname; do cnt=$(ls $dirname | wc -l); if [ 0 -eq $cnt ]; then rm -rf $dirname; echo -n found; fi; done;); done;

结果上面处理的代码可以再次变量

清理不包含源文件和头文件的目录:
find . -type d | while read dirname; do cnt=`find $dirname -name '*.[cSh]' | wc -l`; if [ 0 -eq $cnt ]; then rm -rf $dirname; fi; done;

 

posted @ 2013-07-19 18:25  jlins  阅读(362)  评论(0编辑  收藏  举报