duke@435: # duke@435: # Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. duke@435: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: # duke@435: # This code is free software; you can redistribute it and/or modify it duke@435: # under the terms of the GNU General Public License version 2 only, as duke@435: # published by the Free Software Foundation. duke@435: # duke@435: # This code is distributed in the hope that it will be useful, but WITHOUT duke@435: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: # version 2 for more details (a copy is included in the LICENSE file that duke@435: # accompanied this code). duke@435: # duke@435: # You should have received a copy of the GNU General Public License version duke@435: # 2 along with this work; if not, write to the Free Software Foundation, duke@435: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: # duke@435: # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: # CA 95054 USA or visit www.sun.com if you need additional information or duke@435: # have any questions. duke@435: # duke@435: # duke@435: duke@435: # duke@435: # The cscope.out file is made in the current directory and spans the entire duke@435: # source tree. duke@435: # duke@435: # Things to note: duke@435: # 1. We use relative names for cscope. duke@435: # 2. We *don't* remove the old cscope.out file, because cscope is smart duke@435: # enough to only build what has changed. It can be confused, however, duke@435: # if files are renamed or removed, so it may be necessary to manually duke@435: # remove cscope.out if a lot of reorganization has occurred. duke@435: # duke@435: duke@435: include $(GAMMADIR)/make/scm.make duke@435: duke@435: NAWK = /usr/xpg4/bin/awk duke@435: RM = rm -f ysr@546: HG = hg duke@435: CS_TOP = ../.. duke@435: duke@435: CSDIRS = $(CS_TOP)/src $(CS_TOP)/build duke@435: CSINCS = $(CSDIRS:%=-I%) duke@435: duke@435: CSCOPE = cscope duke@435: CSCOPE_FLAGS = -b duke@435: duke@435: # Allow .java files to be added from the environment (CSCLASSES=yes). duke@435: ifdef CSCLASSES duke@435: ADDCLASSES= -o -name '*.java' duke@435: endif duke@435: duke@435: # Adding CClassHeaders also pushes the file count of a full workspace up about duke@435: # 200 files (these files also don't exist in a new workspace, and thus will duke@435: # cause the recreation of the database as they get created, which might seem duke@435: # a little confusing). Thus allow these files to be added from the environment duke@435: # (CSHEADERS=yes). duke@435: ifndef CSHEADERS duke@435: RMCCHEADERS= -o -name CClassHeaders duke@435: endif duke@435: duke@435: # Use CS_GENERATED=x to include auto-generated files in the build directories. duke@435: ifdef CS_GENERATED duke@435: CS_ADD_GENERATED = -o -name '*.incl' duke@435: else duke@435: CS_PRUNE_GENERATED = -o -name '${OS}_*_core' -o -name '${OS}_*_compiler?' duke@435: endif duke@435: duke@435: # OS-specific files for other systems are excluded by default. Use CS_OS=yes duke@435: # to include platform-specific files for other platforms. duke@435: ifndef CS_OS duke@435: CS_OS = linux macos solaris win32 duke@435: CS_PRUNE_OS = $(patsubst %,-o -name '*%*',$(filter-out ${OS},${CS_OS})) duke@435: endif duke@435: duke@435: # Processor-specific files for other processors are excluded by default. Use duke@435: # CS_CPU=x to include platform-specific files for other platforms. duke@435: ifndef CS_CPU duke@435: CS_CPU = i486 sparc amd64 ia64 duke@435: CS_PRUNE_CPU = $(patsubst %,-o -name '*%*',$(filter-out ${SRCARCH},${CS_CPU})) duke@435: endif duke@435: duke@435: # What files should we include? A simple rule might be just those files under duke@435: # SCCS control, however this would miss files we create like the opcodes and duke@435: # CClassHeaders. The following attempts to find everything that is *useful*. duke@435: # (.del files are created by sccsrm, demo directories contain many .java files duke@435: # that probably aren't useful for development, and the pkgarchive may contain duke@435: # duplicates of files within the source hierarchy). duke@435: duke@435: # Directories to exclude. duke@435: CS_PRUNE_STD = $(SCM_DIRS) \ duke@435: -o -name '.del-*' \ duke@435: -o -name '*demo' \ duke@435: -o -name pkgarchive duke@435: duke@435: CS_PRUNE = $(CS_PRUNE_STD) \ duke@435: $(CS_PRUNE_OS) \ duke@435: $(CS_PRUNE_CPU) \ duke@435: $(CS_PRUNE_GENERATED) \ duke@435: $(RMCCHEADERS) duke@435: duke@435: # File names to include. duke@435: CSFILENAMES = -name '*.[ch]pp' \ duke@435: -o -name '*.[Ccshlxy]' \ duke@435: $(CS_ADD_GENERATED) \ duke@435: -o -name '*.d' \ duke@435: -o -name '*.il' \ duke@435: -o -name '*.cc' \ duke@435: -o -name '*[Mm]akefile*' \ duke@435: -o -name '*.gmk' \ duke@435: -o -name '*.make' \ duke@435: -o -name '*.ad' \ duke@435: $(ADDCLASSES) duke@435: duke@435: .PRECIOUS: cscope.out duke@435: duke@435: cscope cscope.out: cscope.files FORCE duke@435: $(CSCOPE) $(CSCOPE_FLAGS) duke@435: duke@435: # The .raw file is reordered here in an attempt to make cscope display the most duke@435: # relevant files first. duke@435: cscope.files: .cscope.files.raw duke@435: echo "$(CSINCS)" > $@ duke@435: -egrep -v "\.java|\/build\/" $< >> $@ duke@435: -fgrep ".java" $< >> $@ duke@435: -fgrep "/build/" $< >> $@ duke@435: duke@435: .cscope.files.raw: .nametable.files duke@435: -find $(CSDIRS) -type d \( $(CS_PRUNE) \) -prune -o \ duke@435: -type f \( $(CSFILENAMES) \) -print > $@ duke@435: duke@435: cscope.clean: nametable.clean duke@435: -$(RM) cscope.out cscope.files .cscope.files.raw duke@435: duke@435: TAGS: cscope.files FORCE duke@435: egrep -v '^-|^$$' $< | etags --members - duke@435: duke@435: TAGS.clean: nametable.clean duke@435: -$(RM) TAGS duke@435: duke@435: # .nametable.files and .nametable.files.tmp are used to determine if any files duke@435: # were added to/deleted from/renamed in the workspace. If not, then there's ysr@546: # normally no need to rebuild the cscope database. To force a rebuild of ysr@546: # the cscope database: gmake nametable.clean. duke@435: .nametable.files: .nametable.files.tmp ysr@546: ( cmp -s $@ $< ) || ( cp $< $@ ) ysr@546: -$(RM) $< duke@435: ysr@546: # `hg status' is slightly faster than `hg fstatus'. Both are ysr@546: # quite a bit slower on an NFS mounted file system, so this is ysr@546: # really geared towards repos on local file systems. ysr@546: .nametable.files.tmp: ysr@546: -$(HG) fstatus -acmn > $@ duke@435: duke@435: nametable.clean: duke@435: -$(RM) .nametable.files .nametable.files.tmp duke@435: duke@435: FORCE: duke@435: duke@435: .PHONY: cscope cscope.clean TAGS.clean nametable.clean FORCE