1200Sant
22362Sohair# Directories to include in cscope name file and TAGS.
3200SantCSCOPEDIRS=	bsm cam cddl compat conf contrib crypto ddb dev fs gdb \
4200Sant		geom gnu isa kern libkern modules net net80211 \
5200Sant		netgraph netinet netinet6 netipsec netpfil \
6200Sant		netsmb nfs nfsclient nfsserver nlm ofed opencrypto \
7200Sant		rpc security sys ufs vm xdr xen ${CSCOPE_ARCHDIR}
8200Sant.if !defined(CSCOPE_ARCHDIR)
9200Sant.if defined(ALL_ARCH)
10200SantCSCOPE_ARCHDIR = amd64 arm arm64 i386 powerpc riscv x86
11200Sant.else
12200SantCSCOPE_ARCHDIR = ${MACHINE}
13200Sant.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
14200SantCSCOPE_ARCHDIR += x86
15200Sant.endif
16200Sant.endif
17200Sant.endif
18200Sant
192362SohairHTAGSFLAGS+= -at `awk -F= '/^RELEASE *=/{release=$2}; END {print "FreeBSD", release, "kernel"}' < conf/newvers.sh`
202362Sohair
212362Sohair# You need the devel/cscope port for this.
22200Santcscope: cscope.out
23200Santcscope.out: ${.CURDIR}/cscope.files
24200Sant	cd ${.CURDIR}; cscope -k -buq -p4 -v
25200Sant
2615235Sgoetz${.CURDIR}/cscope.files: .PHONY
27202Sant	cd ${.CURDIR}; \
28202Sant		find ${CSCOPEDIRS} -name "*.[chSsly]" -a -type f > ${.TARGET}
29202Sant
30202Santcscope-clean:
31202Sant	cd ${.CURDIR}; \
32202Sant	    rm -f cscope.files cscope.out cscope.in.out cscope.po.out
33200Sant
34200Sant#
35200Sant# Installs SCM hooks to update the cscope database every time the source tree
36200Sant# is updated.
37200Sant# cscope understands incremental updates, so it's considerably faster when only
38200Sant# a few files have changed.
39202Sant#
40200SantHG_DIR=${.CURDIR}/../.hg
41200SantHG_HOOK=if [ \$$HG_ERROR -eq 0 ]; then cd sys && make -m ../share/mk cscope; fi
42200Santcscope-hook:
43200Sant	@if [ -d ${HG_DIR} ]; then 					\
44200Sant		if [ "`grep hooks ${HG_DIR}/hgrc`" = "" ]; then		\
45200Sant			echo "[hooks]" >> ${HG_DIR}/hgrc;		\
46200Sant			echo "update = ${HG_HOOK}" >> ${HG_DIR}/hgrc;	\
47200Sant			echo "Hook installed in ${HG_DIR}/hgrc";	\
48200Sant		else 							\
49200Sant			echo "Mercurial update hook already exists.";	\
50200Sant		fi;							\
51200Sant	fi
52200Sant
53202Sant# You need the devel/global and one of editor/emacs* ports for that.
54200SantTAGS ${.CURDIR}/TAGS: ${.CURDIR}/cscope.files
55200Sant	rm -f ${.CURDIR}/TAGS
56200Sant	cd ${.CURDIR}; xargs etags -a < ${.CURDIR}/cscope.files
57200Sant
58200Sant.if !(make(cscope) || make(cscope-clean) || make(cscope-hook) || make(TAGS))
59200Sant.include <src.opts.mk>
60200Sant
61202Sant# Loadable kernel modules
62200Sant
63200Sant.if defined(MODULES_WITH_WORLD)
64200SantSUBDIR+=modules
65200Sant.endif
66200Sant
67200Sant.include <bsd.subdir.mk>
68202Sant.endif
69200Sant