jerry的小窝jarodlau.blog.chinaunix.net
jarodlau
全部博文(156)
2010年(13)
2008年(39)
2007年(104)
aaaaa5aa
sanyujoj
cynthia
浪花小雨
Bsolar
仇一败
乐百事2
eva2021h
million
遗城浅落
分类: LINUX
2007-05-19 19:03:00
看大家讨论得热烈,我也写点。呵呵 其实内核原代码的Makefile就包含了make tags/TAGS的选项, 但是生成的tags太大,因为包含了drivers等不常用的目录。 因此参照内核的Makefile文件,写了一个Makefile, 用来生成ctags/cscope/etags。 这样,可以根据自己的需要,删除和添加目录。 我以前没有用过tags/cscope,不知道有没有更好的方法。欢迎指教。 也请大家补充tags/cscope的常用的和好用的命令,技巧。 一、用法 找一个空目录,把附件Makefile拷贝进去。 然后在该目录中选择性地运行如下make命令: 注:SRCDIR用来指定内核源代码目录,如果没有指定, 则缺省为/usr/src/linux/,如 $ make 将处理/usr/src/linux下的源文件,在当前目录生成ctags, cscope 1) 只创建ctags $ make SRCDIR=/usr/src/linux-2.6.12/ tags 2) 只创建cscope $ make SRCDIR=/usr/src/linux-2.6.12/ cscope 3) 创建ctags和cscope $ make SRCDIR=/usr/src/linux-2.6.12/ 4) 只创建etags $ make SRCDIR=/usr/src/linux-2.6.12/ TAGS 二、处理时包括的内核源文件: 1) 不包括drivers,sound目录 2) 不包括无关的体系结构目录 3) fs目录只包括顶层目录和ext2,proc目录 对2.6.12.1内核,这样生成的tags大约12M,cscopes大约19M 三、最简单的ctags命令 ---------------------- 1) 进入 进入vim后,用 :tag func_name 跳到函数func_name ---------------------- 2) 看函数(identifier) 想进入光标所在的函数,用 CTRL + ] ---------------------- 3) 回退 回退用 CTRL + T ---------------------- 我现在只会用这几个命令,请大家说说其他常用的命令。
#debug=ifeq ($(debug),) quiet=quiet_else quiet=endififdef SRCDIR srctree = $(SRCDIR)/else srctree = /usr/src/linux/endifSUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ -e s/arm.*/arm/ -e s/sa110/arm/ \ -e s/s390x/s390/ -e s/parisc64/parisc/ ) ARCH ?= $(SUBARCH)RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc \) -prune -oifeq ($(debug),)define all-sources ( find $(srctree) $(RCS_FIND_IGNORE) \ \( -name include \ -o -name arch \ -o -name drivers \ -o -name sound \ -o -name fs \) -prune -o \ -name '*.[chS]' -print; \ find $(srctree)arch/$(ARCH) $(RCS_FIND_IGNORE) \ -name '*.[chS]' -print; \ find $(srctree)include $(RCS_FIND_IGNORE) \ \( -name config -o -name 'asm-*' \) -prune \ -o -name '*.[chS]' -print; \ find $(srctree)include/asm-$(ARCH) $(RCS_FIND_IGNORE) \ -name '*.[chS]' -print; \ find $(srctree)include/asm-generic $(RCS_FIND_IGNORE) \ -name '*.[chS]' -print; \ find $(srctree)fs -maxdepth 1 $(RCS_FIND_IGNORE) \ -name '*.[chS]' -print; \ find $(srctree)fs/ext2 $(RCS_FIND_IGNORE) \ -name '*.[chS]' -print; \ find $(srctree)fs/proc $(RCS_FIND_IGNORE) \ -name '*.[chS]' -print )endefelse# in debug mode only process net/ipv4/*define all-sources ( find $(srctree)net/ipv4 $(RCS_FIND_IGNORE) \ -name '*.[chS]' -print )endefendif.PHONY: allall: tags cscope# If quiet is set, only print short version of commandcmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))quiet_cmd_cscope-file = FILELST cscope.files cmd_cscope-file = $(all-sources) > cscope.filesquiet_cmd_cscope = MAKE cscope.out cmd_cscope = cscope -k -b -qcscope: FORCE $(call cmd,cscope-file) $(call cmd,cscope)quiet_cmd_TAGS = MAKE $@cmd_TAGS = $(all-sources) | etags -# Exuberant ctags works better with -Iquiet_cmd_tags = MAKE $@define cmd_tags rm -f $@; \ CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_GPL --extra=+f"`; \ $(all-sources) | xargs ctags $$CTAGSF -aendefTAGS: FORCE $(call cmd,TAGS)tags: FORCE $(call cmd,tags)clean: rm -rf tags TAGS cscope*FORCE:
上一篇:Emacs 下处理中文
下一篇:开源的领导人
登录 注册