10Sstevel@tonic-gate# 20Sstevel@tonic-gate# CDDL HEADER START 30Sstevel@tonic-gate# 40Sstevel@tonic-gate# The contents of this file are subject to the terms of the 51839Srscott# Common Development and Distribution License (the "License"). 61839Srscott# You may not use this file except in compliance with the License. 70Sstevel@tonic-gate# 80Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate# See the License for the specific language governing permissions 110Sstevel@tonic-gate# and limitations under the License. 120Sstevel@tonic-gate# 130Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate# 190Sstevel@tonic-gate# CDDL HEADER END 200Sstevel@tonic-gate# 21*7551SPeter.Memishian@Sun.COM# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 223212Sraf# Use is subject to license terms. 233212Sraf# 240Sstevel@tonic-gate# This Makefile is used exclusively by `xref' to generate and maintain 250Sstevel@tonic-gate# cross-reference databases (right now: cscope, ctags, and etags). 260Sstevel@tonic-gate# 270Sstevel@tonic-gate# By default, the cross-reference is built for all files underneath the 280Sstevel@tonic-gate# currrent working directory that match the criteria specified in the 290Sstevel@tonic-gate# xref.files rule below, and any files that would also be hauled over as 300Sstevel@tonic-gate# part of a `bringover' of the working directory (though this can be 310Sstevel@tonic-gate# turned off via the -f flag to `xref'). 320Sstevel@tonic-gate# 330Sstevel@tonic-gate# However, this behavior can be customized in each directory of the build 340Sstevel@tonic-gate# tree through the following Makefile macros, if necessary: 350Sstevel@tonic-gate# 360Sstevel@tonic-gate# XRDIRS: The list of directories to include; defaults to `.'. 370Sstevel@tonic-gate# The more interesting directories should be listed earlier. 380Sstevel@tonic-gate# XRPRUNE: The list of directories to prune out. 390Sstevel@tonic-gate# XRADD: The list of additional filename globs to include. 400Sstevel@tonic-gate# XRDEL: The list of additional filename globs to exclude. 410Sstevel@tonic-gate# XRINCDIRS: The list of additional include paths, in "foo bar" format. 420Sstevel@tonic-gate# XRINCS: The list of additional include paths, in "-Ifoo -Ibar" format. 430Sstevel@tonic-gate# 440Sstevel@tonic-gate# Note that XRINCDIRS and XRINCS are for specifying header paths that are 450Sstevel@tonic-gate# not already included in CPPFLAGS and HDRDIR. 460Sstevel@tonic-gate# 470Sstevel@tonic-gate# These macros are assumed to be set in a file named `Makefile', but this 480Sstevel@tonic-gate# too can be overridden via the -m option to `xref'. 490Sstevel@tonic-gate# 500Sstevel@tonic-gate# This Makefile should *never* be included by other Makefiles. 510Sstevel@tonic-gate# 520Sstevel@tonic-gate 530Sstevel@tonic-gateXRMAKEFILE=Makefile 540Sstevel@tonic-gateinclude $(SRC)/Makefile.master 550Sstevel@tonic-gate 560Sstevel@tonic-gate# 570Sstevel@tonic-gate# Default values for the cross-reference tools; these can be overridden 580Sstevel@tonic-gate# either in the environment or in XRMAKEFILE. To use regular cscope, set 590Sstevel@tonic-gate# CSCOPE to cscope and CSFLAGS to -b. 600Sstevel@tonic-gate# 610Sstevel@tonic-gateCSCOPE = $(BUILD_TOOLS)/onbld/bin/$(MACH)/cscope-fast 620Sstevel@tonic-gateCSFLAGS = -bq 630Sstevel@tonic-gateCTAGS = /usr/bin/ctags 640Sstevel@tonic-gateCTFLAGS = -wt 650Sstevel@tonic-gateETAGS = $(SPRO_VROOT)/bin/etags 660Sstevel@tonic-gateETFLAGS = -t 670Sstevel@tonic-gateFLGFLP = $(BUILD_TOOLS)/onbld/bin/flg.flp 680Sstevel@tonic-gate 690Sstevel@tonic-gateXRDIRS = . 700Sstevel@tonic-gateXRINCS = $(XRINCDIRS:%=-I%) $(HDRDIR:%=-I%) $(CPPFLAGS) 710Sstevel@tonic-gate 720Sstevel@tonic-gateinclude $(XRMAKEFILE) 730Sstevel@tonic-gate 74*7551SPeter.Memishian@Sun.COMXRADDLIST = $(XRADD) *.[Ccdshlxy] Makefile* *.il* *.cc llib-* *.xml \ 75*7551SPeter.Memishian@Sun.COM *.dtd.* *.ndl 76*7551SPeter.Memishian@Sun.COMXRDELLIST = $(XRDEL) *.ln 77*7551SPeter.Memishian@Sun.COMXRPRUNELIST = $(XRPRUNE) .hg 78*7551SPeter.Memishian@Sun.COMXRFINDADD = $(XRADDLIST:%=-o -name '%') 79*7551SPeter.Memishian@Sun.COMXRFINDDEL = $(XRDELLIST:%=-a ! -name '%') 80*7551SPeter.Memishian@Sun.COMXRFINDPRUNE = $(XRPRUNELIST:%=-o -name '%') 81*7551SPeter.Memishian@Sun.COMXRSEDPRUNE = $(XRPRUNELIST:%=/\/%\//d; /^%\//d;) 820Sstevel@tonic-gate 830Sstevel@tonic-gate.KEEP_STATE: 840Sstevel@tonic-gate.PRECIOUS: cscope.out cscope.in.out cscope.po.out tags TAGS 850Sstevel@tonic-gate 860Sstevel@tonic-gate# 870Sstevel@tonic-gate# Build the list of files to be included in the cross-reference database. 880Sstevel@tonic-gate# 890Sstevel@tonic-gate# Please note that: 900Sstevel@tonic-gate# 910Sstevel@tonic-gate# * Any additional FLG-related source files are in xref.flg. 920Sstevel@tonic-gate# 930Sstevel@tonic-gate# * We use relative pathnames for the file list; this makes it easier 940Sstevel@tonic-gate# to share the resulting cross-reference across machines. We also 950Sstevel@tonic-gate# strip the leading './' off of pathnames (if necessary) so that we 960Sstevel@tonic-gate# don't trip up vi (since it thinks foo.c and ./foo.c are different 970Sstevel@tonic-gate# files). 980Sstevel@tonic-gate# 990Sstevel@tonic-gate# * We strip out any duplicate file names, being careful not to 1000Sstevel@tonic-gate# disturb the order of the file list. 1010Sstevel@tonic-gate# 1020Sstevel@tonic-gate# * We put all the Makefiles at the end of the file list, since they're 1030Sstevel@tonic-gate# not really source files and thus can cause problems. 1040Sstevel@tonic-gate# 1050Sstevel@tonic-gate# * We otherwise do not sort the file list, since we assume that if 1060Sstevel@tonic-gate# the order matters, then XRDIRS would've been set so that the more 1070Sstevel@tonic-gate# important directories are first. 1080Sstevel@tonic-gate# 1090Sstevel@tonic-gatexref.files: 1100Sstevel@tonic-gate $(TOUCH) xref.flg 111*7551SPeter.Memishian@Sun.COM $(FIND) $(XRDIRS) `$(CAT) xref.flg` \ 112*7551SPeter.Memishian@Sun.COM -type d \( -name SCCS $(XRFINDPRUNE) \) -prune -o \ 113*7551SPeter.Memishian@Sun.COM -type f \( \( -name '' $(XRFINDADD) \) $(XRFINDDEL) \) -print |\ 1140Sstevel@tonic-gate $(PERL) -ne 's:^\./::; next if ($$seen{$$_}++); print' > xref.tmp 1150Sstevel@tonic-gate > xref.files 1160Sstevel@tonic-gate -$(GREP) -v Makefile xref.tmp >> xref.files 1170Sstevel@tonic-gate -$(GREP) Makefile xref.tmp >> xref.files 1180Sstevel@tonic-gate $(RM) xref.tmp 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate# 1210Sstevel@tonic-gate# Use the .flg files to assemble a list of other source files that are 1220Sstevel@tonic-gate# important for building the sources in XRDIRS. So that the list can be 1230Sstevel@tonic-gate# fed to the $(FIND) in xref.files, we tell $(FLGFLP) to generate relative 1240Sstevel@tonic-gate# pathnames. We filter out any files that are along paths that are being 1250Sstevel@tonic-gate# pruned. 1260Sstevel@tonic-gate# 1270Sstevel@tonic-gatexref.flg: 1280Sstevel@tonic-gate > xref.tmp 1290Sstevel@tonic-gate for dir in $(XRDIRS); do \ 1300Sstevel@tonic-gate $(FLGFLP) -r $$dir >> xref.tmp; \ 1310Sstevel@tonic-gate done 1320Sstevel@tonic-gate $(SED) '$(XRSEDPRUNE)' < xref.tmp | $(SORT) -u > xref.flg 1330Sstevel@tonic-gate $(RM) xref.tmp 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate# 1360Sstevel@tonic-gate# Note that we don't remove the old cscope.out since cscope is smart enough 1370Sstevel@tonic-gate# to rebuild only what has changed. It can become confused, however, if files 1380Sstevel@tonic-gate# are renamed or removed, so it may be necessary to do an `xref -c' if 1390Sstevel@tonic-gate# a lot of reorganization has occured. 1400Sstevel@tonic-gate# 1410Sstevel@tonic-gatexref.cscope: xref.files 1420Sstevel@tonic-gate -$(ECHO) $(XRINCS) | $(XARGS) -n1 | $(GREP) '^-I' | \ 1430Sstevel@tonic-gate $(CAT) - xref.files > cscope.files 1440Sstevel@tonic-gate $(CSCOPE) $(CSFLAGS) 1450Sstevel@tonic-gate 1460Sstevel@tonic-gatexref.cscope.clobber: xref.clean 1470Sstevel@tonic-gate -$(RM) cscope.out cscope.in.out cscope.po.out cscope.files 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate# 1500Sstevel@tonic-gate# Create tags databases, similar to above. 1510Sstevel@tonic-gate# 1520Sstevel@tonic-gate# Since assembler files contain C fragments for lint, the lint fragments will 1530Sstevel@tonic-gate# allow tags to "work" on assembler. Please note that: 1540Sstevel@tonic-gate# 1550Sstevel@tonic-gate# * We order the tags file such that source files that tags seems to 1560Sstevel@tonic-gate# get along with best are earlier in the list, and so that structure 1570Sstevel@tonic-gate# definitions are ordered before their uses. 1580Sstevel@tonic-gate# 1590Sstevel@tonic-gate# * We *don't* sort the file list within a given suffix, since we 1600Sstevel@tonic-gate# assume that if someone cared about ordering, they would've already 1610Sstevel@tonic-gate# set XRDIRS so that the more important directories are first. 1620Sstevel@tonic-gate# 1630Sstevel@tonic-gate# * We include "/dev/null" in the xref.ctags rule to prevent ctags 1640Sstevel@tonic-gate# from barfing if "xref.tfiles" ends up empty (alas, ctags is 1650Sstevel@tonic-gate# too lame to read its file list from stdin like etags does). 1660Sstevel@tonic-gate# 1670Sstevel@tonic-gate 1680Sstevel@tonic-gatexref.ctags: xref.tfiles 1690Sstevel@tonic-gate $(CTAGS) $(CTFLAGS) /dev/null `$(CAT) xref.tfiles` 1700Sstevel@tonic-gate 1710Sstevel@tonic-gatexref.ctags.clobber: xref.clean 1720Sstevel@tonic-gate -$(RM) tags 1730Sstevel@tonic-gate 1740Sstevel@tonic-gatexref.etags: xref.tfiles 1750Sstevel@tonic-gate $(CAT) xref.tfiles | $(ETAGS) $(ETFLAGS) - 1760Sstevel@tonic-gate 1770Sstevel@tonic-gatexref.etags.check: 1780Sstevel@tonic-gate @$(CAT) /dev/null | $(ETAGS) - 1790Sstevel@tonic-gate 1800Sstevel@tonic-gatexref.etags.clobber: xref.clean 1810Sstevel@tonic-gate -$(RM) TAGS 1820Sstevel@tonic-gate 1830Sstevel@tonic-gatexref.tfiles: xref.files 1840Sstevel@tonic-gate > xref.tfiles 1850Sstevel@tonic-gate -for suffix in h c C cc l y s; do \ 1860Sstevel@tonic-gate $(GREP) "\.$${suffix}$$" xref.files >> xref.tfiles; \ 1870Sstevel@tonic-gate done 1880Sstevel@tonic-gate 1890Sstevel@tonic-gate# 1900Sstevel@tonic-gate# Note that we put `cscope.files' in clobber rather than clean because 1910Sstevel@tonic-gate# cscope will whine if it doesn't exist (unless it's passed -d). 1920Sstevel@tonic-gate# 1930Sstevel@tonic-gatexref.clean: 1940Sstevel@tonic-gate -$(RM) xref.tfiles xref.files xref.tmp xref.flg ncscope.* 195