blob: 0b6bdf35b02916ffb59e86a5d9a1c53fd9d9284d [file] [log] [blame]
Reid Spencer2d672082004-06-19 20:32:55 +00001#!/bin/sh
Reid Spencer181e65d2004-09-20 08:09:36 +00002##===- utils/llvmgrep - Counts Lines Of Code -----------------*- Script -*-===##
3#
4# The LLVM Compiler Infrastructure
5#
6# This file was developed by Reid Spencer and is distributed under the
7# University of Illinois Open Source License. See LICENSE.TXT for details.
8#
9##===----------------------------------------------------------------------===##
10#
11# This script searches your srcdir for an egrep style pattern. This can quickly
12# help you build a list of the places you need to modify when changing a header
13# or other "global" name. The only argument is the pattern you want to search
14# for. It should be quoted to escape shell interpretation of the pattern's
15# special characters.
16#
17# Note that the implementation is based on llvmdo. See that script for more
18# details.
19##===----------------------------------------------------------------------===##
20
Reid Spencerca7592a2006-08-14 18:49:05 +000021if test $# -gt 1 ; then
22 if test "$1" = "-topdir" ; then
23 TOPDIR="$2"
24 shift; shift;
25 else
26 TOPDIR=`llvm-config --src-root`
27 fi
28fi
29
Reid Spencer2d672082004-06-19 20:32:55 +000030if test -d "$TOPDIR" ; then
31 cd $TOPDIR
Reid Spencer054defa2004-10-07 16:03:21 +000032 case `uname -s` in
33 SunOS) grep_cmd="ggrep -H -n" ;;
34 Linux) grep_cmd="egrep -H -n" ;;
35 *) grep_cmd="egrep -l -n" ;;
36 esac
Reid Spencerca7592a2006-08-14 18:49:05 +000037 ./utils/llvmdo -topdir "$TOPDIR" \
38 -dirs "include lib tools utils docs examples test projects" $grep_cmd "$*"
Reid Spencer23a354d2004-07-07 21:19:01 +000039else
Reid Spencerca7592a2006-08-14 18:49:05 +000040 echo "Can't find LLVM top directory"
Reid Spencer2d672082004-06-19 20:32:55 +000041fi