Subject: kern/6445: Fix for kernel tags
To: None <gnats-bugs@gnats.netbsd.org, perry@netbsd.org>
From: None <fb@enteract.com>
List: netbsd-bugs
Date: 11/15/1998 05:00:51
>Number:         6445
>Category:       kern
>Synopsis:       Fix for kernel "make tags" and "make links"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 15 03:05:00 1998
>Last-Modified:
>Originator:     Frederick Bruckman
>Organization:

>Release:        November 14, 1998
>Environment:
System: NetBSD fb.sa.enteract.com 1.3H NetBSD 1.3H (FB) #141: 
Sat Nov 14 11:03:32 CST 1998 fredb@fb.sa.enteract.com:
/usr/src/sys/arch/mac68k/compile/FB mac68k


>Description:
	Here's a fix for the kernel "make tags", complete and tested for
	mac68k and i386. There are two key features to this fix.

	1) The fixed list of sys subdirectories is replaced with a find/sed
	combination. This promises to be more low-maintenance than the
	present (broken) way of doing things.

	2) We're now storing full paths in the tags file, using the /sys
	symlink. The relative paths prove to be inconsistent with the 
	"make links" feature. With this fix, you can be in any kernel
	subdirectory and "less -t {function]" will more or less do the right
	thing, opening the file that matches your box's architecture, unless
	you're in another arch's subtree, in which case it should link to 
	that architecture's tags file. Serious cross-compiling set-ups will
	probably want to dispense with this, and simply set the browser 
	directly to the appropriate architecture's tags file. Using the /sys
	symlink, instead of /usr/src/sys, maintains sufficient flexibility
	for non-standard set-ups, IMHO.

	The arch specific Makefiles are left as they are, except for
	changing the relative paths to full paths. This is only complete for
	mac68k and i386. Someone will need to complete this work for the
	other arch's. Regular maintenance is still required for all of the 
	architectures, but this should be a far less less formidible job than 
	it was previously.
>How-To-Repeat:
	1) Apply patch 
	2) cd /usr/src/sys/kern; make tags; make links
>Fix:
	
--- src/sys/kern/Make.tags.inc.orig	Wed Sep  9 06:22:41 1998
+++ src/sys/kern/Make.tags.inc	Sat Oct  3 17:30:19 1998
@@ -9,13 +9,9 @@
 # there is a struct tag with the same name (eg., vmmeter).  The real
 # solution would probably be for ctags to generate "struct vmmeter" tags.
 
