kernel source insight filelist
来源:互联网 发布:美图秀秀 mac版 编辑:程序博客网 时间:2024/09/21 08:52
#!/bin/sh
###############################################################################
# File : collect-src
# Description: script to find all the compiled source file and header file
#
# You must first compile the source and generate *.o files.
#
# For kernel and busybox , the *.o.cmd file will be generated to find the header file.
# For u-boot, the .depend file will be generated to find the header file.
# Others, please concate with me for support!
#
###############################################################################
#
# Usage:
#
# collect-src [-i list_file ]
#
# where:
#
# -i list_file
# Specifies the name of the file into which the list of files
# to index is placed (default: src.list).
#
# -f
# Output full file path in the list_file
#
#
###############################################################################
DIR=.
obj_file=`echo $obj_file| sed 's/\n/ /g'`
src_list=src.list
tmp_mk=tmp_makefile.mk
full_path=false
while [ -n "$1" ]
do
case $1 in
-i)
if [ "X$2" = "X" ]; then
echo "$0: No list file specified" >&2
exit 1
fi
src_list="$2"
shift
;;
-f)
full_path=true
;;
*)
echo "Unsupport args $1"
exit
;;
esac
shift
done
cd $DIR
cat <<EOF > $tmp_mk
src_list := $src_list
pwd := \$(shell pwd)
.PHONY: all
# make all is the first target
all:
define find_file
\$(shell find \$(1) \( -name "\$(2)" -a -type f \) | \\
sed -e '/\/CVS\//d' -e '/\/RCS\//d' -e '/\.svn\//d' -e 's/^\.\///')
endef
define change1suffix
\$(foreach f,\$(1), \\
\$(addprefix \$(dir \$(f)),\$(patsubst .%.o.cmd,%.o,\$(notdir \$(f)))))
endef
define _change2suffix
\$(wildcard \$(dir \$(1))\$(patsubst %.o,.%.\$(2),\$(notdir \$(1))))
endef
define change2suffix
\$(foreach f,\$(1), \\
\$(call _change2suffix,\$(f),\$(2)))
endef
define _obj2src
\$(wildcard \$(patsubst %.o,%.\$(2),\$(1)))
endef
define obj2src
\$(eval _src_f := \$(call _obj2src,\$(1),c)) \\
\$(eval _src_f += \$(call _obj2src,\$(1),h)) \\
\$(eval _src_f += \$(call _obj2src,\$(1),l)) \\
\$(eval _src_f += \$(call _obj2src,\$(1),y)) \\
\$(eval _src_f += \$(call _obj2src,\$(1),S)) \\
\$(eval _src_f += \$(call _obj2src,\$(1),C)) \\
\$(eval _src_f += \$(call _obj2src,\$(1),cpp)) \\
\$(eval _src_f += \$(call _obj2src,\$(1),java)) \\
\$(_src_f)
endef
define get_src_from_var
\$(eval _all_files:=) \\
\$(foreach v,\$(1), \\
\$(eval _files := \$(subst \$(pwd)/,,\$(\$(v)))) \\
\$(eval _files := \$(patsubst /%,,\$(_files))) \\
\$(eval _all_files := \$(sort \$(_all_files) \$(wildcard \$(_files))))) \\
\$(_all_files) \\
\$(eval _all_files:=)
endef
define get_one_src_from_var
\$(eval file:=) \\
\$(eval _file := \$(subst \$(pwd)/,,\$(\$(1)))) \\
\$(info 1111111111_file=\$(_file)) \\
\$(eval _file := \$(patsubst /%,,\$(_file))) \\
\$(info 2222222222 _file=\$(_file)) \\
\$(eval file := \$(sort \$(file) \$(wildcard \$(_file))))) \\
\$(file) \\
\$(eval file:=)
endef
DEP_FILE := \$(call find_file,.,*.o.cmd)
\$(if \$(DEP_FILE),, \\
\$(eval DEP_FILE := \$(call find_file,.,.depend)) \\
\$(eval nokernel := true))
ifneq (\$(nokernel),true)
################ Find all kernel source files ######################
dep_objs := \$(call change1suffix,\$(DEP_FILE))
dep_vars := \$(addprefix deps_,\$(dep_objs))
### New kernel ###
dep_vars += \$(addprefix source_,\$(dep_objs))
include \$(DEP_FILE)
######## Only find the kernel directory src and header files ####
autoconf_header := \$(shell test -d include && find include -name autoconf.h)
all_src_files := \$(autoconf_header)
all_src_files += \$(call get_src_from_var,\$(dep_vars))
else # \$(nokernel) == true
############### Not kernel ##########################################
O_SRC := \$(call find_file,.,*.o))
all_src_files := \$(call obj2src,\$(O_SRC))
#################### Find all source file by .depend ############
ifneq (\$(DEP_FILE),)
\$(foreach f,\$(DEP_FILE), \\
\$(shell sed 's/\(^[a-zA-Z0-9_][a-zA-Z0-9_-]*\.o\):/\1:=/' \$(f) > \$(f).tmp))
dep_vars := \$(notdir \$(O_SRC))
include \$(addsuffix .tmp,\$(DEP_FILE))
all_src_files := \$(sort \$(all_src_files) \$(call get_src_from_var,\$(dep_vars)))
endif # DEP_FILE
endif # end of nokernel
all:
\$(foreach f,\$(all_src_files),\$(shell echo \$(f) >> \$(src_list)))
@echo "----------- generate source file success ----------"
EOF
PWD=`pwd`
### collect files by Makefile
make -f $tmp_mk
all_src=`cat $src_list`
### remove tmp files
#rm -rf $tmp_mk
if [ "$full_path" = "true" ]; then
rm -rf $src_list
for f in $all_src; do
echo $PWD/$f >> $src_list
done
fi
# Generate cscope database with kernel mode
#cscope -k -b -i $src_list
- kernel source insight filelist
- kernel source insight file list.
- Source Insight建工程之Kernel
- Source Insight建工程之Kernel
- Source Insight建工程之Kernel
- Source Insight建工程之Kernel
- Source Insight
- Source Insight
- source insight
- Source Insight
- Source Insight
- Source Insight
- source insight
- source insight
- source insight
- source insight
- source insight
- Source Insight
- 直接启动tomcat时为tomcat指定JDK 而不是读取环境变量中的配置
- bat启动软件例子
- linux下如何恢复rm命令删除的文件
- 毕业于毕业设计
- 使用自定义分隔符分离字符串 解决Delphi7下TStringList.Delimiter分离无法跳过空格问题
- kernel source insight filelist
- MPI 的基本数据结构
- SQLNET.AUTHENTICATION_SERVICES值在不同操作系统下的含义
- 关于java中的static
- 编写扩展的理由,简实示例
- JVM系列一:JVM内存组成及分配
- Codejam Africa and Arabia 2011 qualification round question C
- oracle函数返回表
- Windows平台进行Objective-C开发