1 #
   2 # Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.
   8 #
   9 # This code is distributed in the hope that it will be useful, but WITHOUT
  10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12 # version 2 for more details (a copy is included in the LICENSE file that
  13 # accompanied this code).
  14 #
  15 # You should have received a copy of the GNU General Public License version
  16 # 2 along with this work; if not, write to the Free Software Foundation,
  17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 #
  19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 # or visit www.oracle.com if you need additional information or have any
  21 # questions.
  22 #  
  23 #
  24 
  25 #
  26 # The cscope.out file is made in the current directory and spans the entire
  27 # source tree.
  28 #
  29 # Things to note:
  30 #       1. We use relative names for cscope.
  31 #       2. We *don't* remove the old cscope.out file, because cscope is smart
  32 #          enough to only build what has changed.  It can be confused, however,
  33 #          if files are renamed or removed, so it may be necessary to manually
  34 #          remove cscope.out if a lot of reorganization has occurred.
  35 #
  36 
  37 include $(GAMMADIR)/make/scm.make
  38 
  39 NAWK    = awk
  40 RM      = rm -f
  41 HG      = hg
  42 CS_TOP  = ../..
  43 
  44 CSDIRS  = $(CS_TOP)/src $(CS_TOP)/build
  45 CSINCS  = $(CSDIRS:%=-I%)
  46 
  47 CSCOPE          = cscope
  48 CSCOPE_FLAGS    = -b
  49 
  50 # Allow .java files to be added from the environment (CSCLASSES=yes).
  51 ifdef   CSCLASSES
  52 ADDCLASSES=     -o -name '*.java'
  53 endif
  54 
  55 # Adding CClassHeaders also pushes the file count of a full workspace up about
  56 # 200 files (these files also don't exist in a new workspace, and thus will
  57 # cause the recreation of the database as they get created, which might seem
  58 # a little confusing).  Thus allow these files to be added from the environment
  59 # (CSHEADERS=yes).
  60 ifndef  CSHEADERS
  61 RMCCHEADERS=    -o -name CClassHeaders
  62 endif
  63 
  64 # Use CS_GENERATED=x to include auto-generated files in the build directories.
  65 ifdef   CS_GENERATED
  66 CS_ADD_GENERATED        = -o -name '*.incl'
  67 else
  68 CS_PRUNE_GENERATED      = -o -name '${OS}_*_core' -o -name '${OS}_*_compiler?'
  69 endif
  70 
  71 # OS-specific files for other systems are excluded by default.  Use CS_OS=yes
  72 # to include platform-specific files for other platforms.
  73 ifndef  CS_OS
  74 CS_OS           = linux macos solaris win32 bsd
  75 CS_PRUNE_OS     = $(patsubst %,-o -name '*%*',$(filter-out ${OS},${CS_OS}))
  76 endif
  77 
  78 # Processor-specific files for other processors are excluded by default.  Use
  79 # CS_CPU=x to include platform-specific files for other platforms.
  80 ifndef  CS_CPU
  81 CS_CPU          = i486 sparc amd64 ia64
  82 CS_PRUNE_CPU    = $(patsubst %,-o -name '*%*',$(filter-out ${SRCARCH},${CS_CPU}))
  83 endif
  84 
  85 # What files should we include?  A simple rule might be just those files under
  86 # SCCS control, however this would miss files we create like the opcodes and
  87 # CClassHeaders.  The following attempts to find everything that is *useful*.
  88 # (.del files are created by sccsrm, demo directories contain many .java files
  89 # that probably aren't useful for development, and the pkgarchive may contain
  90 # duplicates of files within the source hierarchy).
  91 
  92 # Directories to exclude.
  93 CS_PRUNE_STD    = $(SCM_DIRS) \
  94                   -o -name '.del-*' \
  95                   -o -name '*demo' \
  96                   -o -name pkgarchive
  97 
  98 CS_PRUNE        = $(CS_PRUNE_STD) \
  99                   $(CS_PRUNE_OS) \
 100                   $(CS_PRUNE_CPU) \
 101                   $(CS_PRUNE_GENERATED) \
 102                   $(RMCCHEADERS)
 103 
 104 # File names to include.
 105 CSFILENAMES     = -name '*.[ch]pp' \
 106                   -o -name '*.[Ccshlxy]' \
 107                   $(CS_ADD_GENERATED) \
 108                   -o -name '*.il' \
 109                   -o -name '*.cc' \
 110                   -o -name '*[Mm]akefile*' \
 111                   -o -name '*.gmk' \
 112                   -o -name '*.make' \
 113                   -o -name '*.ad' \
 114                   $(ADDCLASSES)
 115 
 116 .PRECIOUS:      cscope.out
 117 
 118 cscope cscope.out: cscope.files FORCE
 119         $(CSCOPE) $(CSCOPE_FLAGS)
 120 
 121 # The .raw file is reordered here in an attempt to make cscope display the most
 122 # relevant files first.
 123 cscope.files: .cscope.files.raw
 124         echo "$(CSINCS)" > $@
 125         -egrep -v "\.java|\/make\/"     $< >> $@
 126         -fgrep ".java"                  $< >> $@
 127         -fgrep "/make/"         $< >> $@
 128 
 129 .cscope.files.raw:  .nametable.files
 130         -find $(CSDIRS) -type d \( $(CS_PRUNE) \) -prune -o \
 131             -type f \( $(CSFILENAMES) \) -print > $@
 132 
 133 cscope.clean:  nametable.clean
 134         -$(RM) cscope.out cscope.files .cscope.files.raw
 135 
 136 TAGS:  cscope.files FORCE
 137         egrep -v '^-|^$$' $< | etags --members -
 138 
 139 TAGS.clean:  nametable.clean
 140         -$(RM) TAGS
 141 
 142 # .nametable.files and .nametable.files.tmp are used to determine if any files
 143 # were added to/deleted from/renamed in the workspace.  If not, then there's
 144 # normally no need to rebuild the cscope database. To force a rebuild of
 145 # the cscope database: gmake nametable.clean.
 146 .nametable.files:  .nametable.files.tmp
 147         ( cmp -s $@ $< ) || ( cp $< $@ )
 148         -$(RM) $<
 149 
 150 # `hg status' is slightly faster than `hg fstatus'. Both are
 151 # quite a bit slower on an NFS mounted file system, so this is
 152 # really geared towards repos on local file systems.
 153 .nametable.files.tmp:
 154         -$(HG) fstatus -acmn > $@
 155 nametable.clean:
 156         -$(RM) .nametable.files .nametable.files.tmp
 157 
 158 FORCE:
 159 
 160 .PHONY:         cscope cscope.clean TAGS.clean nametable.clean FORCE