cscope.make 5.2 KB
Newer Older
D
duke 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
#
# Copyright 2005-2007 Sun Microsystems, Inc.  All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#  
#

#
# The cscope.out file is made in the current directory and spans the entire
# source tree.
#
# Things to note:
#	1. We use relative names for cscope.
#	2. We *don't* remove the old cscope.out file, because cscope is smart
#	   enough to only build what has changed.  It can be confused, however,
#	   if files are renamed or removed, so it may be necessary to manually
#	   remove cscope.out if a lot of reorganization has occurred.
#

include $(GAMMADIR)/make/scm.make

NAWK	= awk
RM	= rm -f
Y
ysr 已提交
41
HG	= hg
D
duke 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
CS_TOP	= ../..

CSDIRS	= $(CS_TOP)/src $(CS_TOP)/build
CSINCS	= $(CSDIRS:%=-I%)

CSCOPE		= cscope
CSCOPE_FLAGS	= -b

# Allow .java files to be added from the environment (CSCLASSES=yes).
ifdef	CSCLASSES
ADDCLASSES=	-o -name '*.java'
endif

# Adding CClassHeaders also pushes the file count of a full workspace up about
# 200 files (these files also don't exist in a new workspace, and thus will
# cause the recreation of the database as they get created, which might seem
# a little confusing).  Thus allow these files to be added from the environment
# (CSHEADERS=yes).
ifndef	CSHEADERS
RMCCHEADERS=	-o -name CClassHeaders
endif

# Use CS_GENERATED=x to include auto-generated files in the build directories.
ifdef	CS_GENERATED
CS_ADD_GENERATED	= -o -name '*.incl'
else
CS_PRUNE_GENERATED	= -o -name '${OS}_*_core' -o -name '${OS}_*_compiler?'
endif

# OS-specific files for other systems are excluded by default.  Use CS_OS=yes
# to include platform-specific files for other platforms.
ifndef	CS_OS
CS_OS		= linux macos solaris win32
CS_PRUNE_OS	= $(patsubst %,-o -name '*%*',$(filter-out ${OS},${CS_OS}))
endif

# Processor-specific files for other processors are excluded by default.  Use
# CS_CPU=x to include platform-specific files for other platforms.
ifndef	CS_CPU
CS_CPU		= i486 sparc amd64 ia64
CS_PRUNE_CPU	= $(patsubst %,-o -name '*%*',$(filter-out ${SRCARCH},${CS_CPU}))
endif

# What files should we include?  A simple rule might be just those files under
# SCCS control, however this would miss files we create like the opcodes and
# CClassHeaders.  The following attempts to find everything that is *useful*.
# (.del files are created by sccsrm, demo directories contain many .java files
# that probably aren't useful for development, and the pkgarchive may contain
# duplicates of files within the source hierarchy).

# Directories to exclude.
CS_PRUNE_STD	= $(SCM_DIRS) \
		  -o -name '.del-*' \
		  -o -name '*demo' \
		  -o -name pkgarchive

CS_PRUNE	= $(CS_PRUNE_STD) \
		  $(CS_PRUNE_OS) \
		  $(CS_PRUNE_CPU) \
		  $(CS_PRUNE_GENERATED) \
		  $(RMCCHEADERS)

# File names to include.
CSFILENAMES	= -name '*.[ch]pp' \
		  -o -name '*.[Ccshlxy]' \
		  $(CS_ADD_GENERATED) \
		  -o -name '*.il' \
		  -o -name '*.cc' \
		  -o -name '*[Mm]akefile*' \
		  -o -name '*.gmk' \
		  -o -name '*.make' \
		  -o -name '*.ad' \
		  $(ADDCLASSES)

.PRECIOUS:	cscope.out

cscope cscope.out: cscope.files FORCE
	$(CSCOPE) $(CSCOPE_FLAGS)

# The .raw file is reordered here in an attempt to make cscope display the most
# relevant files first.
cscope.files: .cscope.files.raw
	echo "$(CSINCS)" > $@
125
	-egrep -v "\.java|\/make\/"	$< >> $@
D
duke 已提交
126
	-fgrep ".java"			$< >> $@
127
	-fgrep "/make/"		$< >> $@
D
duke 已提交
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143

.cscope.files.raw:  .nametable.files
	-find $(CSDIRS) -type d \( $(CS_PRUNE) \) -prune -o \
	    -type f \( $(CSFILENAMES) \) -print > $@

cscope.clean:  nametable.clean
	-$(RM) cscope.out cscope.files .cscope.files.raw

TAGS:  cscope.files FORCE
	egrep -v '^-|^$$' $< | etags --members -

TAGS.clean:  nametable.clean
	-$(RM) TAGS

# .nametable.files and .nametable.files.tmp are used to determine if any files
# were added to/deleted from/renamed in the workspace.  If not, then there's
Y
ysr 已提交
144 145
# normally no need to rebuild the cscope database. To force a rebuild of
# the cscope database: gmake nametable.clean.
D
duke 已提交
146
.nametable.files:  .nametable.files.tmp
Y
ysr 已提交
147 148 149 150 151 152 153 154
	( cmp -s $@ $< ) || ( cp $< $@ )
	-$(RM) $<

# `hg status' is slightly faster than `hg fstatus'. Both are
# quite a bit slower on an NFS mounted file system, so this is
# really geared towards repos on local file systems.
.nametable.files.tmp:
	-$(HG) fstatus -acmn > $@
D
duke 已提交
155 156 157 158 159 160
nametable.clean:
	-$(RM) .nametable.files .nametable.files.tmp

FORCE:

.PHONY:		cscope cscope.clean TAGS.clean nametable.clean FORCE