5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
26 # xref: build and maintain source cross-reference databases.
29 ONBLDDIR
=$
(dirname $
(whence
$0))
32 XREFMK
=`dirname $0`/xref.mk
33 XRMAKEFILE
=Makefile
export XRMAKEFILE
34 MAKE
="dmake -m serial"
37 # The CSCOPEOPTIONS variable can cause problems if it's set in the environment
38 # when using cscope; remove it.
43 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
44 # under certain circumstances, which can really screw things up; unset it.
49 # Print the provided failure message and exit with an error.
53 echo $PROG: $@
> /dev
/stderr
58 # Print the provided warning message.
62 echo $PROG: warning
: $@
> /dev
/stderr
66 # Print the provided informational message.
74 # Print the provided informational message, and the current value of $SECONDS
75 # in a user-friendly format.
80 typeset
-i min seconds
83 ((min
= seconds
/ 60))
84 ((sec
= seconds
% 60))
86 info
"$1 in ${min}m${sec}s"
89 which_scm |
read SCM_MODE CODEMGR_WS ||
exit 1
91 if [[ $SCM_MODE == "unknown" ]];then
92 print
-u2 "Unable to determine SCM type currently in use."
97 SRC
=$CODEMGR_WS/usr
/src
export SRC
98 MACH
=`uname -p` export MACH
100 [ -f $XREFMK ] || fail
"cannot locate xref.mk"
106 while getopts cfm
:px
: flag
; do
119 # The ENVCPPFLAGS* environment variables contain the include
120 # paths to our proto areas; clear 'em so that they don't end
121 # up in CPPFLAGS, and thus don't end up in XRINCS in xref.mk.
132 echo "usage: $PROG [-cfp] [-m <makefile>]"\
133 "[-x cscope|ctags|etags[,...]] [<subtree> ...]"\
140 shift $
((OPTIND
- 1))
143 # Get the list of directories before we reset $@.
146 [ -z "$dirs" ] && dirs=.
149 # Get the canonical path to the workspace. This allows xref to work
150 # even in the presence of lofs(7FS).
153 CODEMGR_WS
=`/bin/pwd`
157 # Process the xref format list. For convenience, support common synonyms
158 # for the xref formats.
160 if [ -z "$xrefs" ]; then
162 # Disable etags if we can't find it.
165 $MAKE -e -f $XREFMK xref.etags.check
2>/dev
/null
1>&2 && \
177 xrefs
="$xrefs cscope"
186 warn
"ignoring unknown cross-reference \"$xref\""
191 [ -z "$xrefs" ] && fail
"no known cross-reference formats specified"
195 # Process the requested list of directories.
198 if [ ! -d $dir ]; then
199 warn
"directory \"$dir\" does not exist; skipping"
204 # NOTE: we cannot use $PWD because it will mislead in the presence
207 cd $dir || fail
"cannot change to directory $dir"
209 reldir
=${pwd##${CODEMGR_WS}/}
210 if [ "$reldir" = "$pwd" ]; then
211 warn
"directory \"$pwd\" is not beneath \$CODEMGR_WS; skipping"
217 # If we're building cross-references, then run `xref.clean' first
218 # to purge any crud that may be lying around from previous aborted runs.
220 if [ -z "$clobber" ]; then
221 $MAKE -e -f $XREFMK xref.clean
> /dev
/null
225 # Find flg-related source files, if requested.
227 if [ -z "$noflg" -a -z "$clobber" ]; then
229 info
"$reldir: finding flg-related source files"
230 $MAKE -e -f $XREFMK xref.flg
> /dev
/null
231 if [ $?
-ne 0 ]; then
232 warn
"$reldir: unable to find flg-related source files"
234 nfiles
=`wc -l < xref.flg`
235 if [ "$nfiles" -eq 1 ]; then
236 msg
="found 1 flg-related source file"
238 msg
="found $nfiles flg-related source files"
240 timeinfo
"$reldir: $msg"
245 # Build or clobber all of the requested cross-references.
247 for xref
in $xrefs; do
248 if [ -n "$clobber" ]; then
249 info
"$reldir: clobbering $xref cross-reference"
250 $MAKE -e -f $XREFMK xref.
${xref}.clobber
> /dev
/null ||
251 warn
"$reldir: cannot clobber $xref cross-reference"
256 info
"$reldir: building $xref cross-reference"
257 $MAKE -e -f $XREFMK xref.
${xref} > /dev
/null ||
258 fail
"$reldir: cannot build $xref cross-reference"
259 timeinfo
"$reldir: built $xref cross-reference"
262 $MAKE -e -f $XREFMK xref.clean
> /dev
/null ||
263 warn
"$reldir: cannot clean up temporary files"