Skip to contentSkip to conversation

Makefile patch for cscope and saner Ctags

PATCH Mark Frazer 2 participants 3 messages May 30, 2001 – May 31, 2001 Kbuild

lore
Share & tools
lore
#0 lore raw

The following patch generates saner Ctags and will build cscope output. It's against 2.4.5

Makefile renamed from Makefile.old +23 -2
@@ -334,11 +334,32 @@
 
 # Exuberant ctags works better with -I
 tags: dummy
-	CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \
+	CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "--sort=no -I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \
 	ctags $$CTAGSF `find include/asm-$(ARCH) -name '*.h'` && \
-	find include -type d \( -name "asm-*" -o -name config \) -prune -o -name '*.h' -print | xargs ctags $$CTAGSF -a && \
+	find include -type f -name '*.h' -mindepth 2 -maxdepth 2 \
+	    | grep -v include/asm- | grep -v include/config \
+	    | xargs -r ctags $$CTAGSF -a && \
+	find include -type f -name '*.h' -mindepth 3 -maxdepth 3 \
+	    | grep -v include/asm- | grep -v include/config \
+	    | xargs -r ctags $$CTAGSF -a && \
+	find include -type f -name '*.h' -mindepth 4 -maxdepth 4 \
+	    | grep -v include/asm- | grep -v include/config \
+	    | xargs -r ctags $$CTAGSF -a && \
+	find include -type f -name '*.h' -mindepth 5 -maxdepth 5 \
+	    | grep -v include/asm- | grep -v include/config \
+	    | xargs -r ctags $$CTAGSF -a && \
 	find $(SUBDIRS) init -name '*.c' | xargs ctags $$CTAGSF -a
+	mv tags tags.unsorted
+	LC_ALL=C sort -k 1,1 -s tags.unsorted > tags
+	rm tags.unsorted
 
+cscope: dummy
+	find include/asm-$(ARCH) -name '*.h' >cscope.files
+	find include $(SUBDIRS) init -type f -name '*.[ch]' \
+	    | grep -v include/asm- | grep -v include/config >> cscope.files
+	cscope -b -I include
+
+	
 ifdef CONFIG_MODULES
 ifdef CONFIG_MODVERSIONS
 MODFLAGS += -DMODVERSIONS -include $(HPATH)/linux/modversions.h
#1 lore raw
Quoted 30 lines · [email protected] said:

The following patch generates saner Ctags and will build cscope output. It's against 2.4.5

Makefile renamed from Makefile.old +16 -2
@@ -334,11 +334,32 @@
 
 # Exuberant ctags works better with -I
 tags: dummy
-	CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \
+	CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "--sort=no -I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \
 	ctags $$CTAGSF `find include/asm-$(ARCH) -name '*.h'` && \
-	find include -type d \( -name "asm-*" -o -name config \) -prune -o -name '*.h' -print | xargs ctags $$CTAGSF -a && \
+	find include -type f -name '*.h' -mindepth 2 -maxdepth 2 \
+	    | grep -v include/asm- | grep -v include/config \
+	    | xargs -r ctags $$CTAGSF -a && \
+	find include -type f -name '*.h' -mindepth 3 -maxdepth 3 \
+	    | grep -v include/asm- | grep -v include/config \
+	    | xargs -r ctags $$CTAGSF -a && \
+	find include -type f -name '*.h' -mindepth 4 -maxdepth 4 \
+	    | grep -v include/asm- | grep -v include/config \
+	    | xargs -r ctags $$CTAGSF -a && \
+	find include -type f -name '*.h' -mindepth 5 -maxdepth 5 \
+	    | grep -v include/asm- | grep -v include/config \
+	    | xargs -r ctags $$CTAGSF -a && \
 	find $(SUBDIRS) init -name '*.c' | xargs ctags $$CTAGSF -a
+	mv tags tags.unsorted
+	LC_ALL=C sort -k 1,1 -s tags.unsorted > tags
+	rm tags.unsorted
 

Makefile line 365

Quoted 10 lines
Makefile renamed from Makefile.old +7 -0
+cscope: dummy
+	find include/asm-$(ARCH) -name '*.h' >cscope.files
+	find include $(SUBDIRS) init -type f -name '*.[ch]' \
+	    | grep -v include/asm- | grep -v include/config >> cscope.files
+	cscope -b -I include
+
+	
 ifdef CONFIG_MODULES
 ifdef CONFIG_MODVERSIONS
 MODFLAGS += -DMODVERSIONS -include $(HPATH)/linux/modversions.h

You seem not to have read my response to your earlier mail proprosing such a thing (for tags only, not cscope):

    http://boudicca.tux.org/hypermail/linux-kernel/2001week21/1869.html

How does the patch above fix anything? You're sorting so that include/linux/*.h comes before include/linux/{mtd,lockd,raid,...}/*.h, but I don't see how that can be an improvement, or how it addresses your original complaint "ctags doesn't honour any CPP #if'ing".

		-- Pete
#2 lore raw
In reply to Mark Frazer

Pete Wyckoff <[email protected]> [01/05/31 13:56]:

Quoted 5 lines

You seem not to have read my response to your earlier mail proprosing such a thing (for tags only, not cscope):

    http://boudicca.tux.org/hypermail/linux-kernel/2001week21/1869.html

I did. I didn't want to sign up to maintain the ctags-ignore file though.

Quoted 5 lines

How does the patch above fix anything? You're sorting so that include/linux/*.h comes before include/linux/{mtd,lockd,raid,...}/*.h, but I don't see how that can be an improvement, or how it addresses your original complaint "ctags doesn't honour any CPP #if'ing".

The sort -s is a stable sort, so by putting things into ctags in the order I want them to appear in my tags file I get what I want. YMMV

My original complaint ain't gonna get fixed anytime soon.

Your script is definitely a better solution IMO.

-mark