summaryrefslogtreecommitdiff
path: root/support/make/grep.mk
blob: b1a3bd621a1f82a8ab149e2a35b79c3eec8bd93d (plain) (blame)
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
41
42
43
44
45
46
############################################################-*-Makefile-*-####
# GREP - Search Regular Expressions
##############################################################################
# $Id$

##############################################################################
# Usage
#
#   make grep [FLAGS=<flags>] REGEX=<regex> [FILES=<files>]"
#
##############################################################################
# Examples
#
# Search for "runtime" in all source files:
#
#   make grep REGEX=runtime
#
#
# Search for "runtime" in the compiler source files:
#
#   make grep REGEX=runtime FILES='$(COMPILER_SOURCES)'
#
##############################################################################

##############################################################################
# Variables

GREP_BINARY		?= $(GREP)
GREP_FLAGS		?= $(FLAGS)
GREP_REGEX		?= $(REGEX)
GREP_FILES		?= $(if $(FILES),$(FILES),$(PROJECT_SOURCES))

##############################################################################
# Rules

grep		:
	@if [ -z '$(GREP_REGEX)' ]; then \
	    $(ECHO) "Usage:" \
	       "$(MAKE) $@ [FLAGS=<flags>] REGEX=<regex> [FILES=<files>]";\
	    exit 1; \
	fi
	@$(GREP_BINARY) $(GREP_FLAGS) '$(GREP_REGEX)' $(GREP_FILES)

.PHONY		: grep

##############################################################################