-COMM=	/sys/conf/*.[ch] \
-	/sys/dev/*.[ch] /sys/dev/scsipi/*.[ch] \
-	/sys/kern/*.[ch] /sys/lib/libkern/*.[ch] \
-	/sys/miscfs/*/*.[ch] \
-	/sys/net/*.[ch] /sys/netccitt/*.[ch] /sys/netinet/*.[ch] \
-	/sys/netiso/*.[ch] /sys/netns/*.[ch] \
-	/sys/nfs/*.[ch] /sys/sys/*.[ch] \
-	/sys/ufs/*/*.[ch] \
-	/sys/vm/*.[ch] \
-        /sys/uvm/*.[ch] /sys/ddb/*.[ch]
+# The invocation below returns every directory that contains sources, excluding
+# the arch directories. Traditionally, COMM would have been an explicit list.
+# This promises to be easier to maintain, considering how often the directory
+# structure of the kernel sources has been changing recently.
+COMM!=	find -H /sys ! -path "/sys/arch*" -name "*.[ch]" | sed "s@[^/]*\..*@*.\[ch\]@" | \
+	    sort -t / -u
--- src/sys/kern/Makefile.orig	Mon Sep 14 06:11:43 1998
+++ src/sys/kern/Makefile	Sat Oct  3 17:34:37 1998
@@ -22,16 +22,6 @@
 	-mv -f ../sys/vnode_if.h ../sys/vnode_if.h.bak
 	sh vnode_if.sh vnode_if.src
 
-# XXX 
-# [Note by Perry Metzger, Sept. 1998]
-# As it stands, the tags support below is hopelessly
-# broken. Just look at the names of the architectures it is dealing
-# with and where it expects to find the support for them to see why.
-# I've left the stuff in this Makefile alone in the hope that someone
-# will fix it someday -- I am assuming that it might help that
-# person if they have the old Makefile goo left in place as a starting
-# point. 
-# XXX
 
 # Kernel tags:
 # Tags files are built in the top-level directory for each architecture,
@@ -42,31 +32,28 @@
 # via remote mounts; therefore we use symlinks to $SYSTAGS, which points at
 # ${SYSDIR}/${MACHINE}/tags.
 
-ARCH=	hp300 i386 luna68k news3400 pmax sparc tahoe vax
+ARCH=	hp300 i386 luna68k mac68k news3400 pmax sparc tahoe vax
 
 SYSTAGS=/var/db/sys_tags
 SYSDIR=/sys
 
-# Directories in which to place tags links (other than machine-dependent)
-DGEN=	conf \
-	dev dev/scsi \
-	hp hp/dev hp/hpux \
-	kern libkern \
-	miscfs miscfs/deadfs miscfs/fdesc miscfs/fifofs miscfs/kernfs \
-	miscfs/lofs miscfs/nullfs miscfs/portal miscfs/procfs \
-	miscfs/specfs miscfs/umapfs miscfs/union \
-	net netccitt netinet netiso netns nfs scripts sys \
-	ufs ufs/ffs ufs/lfs ufs/mfs ufs/ufs \
-	vm
+.ifmake links
+# Directories in which to place tags links (other than machine-dependent):
+# The invocation below returns every directory that contains sources, the idea
+# being, in the face of a constantly varying source tree, that this will be 
+# easier to maintain than a fixed list.
+DGEN!=	find -H /sys ! -path "/sys/arch*" -name "*.[chs]" | \
+	    sed -e "s@/sys/@@" -e "s@/[^/]*\..*@@" | sort -t / -u
+.endif
 
 tags::
 	-for i in ${ARCH}; do \
-	    (cd ../$$i && make ${MFLAGS} tags); done
+	    (cd ../arch/$$i && make ${MFLAGS} tags); done
 
 links::
 	rm -f ${SYSTAGS}
-	ln -s ${SYSDIR}/${MACHINE}/tags ${SYSTAGS}
+	ln -s ${SYSDIR}/arch/${MACHINE}/tags ${SYSTAGS}
 	-for i in ${DGEN}; do \
-	    (cd ../$$i && { rm -f tags; ln -s ${SYSTAGS} tags; }) done
+	    (cd ../$$i && { rm -f tags; ln -s ${SYSTAGS} tags; }); done
 	-for i in ${ARCH}; do \
-	    (cd ../$$i && make ${MFLAGS} SYSTAGS=${SYSTAGS} links); done
+	    (cd ../arch/$$i && make ${MFLAGS} SYSTAGS=${SYSTAGS} links); done
--- src/sys/arch/m68k/Makefile.inc.orig	Sat Oct  3 22:20:37 1998
+++ src/sys/arch/m68k/Makefile.inc	Sun Oct  4 09:25:49 1998
@@ -1,4 +1,6 @@
 #	$NetBSD: Makefile.inc,v 1.1 1997/10/11 09:10:09 mycroft Exp $
 
-SM68K=	../m68k/m68k/*.[ch] ../m68k/include/*.h
-AM68K=	../m68k/m68k/*.S
+SYSDIR?=	/sys
+
+SM68K=	${SYSDIR}/arch/m68k/m68k/*.[ch] ${SYSDIR}/arch/m68k/include/*.h
+AM68K=	${SYSDIR}/arch/m68k/m68k/*.s
--- src/sys/arch/mac68k/Makefile.orig	Sat Oct  3 22:20:37 1998
+++ src/sys/arch/mac68k/Makefile	Sun Oct  4 09:24:25 1998
@@ -5,14 +5,15 @@
 # Find where m68k source files are for inclusion in tags
 .include <../m68k/Makefile.inc>
 
-TMAC68K=../mac68k/tags
-SMAC68K=../m68k/m68k/*.c ../m68k/include/*.h \
-	../mac68k/mac68k/*.[ch] ../mac68k/include/*.h \
-	../mac68k/dev/*.[ch]
-AMAC68K=../mac68k/mac68k/*.s
+SYSDIR?=	/sys
+TMAC68K=${SYSDIR}/arch/mac68k/tags
+SMAC68K=${SYSDIR}/arch/mac68k/mac68k/*.[ch] ${SYSDIR}/arch/mac68k/include/*.h \
+	${SYSDIR}/arch/mac68k/nubus/*.[ch] ${SYSDIR}/arch/mac68k/obio/*.[ch] \
+	${SYSDIR}/arch/mac68k/dev/*.[ch]
+AMAC68K=${SYSDIR}/arch/mac68k/mac68k/*.s ${SYSDIR}/arch/mac68k/dev/*.s
 
 # Directories in which to place tags links
-DMAC68K=mac68k dev include
+DMAC68K=mac68k dev include nubus obio
 
 .include "../../kern/Make.tags.inc"
 
@@ -25,7 +26,7 @@
 
 links:
 	-for i in ${DMAC68K}; do \
-	    cd $$i && rm -f tags; ln -s ../tags tags; done
+	    (cd $$i && rm -f tags; ln -s ../tags tags); done
 
 
 SUBDIR=	include
--- src/sys/arch/i386/Makefile.orig	Sun Oct  4 09:33:57 1998
+++ src/sys/arch/i386/Makefile	Sun Oct  4 09:40:10 1998
@@ -2,13 +2,16 @@
 
 # Makefile for i386 tags file and boot blocks
 
-TI386=	../i386/tags
-SI386=	../i386/i386/*.[ch] ../i386/include/*.h \
-	../i386/eisa/*.[ch] ../i386/isa/*.[ch] ../i386/pci/*.[ch]
-AI386=	../i386/i386/*.s
+SYSDIR?=	/sys
+
+TI386=	${SYSDIR}/arch/i386/tags
+SI386=	${SYSDIR}/arch/i386/i386/*.[ch] ${SYSDIR}/arch/i386/include/*.h \
+	${SYSDIR}/arch/i386/eisa/*.[ch] ${SYSDIR}/arch/i386/isa/*.[ch] \
+	${SYSDIR}/arch/i386/pci/*.[ch]
+AI386=	${SYSDIR}/arch/i386/i386/*.s ${SYSDIR}/arch/i386/isa/*.s
 
 # Directories in which to place tags links
-DI386=	eisa isa include pci
+DI386=	i386 eisa isa include pci
 
 .include "../../kern/Make.tags.inc"
 
@@ -21,7 +24,7 @@
 
 links:
 	-for i in ${DI386}; do \
-	    cd $$i && rm -f tags; ln -s ../tags tags; done
+	    (cd $$i && rm -f tags; ln -s ../tags tags); done
 
 
 SUBDIR=	include stand isa/pcvt
>Audit-Trail:
>Unformatted: